Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp103637pxu; Wed, 14 Oct 2020 21:52:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJze71l5nBvc2+PZoUmx3ojHlBHyGUd4igSffJrBAtQqKxVO6MTnq01lwLCQwRztrFCudJv3 X-Received: by 2002:a17:906:c293:: with SMTP id r19mr2432100ejz.63.1602737556367; Wed, 14 Oct 2020 21:52:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602737556; cv=none; d=google.com; s=arc-20160816; b=nj3+rLYDOmD5wNR8L0Wcdc/Erl1RO0tIhxohebrOM9+eX7HEH7XYPXrPWyFtXcXJ1t RsETob9SnKBJy1YnFbAo+72Vym+qU2VRUsii4X5ZcKv2k+SawPx3UWOD+81T8u+tVDto Yohw1xMbgaFVLSZu5xMetj/A0DIWsshl63eylJ1t71/SIdsmBj5G2+R+yxDN2z5alF1E 0AIsU7S4oC45Rgeriok1cNG+TOs/X3ieIfJD90UuVHXllY9rkELq6RJAai6FSN9tAc0H mvuLsE/il3jGc/gPT3+wwGzYqY5rMaKmb7nUxrUARTfqWoi0bueJrPF2+7C/JW27aTUX dBdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:reply-to:message-id:subject:cc:to:from:date; bh=HC9oDzZz7dr9fvJDsLvBV8TFRCZ1oY8tqfOrY8VyoYM=; b=aMGz/diIlShgsJzj9xOSCvQcSh6EGniZyhtADTiRQ3wN+WYZjkE8FFAz5qesElZtgW qLcLOpjGl5vIlF2ng7SCUAfOuQ5jxtAqe/OKq9VunTfFfR/aRfXIyVEU2B2V1ZSokz+h hLILue//wgTyQxofyqACS/RHbPGM4QyWFD7cJfO5EKDtKWU6OQwBk7XIK0WdXHHLofB+ BdZhfQfJtOINX+L8cp+zERoeS9iuWZBgPejn98p0Y19kpZ+0dacz/R7+5jwAQFm6vCDA vm5jpa9hQzs4xWO+WLcfwHx5zhkbNGu7d1WBSaSMepigAPGPj/egzFjwYy3Ve6j+r9IS lBww== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i13si1202554edq.350.2020.10.14.21.52.14; Wed, 14 Oct 2020 21:52:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730494AbgJOD4o (ORCPT + 99 others); Wed, 14 Oct 2020 23:56:44 -0400 Received: from out30-43.freemail.mail.aliyun.com ([115.124.30.43]:39066 "EHLO out30-43.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727281AbgJOD4o (ORCPT ); Wed, 14 Oct 2020 23:56:44 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R121e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04423;MF=richard.weiyang@linux.alibaba.com;NM=1;PH=DS;RN=8;SR=0;TI=SMTPD_---0UC448V1_1602734199; Received: from localhost(mailfrom:richard.weiyang@linux.alibaba.com fp:SMTPD_---0UC448V1_1602734199) by smtp.aliyun-inc.com(127.0.0.1); Thu, 15 Oct 2020 11:56:40 +0800 Date: Thu, 15 Oct 2020 11:56:39 +0800 From: Wei Yang To: David Hildenbrand Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, virtualization@lists.linux-foundation.org, Andrew Morton , "Michael S . Tsirkin" , Jason Wang , Pankaj Gupta Subject: Re: [PATCH v1 01/29] virtio-mem: determine nid only once using memory_add_physaddr_to_nid() Message-ID: <20201015035639.GA86495@L-31X9LVDL-1304.local> Reply-To: Wei Yang References: <20201012125323.17509-1-david@redhat.com> <20201012125323.17509-2-david@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201012125323.17509-2-david@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 12, 2020 at 02:52:55PM +0200, David Hildenbrand wrote: >Let's determine the target nid only once in case we have none specified - >usually, we'll end up with node 0 either way. > >Cc: "Michael S. Tsirkin" >Cc: Jason Wang >Cc: Pankaj Gupta >Signed-off-by: David Hildenbrand Reviewed-by: Wei Yang >--- > drivers/virtio/virtio_mem.c | 28 +++++++++++----------------- > 1 file changed, 11 insertions(+), 17 deletions(-) > >diff --git a/drivers/virtio/virtio_mem.c b/drivers/virtio/virtio_mem.c >index ba4de598f663..a1f5bf7a571a 100644 >--- a/drivers/virtio/virtio_mem.c >+++ b/drivers/virtio/virtio_mem.c >@@ -70,7 +70,7 @@ struct virtio_mem { > > /* The device block size (for communicating with the device). */ > uint64_t device_block_size; >- /* The translated node id. NUMA_NO_NODE in case not specified. */ >+ /* The determined node id for all memory of the device. */ > int nid; > /* Physical start address of the memory region. */ > uint64_t addr; >@@ -406,10 +406,6 @@ static int virtio_mem_sb_bitmap_prepare_next_mb(struct virtio_mem *vm) > static int virtio_mem_mb_add(struct virtio_mem *vm, unsigned long mb_id) > { > const uint64_t addr = virtio_mem_mb_id_to_phys(mb_id); >- int nid = vm->nid; >- >- if (nid == NUMA_NO_NODE) >- nid = memory_add_physaddr_to_nid(addr); > > /* > * When force-unloading the driver and we still have memory added to >@@ -423,7 +419,8 @@ static int virtio_mem_mb_add(struct virtio_mem *vm, unsigned long mb_id) > } > > dev_dbg(&vm->vdev->dev, "adding memory block: %lu\n", mb_id); >- return add_memory_driver_managed(nid, addr, memory_block_size_bytes(), >+ return add_memory_driver_managed(vm->nid, addr, >+ memory_block_size_bytes(), > vm->resource_name, > MEMHP_MERGE_RESOURCE); > } >@@ -440,13 +437,9 @@ static int virtio_mem_mb_add(struct virtio_mem *vm, unsigned long mb_id) > static int virtio_mem_mb_remove(struct virtio_mem *vm, unsigned long mb_id) > { > const uint64_t addr = virtio_mem_mb_id_to_phys(mb_id); >- int nid = vm->nid; >- >- if (nid == NUMA_NO_NODE) >- nid = memory_add_physaddr_to_nid(addr); > > dev_dbg(&vm->vdev->dev, "removing memory block: %lu\n", mb_id); >- return remove_memory(nid, addr, memory_block_size_bytes()); >+ return remove_memory(vm->nid, addr, memory_block_size_bytes()); > } > > /* >@@ -461,14 +454,11 @@ static int virtio_mem_mb_offline_and_remove(struct virtio_mem *vm, > unsigned long mb_id) > { > const uint64_t addr = virtio_mem_mb_id_to_phys(mb_id); >- int nid = vm->nid; >- >- if (nid == NUMA_NO_NODE) >- nid = memory_add_physaddr_to_nid(addr); > > dev_dbg(&vm->vdev->dev, "offlining and removing memory block: %lu\n", > mb_id); >- return offline_and_remove_memory(nid, addr, memory_block_size_bytes()); >+ return offline_and_remove_memory(vm->nid, addr, >+ memory_block_size_bytes()); > } > > /* >@@ -1659,6 +1649,10 @@ static int virtio_mem_init(struct virtio_mem *vm) > virtio_cread_le(vm->vdev, struct virtio_mem_config, region_size, > &vm->region_size); > >+ /* Determine the nid for the device based on the lowest address. */ >+ if (vm->nid == NUMA_NO_NODE) >+ vm->nid = memory_add_physaddr_to_nid(vm->addr); >+ > /* > * We always hotplug memory in memory block granularity. This way, > * we have to wait for exactly one memory block to online. >@@ -1707,7 +1701,7 @@ static int virtio_mem_init(struct virtio_mem *vm) > memory_block_size_bytes()); > dev_info(&vm->vdev->dev, "subblock size: 0x%llx", > (unsigned long long)vm->subblock_size); >- if (vm->nid != NUMA_NO_NODE) >+ if (vm->nid != NUMA_NO_NODE && IS_ENABLED(CONFIG_NUMA)) > dev_info(&vm->vdev->dev, "nid: %d", vm->nid); > > return 0; >-- >2.26.2 -- Wei Yang Help you, Help me