Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp2526141rwi; Fri, 21 Oct 2022 05:03:28 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6+IqKvZoxsvOVLfPQHM9qk4K9KhO1QcBfYwoj1NvlJacf+o9wLQOUdCf8dK5vjn3tYHccF X-Received: by 2002:a05:6402:847:b0:45b:d50c:b9aa with SMTP id b7-20020a056402084700b0045bd50cb9aamr16771400edz.289.1666353808513; Fri, 21 Oct 2022 05:03:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666353808; cv=none; d=google.com; s=arc-20160816; b=SJbsjVvv0F4RjriGu59M9DmCmWE/wPqs9Z67YULMNKjsPrg3B1FdlYOC3g6fpFyLAN Ncv2BthP6m7FknVNJv9A+fW+XoriQ4AaFgIV8OQ2mY1E/fgmBSylk40kCQnJFTmlO7ms DxIO5t/tDbOgwJWu/5p0MoaftXFxaf7zz+JgY/nDekgpOJbQY5UeYG0pZpiNG4wT8iMQ vxcxjr9PwhR3DhqoIO34c9xDIJ1oqMU7P7RsVRXI/bL5j7iSmoER5s0mjP+8/Y5mBW7U K0iOgCsB9SP8tNruXhqcltokbpcdN4TWar8Ij1agykb3/qNElFo4bhyHuqZfhnSKgFrw 3a4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=5PwdDXVu5A11cVv6wJuG3gZctd4QRKpsxJeBckZ3fGo=; b=ZslctJHdnzPvVM6DHATKxd8hE1QcAC+jMsivfqvoFO07ipwuqVDc4y0hzYyGdvhA69 AFeIiMDCbXnR/pT9CNa4NCCYk2gr1Aym/f058Kjt/6hyf5ezspcN6Cn3Er61ZgNfq86d x4ZmbphNu5VyGBbMjgpv7S+XDca3fW8CWh3ZC9168XoBuiKZ4ORZnOsj1Waln3hQPq2z 9QrV+AfHWVmcgH9GoOwDGJgmFzNkQgNaGDqLCRKFTSJ7pKFkagklXO0QNJJBjJcTI+fk Zy+6i6loVZPiKrwYd0zSclsduOIf0Y5R5j8hwB9ZTQqeco6J62nbKShXiwZBsHc+DfDx O7JQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=DE2jFHwT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c20-20020a05640227d400b0045d27c0ba90si20773985ede.577.2022.10.21.05.02.57; Fri, 21 Oct 2022 05:03:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=DE2jFHwT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230254AbiJULmo (ORCPT + 99 others); Fri, 21 Oct 2022 07:42:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229787AbiJULmm (ORCPT ); Fri, 21 Oct 2022 07:42:42 -0400 Received: from mail-ot1-x332.google.com (mail-ot1-x332.google.com [IPv6:2607:f8b0:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D45892625CF for ; Fri, 21 Oct 2022 04:42:41 -0700 (PDT) Received: by mail-ot1-x332.google.com with SMTP id f4-20020a9d0384000000b0066208c73094so1681517otf.0 for ; Fri, 21 Oct 2022 04:42:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=5PwdDXVu5A11cVv6wJuG3gZctd4QRKpsxJeBckZ3fGo=; b=DE2jFHwTCLaJZKNXRFpcGV7F9oYrDcTgin68ddiLvmSVj7qsqTyMUi4RIbwW5Oe+if 7Rr4jMKrJeV2vk7KsQXL0yyAopaHkuLwC0Km67MNC4pWxDq2BhmEKwxsCS5Hhbya01fP wzW8WS0Nj/oIKB+NnQFEPENeAym4Atjquli+3OdFHqEUCjxZm38DlfwzQqCnCt4hNK4a Jis9X5xOEn2GVKQ+dNTjBD7eQhEAu/nDy+bggd6+paAMX7wGt+FrV0Nl7c0mqvRxd8HT rInJCusJHTq0E9lO5WWRQBQlyIXFTCn09HTBcEQbXehVbXFSmkWg+dWi9WjXpgN7YJwz CnyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=5PwdDXVu5A11cVv6wJuG3gZctd4QRKpsxJeBckZ3fGo=; b=gOABG8oH5uUyAb2A0DGdlcOcFif00Z0QBKhlKBa+5tlXI0vzqQ42YnxLqWVknJXBWh bg0o0+iaR4Gva61wPVpRm5FMHoTPsAMXidk3hmQqJVTYTbWIAy+KHue5rWdc2hXKvrTS 6N9ETh+U7Wviz3RlFMtCJRwoKfYoqK+k5Hh9MVqqbb1ErSOuxXpm7litv/WGCHu4jAO8 qUiDsHSwwkxz3eVfdg9iy4kcGiN5r1eHOm9X+vw0NnFNDehqqrvLfJOD/+P2udR2NwUT 6xzViWat1/YZAd+cu4PyMNNmwzZA82FJ2LalhsWWi7IGWFQFqxegbUwz4sbQ5Z9+ipg3 tMwg== X-Gm-Message-State: ACrzQf0KQbcy4mg71mSc8LWJWQJZ/JwHmkxhh1OoQkutUGBaYfvvZkSv JkmSmCV1+jEfToy3w6qCB0gk6Y53DZqugnb1WMcsDhJcHAo= X-Received: by 2002:a05:6830:4115:b0:661:a2c4:3bcd with SMTP id w21-20020a056830411500b00661a2c43bcdmr10255936ott.368.1666352561091; Fri, 21 Oct 2022 04:42:41 -0700 (PDT) MIME-Version: 1.0 References: <20221017171118.1588820-1-sammler@google.com> In-Reply-To: <20221017171118.1588820-1-sammler@google.com> From: Pankaj Gupta Date: Fri, 21 Oct 2022 13:42:28 +0200 Message-ID: Subject: Re: [PATCH v1] virtio_pmem: populate numa information To: Michael Sammler Cc: Dan Williams , Vishal Verma , Dave Jiang , Ira Weiny , Pasha Tatashin , nvdimm@lists.linux.dev, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > Compute the numa information for a virtio_pmem device from the memory > range of the device. Previously, the target_node was always 0 since > the ndr_desc.target_node field was never explicitly set. The code for > computing the numa node is taken from cxl_pmem_region_probe in > drivers/cxl/pmem.c. > > Signed-off-by: Michael Sammler > --- > drivers/nvdimm/virtio_pmem.c | 11 +++++++++-- > 1 file changed, 9 insertions(+), 2 deletions(-) > > diff --git a/drivers/nvdimm/virtio_pmem.c b/drivers/nvdimm/virtio_pmem.c > index 20da455d2ef6..a92eb172f0e7 100644 > --- a/drivers/nvdimm/virtio_pmem.c > +++ b/drivers/nvdimm/virtio_pmem.c > @@ -32,7 +32,6 @@ static int init_vq(struct virtio_pmem *vpmem) > static int virtio_pmem_probe(struct virtio_device *vdev) > { > struct nd_region_desc ndr_desc = {}; > - int nid = dev_to_node(&vdev->dev); > struct nd_region *nd_region; > struct virtio_pmem *vpmem; > struct resource res; > @@ -79,7 +78,15 @@ static int virtio_pmem_probe(struct virtio_device *vdev) > dev_set_drvdata(&vdev->dev, vpmem->nvdimm_bus); > > ndr_desc.res = &res; > - ndr_desc.numa_node = nid; > + > + ndr_desc.numa_node = memory_add_physaddr_to_nid(res.start); > + ndr_desc.target_node = phys_to_target_node(res.start); > + if (ndr_desc.target_node == NUMA_NO_NODE) { > + ndr_desc.target_node = ndr_desc.numa_node; > + dev_dbg(&vdev->dev, "changing target node from %d to %d", > + NUMA_NO_NODE, ndr_desc.target_node); > + } As this memory later gets hotplugged using "devm_memremap_pages". I don't see if 'target_node' is used for fsdax case? It seems to me "target_node" is used mainly for volatile range above persistent memory ( e.g kmem driver?). Thanks, Pankaj > + > ndr_desc.flush = async_pmem_flush; > ndr_desc.provider_data = vdev; > set_bit(ND_REGION_PAGEMAP, &ndr_desc.flags); > --