From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3204DC433E7 for ; Thu, 15 Oct 2020 19:26:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C6CA1206B2 for ; Thu, 15 Oct 2020 19:26:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ItWEqgS7" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391525AbgJOT05 (ORCPT ); Thu, 15 Oct 2020 15:26:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391516AbgJOT05 (ORCPT ); Thu, 15 Oct 2020 15:26:57 -0400 Received: from mail-io1-xd43.google.com (mail-io1-xd43.google.com [IPv6:2607:f8b0:4864:20::d43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DEEDBC061755 for ; Thu, 15 Oct 2020 12:26:56 -0700 (PDT) Received: by mail-io1-xd43.google.com with SMTP id u19so235301ion.3 for ; Thu, 15 Oct 2020 12:26:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=0dW1tg7L5BntD7reoiX2N8eTRkAHKZdUfapCZZ+Vs1s=; b=ItWEqgS7kvOBWeDbXhkzGD4l2aEEChwnpVr6yeLSzC0/z3waEHc5tlrO43e1m665EZ i/hT/raaQQ+AgteFThMAcIzzgcKaOxBJP7LnVCsqs2psdy0ZKRNn8DMHNNcG3KUMvsXS TaFZDhPxxAG3w2CFiOKTcYOLYa4aL+hfqGqhHLSozymYszOU/sxrlfaCQQSzJZJ+mn0o +LFt5tWt7IQc3Ofto4KGqStUyBd0o1Gk4dHVtMQ7K1gbmxoBAZpZZbBNub/b2xgwK6Bj nd8olALXtauuU5srFc/dx4ipv8ExVDHQgChXs2K1sHW/l08DdKgkLjUQ3BTVKtLo+6o8 0k/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=0dW1tg7L5BntD7reoiX2N8eTRkAHKZdUfapCZZ+Vs1s=; b=BNuWLBXP+61XCrurevLl8fbCc+UKuoUVoIAA1/VVUH68hCWoPBpRFhoTv7/jztfAXM esm4R12ZScdeqHW5Y/JV+ifADKiT43H6Xj0ul+TIvgBhxkxofV9mXkEBiO79zrILS0ln ej2bKT3LG9L4soZG0l0qFe7ftGGQT0ivrLw8EBxtHpGizzp37MZNDxMalkp7KRMDxXoH hrHD8aARGUlFwZJL/1/JAJnaDCbFJHzVtt7jADmBT0QTmZzW88gHq6cS2YaewAXTWFQp fK8SkB1SGDic06v9T1PfsnRpDeCrgMbQdN+x5VpyepNqpo7mz7fMq5RlPh2HSF+Hzrnp /J4A== X-Gm-Message-State: AOAM533eIEFO9enJSnKKDgSx07zPAhJ8cNZgA1zgIRr2cT+v70yUKGdy xKqdbJMlSwSdDcNBxxfEb0Vrnu+RPd9GSScY8R4= X-Google-Smtp-Source: ABdhPJxcOWjUA0HcRSZpELeNr/fHwfLQRa14qubApbgCQzZpAze5mJVWqHn5bUOyAaajeggeeJc2zPu50+57luDUa+M= X-Received: by 2002:a02:8b:: with SMTP id 133mr4663255jaa.46.1602790016267; Thu, 15 Oct 2020 12:26:56 -0700 (PDT) MIME-Version: 1.0 References: <20201012125323.17509-1-david@redhat.com> <20201012125323.17509-2-david@redhat.com> In-Reply-To: <20201012125323.17509-2-david@redhat.com> From: Pankaj Gupta Date: Thu, 15 Oct 2020 21:26:45 +0200 Message-ID: Subject: Re: [PATCH v1 01/29] virtio-mem: determine nid only once using memory_add_physaddr_to_nid() To: David Hildenbrand Cc: LKML , Linux MM , virtualization@lists.linux-foundation.org, Andrew Morton , "Michael S . Tsirkin" , Jason Wang Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > 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 > --- > 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; Reviewed-by: Pankaj Gupta From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8CF16C433DF for ; Thu, 15 Oct 2020 19:26:59 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0BB6E206DC for ; Thu, 15 Oct 2020 19:26:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ItWEqgS7" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0BB6E206DC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 462D26B0068; Thu, 15 Oct 2020 15:26:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3EDDF6B006E; Thu, 15 Oct 2020 15:26:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2B3B46B0070; Thu, 15 Oct 2020 15:26:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0197.hostedemail.com [216.40.44.197]) by kanga.kvack.org (Postfix) with ESMTP id F091A6B0068 for ; Thu, 15 Oct 2020 15:26:57 -0400 (EDT) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 71FFD1EE6 for ; Thu, 15 Oct 2020 19:26:57 +0000 (UTC) X-FDA: 77375142474.05.stage24_5106f7227217 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin05.hostedemail.com (Postfix) with ESMTP id 5553F18014D3F for ; Thu, 15 Oct 2020 19:26:57 +0000 (UTC) X-HE-Tag: stage24_5106f7227217 X-Filterd-Recvd-Size: 7245 Received: from mail-io1-f67.google.com (mail-io1-f67.google.com [209.85.166.67]) by imf09.hostedemail.com (Postfix) with ESMTP for ; Thu, 15 Oct 2020 19:26:56 +0000 (UTC) Received: by mail-io1-f67.google.com with SMTP id d20so147178iop.10 for ; Thu, 15 Oct 2020 12:26:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=0dW1tg7L5BntD7reoiX2N8eTRkAHKZdUfapCZZ+Vs1s=; b=ItWEqgS7kvOBWeDbXhkzGD4l2aEEChwnpVr6yeLSzC0/z3waEHc5tlrO43e1m665EZ i/hT/raaQQ+AgteFThMAcIzzgcKaOxBJP7LnVCsqs2psdy0ZKRNn8DMHNNcG3KUMvsXS TaFZDhPxxAG3w2CFiOKTcYOLYa4aL+hfqGqhHLSozymYszOU/sxrlfaCQQSzJZJ+mn0o +LFt5tWt7IQc3Ofto4KGqStUyBd0o1Gk4dHVtMQ7K1gbmxoBAZpZZbBNub/b2xgwK6Bj nd8olALXtauuU5srFc/dx4ipv8ExVDHQgChXs2K1sHW/l08DdKgkLjUQ3BTVKtLo+6o8 0k/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=0dW1tg7L5BntD7reoiX2N8eTRkAHKZdUfapCZZ+Vs1s=; b=iW0PLloSj8thdTDq5Za2Yz16Hrc5VO7uNw0UVDG2yar1akcbIiOxQKjmNVpA+H1Fn2 NJDf3hd1eDp/T8vOYqgCsjonZldDpuLZEApfsdq99nFyJQGiAnle3NydnaTOKI05SgEz LEzmFoBsSk7fBaP526Q+FhZTgm1bBWFxOzdeFoNxHUoXqtzO8WWKtZqNM3Q4v7a7/V9G SBB8UU+fn7xPS0qlghqGG8qwP8dsXKiv+zHqiCRqtEwyRLvC9TtgGYlhxtE1J3bfHdy6 YYu5wbJ1uEGq6B5fy3m1hSjDdhunZv1zw/Iov1BFj1pzQrsFU5gnVeYxezC10wCVqCUH m/eg== X-Gm-Message-State: AOAM532es9L5qEZyLwbRJOdhkFjDcDo2DFUgLP9k5WFq6+i9rEXQaLtB RmsULfCnVkdjzJ0UWbEdu/2odY/hP9uyxTjyj15sErQ1TfM8nw== X-Google-Smtp-Source: ABdhPJxcOWjUA0HcRSZpELeNr/fHwfLQRa14qubApbgCQzZpAze5mJVWqHn5bUOyAaajeggeeJc2zPu50+57luDUa+M= X-Received: by 2002:a02:8b:: with SMTP id 133mr4663255jaa.46.1602790016267; Thu, 15 Oct 2020 12:26:56 -0700 (PDT) MIME-Version: 1.0 References: <20201012125323.17509-1-david@redhat.com> <20201012125323.17509-2-david@redhat.com> In-Reply-To: <20201012125323.17509-2-david@redhat.com> From: Pankaj Gupta Date: Thu, 15 Oct 2020 21:26:45 +0200 Message-ID: Subject: Re: [PATCH v1 01/29] virtio-mem: determine nid only once using memory_add_physaddr_to_nid() To: David Hildenbrand Cc: LKML , Linux MM , virtualization@lists.linux-foundation.org, Andrew Morton , "Michael S . Tsirkin" , Jason Wang Content-Type: text/plain; charset="UTF-8" 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: > 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 > --- > 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; Reviewed-by: Pankaj Gupta