From patchwork Fri Oct 25 15:11:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13850942 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 30CFBD0C61F for ; Fri, 25 Oct 2024 15:13:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BF24C6B00A1; Fri, 25 Oct 2024 11:13:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BA29F6B00A2; Fri, 25 Oct 2024 11:13:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A6A436B00A3; Fri, 25 Oct 2024 11:13:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 8C5A26B00A1 for ; Fri, 25 Oct 2024 11:13:10 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 91A4A120BB1 for ; Fri, 25 Oct 2024 15:12:52 +0000 (UTC) X-FDA: 82712467110.21.DA8E83C Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf28.hostedemail.com (Postfix) with ESMTP id AEE32C0010 for ; Fri, 25 Oct 2024 15:12:48 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=TTYxUR93; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf28.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729869148; a=rsa-sha256; cv=none; b=49oTaJl3aTm4qjCMk9/XuEqNRxR6e44nd3xuu8/2vrUivmpSEmuwNHetR9S/rMKE8K0A/j WWVQUSU7NB8kNV0kSep8eKJwBMAn1vp6IU82h6Pwz5HxbeECu9ExdT77CHcfxe6gmPBQZg WWU1GiBElcyxOAHGGltujQ5gPsgKANc= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=TTYxUR93; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf28.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1729869148; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=PdMqUIxpls1gNH4eQdrzo/q29zzRB98r4tpBih1lnzQ=; b=Io5l6yQeODTn3KyvlnAGdvK8z7y02oCYsMpvfmmndZbNR5fi+Jwj4WDrmQnWpNbnKO5YdK 1zB9lQfO6ze5lUMqoSR50crQT7ORKDkL+Gxz0Hs/ZMAtksGljGlK4TTFnRHP28RxJyGTpG T+hP6QgNvtBF7lPJXDlBPkATvEQhiV4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729869188; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PdMqUIxpls1gNH4eQdrzo/q29zzRB98r4tpBih1lnzQ=; b=TTYxUR93kp1msM0gW1NrCDUBJybHOfMr0I051x9XaUukvrwmxa8YEmqVh+uiU9MNY5ff+o W0dPYNhDGDZl1J7R08ZLIogdMwBNfHVrYtfzjs8i/BuGNY+DQMpI5b2d2trR2jXl4XA+Th buwEnQbJOv+blDuOerRwYVmT0CMwxB8= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-642-o3a0P1v0Nd-PreOhqdKZvg-1; Fri, 25 Oct 2024 11:13:03 -0400 X-MC-Unique: o3a0P1v0Nd-PreOhqdKZvg-1 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2135819560A2; Fri, 25 Oct 2024 15:13:01 +0000 (UTC) Received: from t14s.redhat.com (unknown [10.22.65.27]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5282C300018D; Fri, 25 Oct 2024 15:12:54 +0000 (UTC) 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 v1 09/11] virtio-mem: remember usable region size Date: Fri, 25 Oct 2024 17:11:31 +0200 Message-ID: <20241025151134.1275575-10-david@redhat.com> In-Reply-To: <20241025151134.1275575-1-david@redhat.com> References: <20241025151134.1275575-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Rspam-User: X-Stat-Signature: ofe4px6tp13sk7g3k5ayd6997t9if6cc X-Rspamd-Queue-Id: AEE32C0010 X-Rspamd-Server: rspam02 X-HE-Tag: 1729869168-993219 X-HE-Meta: U2FsdGVkX188+5m/gYiZU8b53du3efL5TMQz+rMkf+lA0HYePhcnfolq4zDRKbzawPWjIYfteQlTQnB+CxknI7mzResxEuq7BjF85TtsSHAClPuuXvCVhollLkXF1KnTuEJy9RO9SjVqJKRlyXogQE3nno2l1614iev61gPkrI1DcVxQsujqvklhsnEeLxDbdI+K2OWV+9FHznUovEoPTicEX7unIjGqeqkB6RGvQjh5SbsEp+Atc3fjh4nTi7bnwrVFqWuK5EsEJfogz47ZRXOpAE1TGw1J2vkS0pU/akUpooybE3eUY+QLkKSKPILil1ut4jPb0acqKteZD86cAbUX1SLOsMJhHUItUHw7RWXmQXCC4nKqrVjvvvRq6zsP1mPe2P8RbcsXhL3itwyFKWSb94qQqkpLcdAzCTN6OtJbdZunzVrH55FudG/zTDOchexzBs2AXC+VIy5HWa9lDf+RNtah6yJoyktVjOCH9mIhpH6pF51Azg3U03TrLdqrIH8ScnSw0fHfg9NUH3gaXQgcQuuRYbL0x9T/L1J5aYJx6l2TR9x9iz4JgA+yUS5Orh0zi3lPMzY/PBglSgfgbhkJbkcyD/s4c9bqCcXCIERIhwwfu2aJ94S/QTMcKQW9p4UhchMCdw6SdP04Vjv6BoTrB6HW00MNzBKcmvi3IbAnPYqrWM8A5LuvJj4E6eznQdr6Fos4c5Ynn/8LWmy5x/F7Firj41o5ylvp1A1QEw+0XGlXYBoTUrwRLVSIXRTA+E3YoFeNuAjxnp9G8dRCItAf7fEWQ9eG/DIb+6Ln7s4hgIU3Gzqh8RuS1ypnfMmPNuJipIOr4GQ0wjdMBuoEcSMNthtf3bQt2IKBrjiT94Kcwuik8PQ+3adwM0DgXn3fdKi4a51+HZ0LR/FWGU1vD5evXIDXd3fcWMs9iRuaZKjYwW/zS4wfq7+KMe3THZ8sJnVfhFGzOVZzdfngoTm ksCtJYFP SIHoj4S8EYLtqXcPyUf2yFlfnNFjQ6MtDcfQfiiHNelXf1Pu3Xz4KCNx4eXvnx+gLTHZK1z9BgOL8OiQFm8hrmvH7vSSqhN+k40qiUe8VUJV7hVndUHYA10MQjZrCJrfRZl3myBIZjk7+0hpwMxd7ESacsacvHt20J/zepggnD6qQWvvCp9iBH5SOF68PxE4MbL8rRFkO5zqCeqBJES7HHVLi1ZQn39ZYE4RGSaF2A8fbrrlNvgeChse8egmITBc0r+FEqlfj74Z9sNNDMMpv5RVrzyJFPuum7mhlZPSpsrHzTtYceq3axqc1bI4k3Pm3j6CRuyo5QLWApG8= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, 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)