From patchwork Wed Dec 4 12:54:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13893715 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 93697E7716E for ; Wed, 4 Dec 2024 12:55:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2AB0E6B00A7; Wed, 4 Dec 2024 07:55:24 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 233C66B00A6; Wed, 4 Dec 2024 07:55:24 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0AF216B00A7; Wed, 4 Dec 2024 07:55:24 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id DA3956B00A2 for ; Wed, 4 Dec 2024 07:55:23 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 95F291C74C7 for ; Wed, 4 Dec 2024 12:55:23 +0000 (UTC) X-FDA: 82857272106.24.7DDC02C Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf22.hostedemail.com (Postfix) with ESMTP id A715EC0018 for ; Wed, 4 Dec 2024 12:55:05 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="Ev0msI2/"; spf=pass (imf22.hostedemail.com: domain of dhildenb@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhildenb@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733316914; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=8qWcPvM3uPJNBlH29eIda0Org6XNMptmimUFcDc8wZo=; b=C2Kk5WBZ47pmaOC83015BjXSPjiylhSXTMaOFZaee21VDsAYjC3mFIJGI6Qhb6LFMeC5ze u6uYgx11AJcLYVq8kB+xk2ZQgpngGqzju37eCIGZfIgwjBxvHkjivweUtp/vcKdXIXgv1V Wd7aKdoNynMWWeamPhhLI7lMsWh+TBs= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733316914; a=rsa-sha256; cv=none; b=dMHj0ahGvrl1PCvGMRRO770F+tdArXt6L2Po8A5foWfT+lSdijFuucZBXbgNTzgy01oOwX 2A2GbqHnS+x40HS5Obh0n4ZWxTwfGlmlL+ZhW4wrE+INt1TiyZMoH54m5GH3ILR/cpMtb8 5zL/yP5pztotkkr3mLoEp4D8g/sVq7s= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="Ev0msI2/"; spf=pass (imf22.hostedemail.com: domain of dhildenb@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhildenb@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1733316920; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8qWcPvM3uPJNBlH29eIda0Org6XNMptmimUFcDc8wZo=; b=Ev0msI2/1xKiqR0Qvg2LLwuFn/3Da2fR1/x+quZTxdgUwaZLX7GZ0rIlrJZJzDU0PMe3j9 LsmFVZsaxLwDxru1TJu3JAgOxeQIMEN9vOIx6YPD+KcBlBq0QxZVGYJHkKC1/mORtNoEMc tfqe01et3HH5/NlOhLG6IyqvB1aq778= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-257-mDwNXtjyOsWdXcm0VsryfQ-1; Wed, 04 Dec 2024 07:55:17 -0500 X-MC-Unique: mDwNXtjyOsWdXcm0VsryfQ-1 X-Mimecast-MFC-AGG-ID: mDwNXtjyOsWdXcm0VsryfQ Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4349e97bfc4so62390425e9.3 for ; Wed, 04 Dec 2024 04:55:17 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733316916; x=1733921716; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8qWcPvM3uPJNBlH29eIda0Org6XNMptmimUFcDc8wZo=; b=YsyrRxJjp009zg6yWLYMkZADXebbQboR799Hi3QgpEYy2A2dfahDORDcI/6t/kUd3M OBT4fhJR/z8xOScGQiO/o6fu9jYk4A42sYPsfvpuKtiuR2aG4zIS4clwqDV/BfiIx3bH AAYl1D0Axi4LCSph9dLst1Lpz8X8djZOUhZ/tS5kyRAJxKb1ewNcAeqy+0VPXu6eQW4v 1uj93x5ms9iL2sH5iFMJ3BxNzMmKlu7TB94KHh9T+VEMmqMNc2tiAxGgleGkCjmBDfj2 t5QMQBmIQhShUK/QQWF8YYKNWybV1Pv9XU0dwhMxj6frnt3gWyXHohRvwXog31hscwkU jBYg== X-Gm-Message-State: AOJu0YxYVBldCsCCX7VgUx2xr+34/ISuNPrKhA9AaBOG6GmmK9wirU4V 8Yst6DXQYH9eidW3P9eCFQtbKsD9DUzvByAAsfIYEOF81G0PDupTb1A3kIxfszQ4x/umL5OHVsg V096Bp0ebkU7SjZ94BsYMLx18KG2G4uCeNwD1O83OJbcAtRpt X-Gm-Gg: ASbGnctaF6xJDJ3HTcEIrbi78EA+p/kFK0UcLeZ7Lh6Gh+xFkqAjTVc5+6pgk1GAElW HmMO9gYOqEnUa7NYyZN4ncEJmmHINBSsuFDlhddY0DH+NhnVlUyFPxjwoVrEeALFw7XyaIdxCj0 2f9/LRVubMbghOYfVEKybqSrTSltUK2zCKzxDw4PTXMFi6D7A4JFWFi8+K/6dxK2/tfQBMaMhtY gupq4SNr1CmijDj043kl+pGIfBMjeTMRkcL6RlE+gTuSBbrEaOe10c7So/BhVqRprjOQDhA7c5n IT4vPhigXbQhYQehTuAaMDyrO1+HBwrDmwQ= X-Received: by 2002:a05:600c:4fc9:b0:434:a986:11cf with SMTP id 5b1f17b1804b1-434d09c0faamr58499765e9.8.1733316916538; Wed, 04 Dec 2024 04:55:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IH0Ukl1ZPphCA+wOQqYI2PG+9UegKLtZCsee5cNCt9biGs2cCCF0gJFsDeKmcsipWxLJl404A== X-Received: by 2002:a05:600c:4fc9:b0:434:a986:11cf with SMTP id 5b1f17b1804b1-434d09c0faamr58499655e9.8.1733316916209; Wed, 04 Dec 2024 04:55:16 -0800 (PST) Received: from localhost (p200300cbc70be10038d68aa111b0a20a.dip0.t-ipconnect.de. [2003:cb:c70b:e100:38d6:8aa1:11b0:a20a]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-434d52a3139sm24274545e9.28.2024.12.04.04.55.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 04 Dec 2024 04:55:14 -0800 (PST) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linux-s390@vger.kernel.org, virtualization@lists.linux.dev, kvm@vger.kernel.org, linux-fsdevel@vger.kernel.org, kexec@lists.infradead.org, David Hildenbrand , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?utf-8?q?Eugenio_P=C3=A9rez?= , Baoquan He , Vivek Goyal , Dave Young , Thomas Huth , Cornelia Huck , Janosch Frank , Claudio Imbrenda , Eric Farman , Andrew Morton Subject: [PATCH v2 10/12] virtio-mem: remember usable region size Date: Wed, 4 Dec 2024 13:54:41 +0100 Message-ID: <20241204125444.1734652-11-david@redhat.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241204125444.1734652-1-david@redhat.com> References: <20241204125444.1734652-1-david@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: zH38yRA1bilZKl3G4MIGhclHYypAQm9AUSynFnMQDf4_1733316916 X-Mimecast-Originator: redhat.com content-type: text/plain; charset="US-ASCII"; x-default=true X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: A715EC0018 X-Stat-Signature: uz4f6dmsg5u39zuwyiwkmtuiy8kf711p X-Rspam-User: X-HE-Tag: 1733316905-372556 X-HE-Meta: U2FsdGVkX19ofmvHdiIM3+ZzwT7PzCLVzEStS56lrfmuRp6n8yKA6IljIL62iKRwDQmPAGBC8csmX1KdP3oFUiWcV3YOQcEhMI3Pu/GzquN3SeltmhzbjAOjrJNDEWiwOWlZClqZvxfHDWvYisSyRaFMDl+t5ACDfb4F2AD1QiTOV8cW2HStJS1KFu19VFQYHK3SITEJqemY6B/w7HfWVdFde7cvRWrQtyVgVolX6k5iKMkfeBRf+sViV2uVZp14Ks9AXCBbf5jzshIOcwFhu6GAXdHIaCErFCMV+wVAUmMyEmy+do1o1HsLqNlXeIMHFqaBeWmIqCZDdeGtAVDvs0e39FOZu13Zlg5ud01YnRaaKhXTxxInvI9B7hLzQSFfR9NAA63JUot/eI0O+e31DqwoQt2nlDm6YS10njiRMSHo/kWvKh6nrccapNpQ+5cggsbgU4o/65neTglw07Z2oVap5hZ5zxp/7gHf4NG3zJZ5piMyrBzysLm2cwRmls3NE//PS6Ai17zeK7hCTwVHvcJKzKj+ldn/aogv5EL3kacWT38LHnDmKQNHhdBmcN0qzLIBnAGj5XvQxKtGuOuWax8i4RdC1TTRdf4ShXVLK8fxCP7phUwWuKzT42k/oisumSUYKfemsWG6P767PhP2+XqVrCzUAVs4z7p2MQWVnn1yFqCTaSv9rtqsh9yvLlAsCYeRwjAhLLx4sKclBXw8sXDO4igRRusZBEdIMTEjXo4mKKgpG4DVQ6UHtwsMYRS3z7vWNKQM+4+GCRNUwOWFlS8Q8VYblxsAbCcA4oHygwUqajIxgqsPUQMXddK+mxgF/mq4TcU7mwV1fArHb82T7kuUF5KbWVXWvht6QEjJXj+FfASvQi09Yz38NJ3CHv2+w4OP6FxgyOepeO4re43kwpfgJGsvuiWT7rmDH+k1Esvu/slusZNR4lVPZ/AeoTvSd7ieU9ui8ah/3rQATUw aGuP8qAH 0+ZQCGSSeKFj7McpcnfonjQpGxqig4DXmUrCEQX0J23mc8QEfJKh5I5kHMATcOjh1AsJd+mh7B0URjvF9+o55IGyroabQClY9wkf4X2I3dtuDlAg6aLgTclRFpzObM9Pb8kVP/v6/mmjWuD4za1nUa6/TRDUxQROcCsov7owmS2/3mo29mKFaLYdsd/Z6HlZCb85ITs/a9l0s427uiN2TlktOr7zK2WaFW1JEcv0FOGCNYuDinSb8ZBMQRXeNOhDeOcxlnOv7bsNXS7/OcXbGJ69gEYJ1fLa/NRHOJKhjEAXA3ThfqC4M/CISqy/FOOMx62WTbr9ErIRi8xhyMmeSBnWa32Gd9qdgh1+BloiNrSow/CP02+kNLjUOLsQSUio9NbBhpsvgShQ+Q157e1Nn4kLL3xM76LNwX9hawX9rb1UvQ5O/vOnD08gtcg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000044, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Let's remember the usable region size, which will be helpful in kdump mode next. Signed-off-by: David Hildenbrand --- drivers/virtio/virtio_mem.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/virtio/virtio_mem.c b/drivers/virtio/virtio_mem.c index 126f1d669bb0..73477d5b79cf 100644 --- a/drivers/virtio/virtio_mem.c +++ b/drivers/virtio/virtio_mem.c @@ -133,6 +133,8 @@ struct virtio_mem { uint64_t addr; /* Maximum region size in bytes. */ uint64_t region_size; + /* Usable region size in bytes. */ + uint64_t usable_region_size; /* The parent resource for all memory added via this device. */ struct resource *parent_resource; @@ -2368,7 +2370,7 @@ static int virtio_mem_cleanup_pending_mb(struct virtio_mem *vm) static void virtio_mem_refresh_config(struct virtio_mem *vm) { const struct range pluggable_range = mhp_get_pluggable_range(true); - uint64_t new_plugged_size, usable_region_size, end_addr; + uint64_t new_plugged_size, end_addr; /* the plugged_size is just a reflection of what _we_ did previously */ virtio_cread_le(vm->vdev, struct virtio_mem_config, plugged_size, @@ -2378,8 +2380,8 @@ static void virtio_mem_refresh_config(struct virtio_mem *vm) /* calculate the last usable memory block id */ virtio_cread_le(vm->vdev, struct virtio_mem_config, - usable_region_size, &usable_region_size); - end_addr = min(vm->addr + usable_region_size - 1, + usable_region_size, &vm->usable_region_size); + end_addr = min(vm->addr + vm->usable_region_size - 1, pluggable_range.end); if (vm->in_sbm) { @@ -2763,6 +2765,8 @@ static int virtio_mem_init(struct virtio_mem *vm) virtio_cread_le(vm->vdev, struct virtio_mem_config, addr, &vm->addr); virtio_cread_le(vm->vdev, struct virtio_mem_config, region_size, &vm->region_size); + virtio_cread_le(vm->vdev, struct virtio_mem_config, usable_region_size, + &vm->usable_region_size); /* Determine the nid for the device based on the lowest address. */ if (vm->nid == NUMA_NO_NODE)