Path: csiph.com!aioe.org!bofh.it!news.nic.it!robomod From: Dan Williams Newsgroups: linux.kernel Subject: Re: [PATCH 3/3] libnvdimm: Add sysfs numa_node to NVDIMM devices Date: Wed, 03 Jun 2015 03:10:02 +0200 Message-ID: References: X-Original-To: Toshi Kani X-Google-Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=t27XGENP3leOAxvxuv6TYFpWLd06AdYmuY481rKZ4gk=; b=OXSMECIbS2fs7vWJQBVECjzDbC0/Fq1LtlpWYw+GDbNz/9aRpxpvOrc3Rk1jBl48Si tPcXdOpSjSkUER6Uh+qv56wh5v03QRIuMCb3iAij3ZDeSVD8Knl1HrLF295FiaXhyOQF WFyhe935nUTvHXuv7XnOb3ws07/SRKgiB2NlFBoYBdP9vf/WUvaCUWbm9+RJZqFpFEZS ne9zFj1t/OsJebT54vc2N7Ybqcl9aglYekGl7XU+LE6xa3XpVGszJJffL/Eccp6ytynB 4zUORtNVTaSGj43KTOc6+56AS+zrrTviiY+UdUsOdsZWL0ZhchOlKMcnHOzfQAVVGR7J 4gQA== X-Gm-Message-State: ALoCoQm8IeZDLRRkFt1tTDuEbXciO4GNXVtrzMN6tjYpeRDGO9ryXgbdVRoNQS9eKaL07A/WiSHS MIME-Version: 1.0 X-Received: by 10.194.62.132 with SMTP id y4mr56254303wjr.91.1433293261931; Tue, 02 Jun 2015 18:01:01 -0700 (PDT) Content-Type: text/plain; charset=UTF-8 Sender: robomod@news.nic.it List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Approved: robomod@news.nic.it Lines: 100 Organization: linux.* mail to news gateway X-Original-Cc: "Rafael J. Wysocki" , Linux ACPI , "linux-nvdimm@lists.01.org" , "linux-kernel@vger.kernel.org" X-Original-Date: Tue, 2 Jun 2015 18:01:01 -0700 X-Original-Message-ID: X-Original-References: <1433291212-23367-1-git-send-email-toshi.kani@hp.com> <1433291212-23367-4-git-send-email-toshi.kani@hp.com> X-Original-Sender: linux-kernel-owner@vger.kernel.org Xref: aioe.org linux.kernel:1157009 On Tue, Jun 2, 2015 at 5:26 PM, Toshi Kani wrote: > Since NVDIMMs are installed on memory slots, they expose the NUMA > topology of a platform. > > This patch adds support of sysfs 'numa_node' to the NVDIMM devices > under /sys/bus/nd/devices, such as regionN, namespaceN.0, and bttN. > When bttN is not set up, its numa_node returns -1 (NUMA_NO_NODE). > nmemN/numa_node always returns -1 for now since this device is for > dimm-ioctl message interface and has little use of NUMA. It can be > enhanced later to set a valid value if necessary. > > Here is an example of numa_node values on a 2-socket system with > a single NVDIMM range on each socket. > /sys/bus/nd/devices > |-- btt0/numa_node:-1 > |-- btt1/numa_node:0 > |-- namespace0.0/numa_node:0 > |-- namespace1.0/numa_node:1 > |-- nmem0/numa_node:-1 > |-- nmem1/numa_node:-1 > |-- region0/numa_node:0 > |-- region1/numa_node:1 > > With this change, numactl(8) accepts 'block:' and 'file:' paths of > pmem and btt devices as shown in the examples below. > numactl --preferred block:pmem0 --show > numactl --preferred file:/dev/pmem0s --show > > Signed-off-by: Toshi Kani > --- > drivers/acpi/nfit.c | 2 ++ > drivers/nvdimm/btt.c | 2 ++ > drivers/nvdimm/bus.c | 12 ++++++++++++ > drivers/nvdimm/nd.h | 1 + > drivers/nvdimm/region.c | 1 + > drivers/nvdimm/region_devs.c | 1 + > include/linux/libnvdimm.h | 1 + > 7 files changed, 20 insertions(+) > > diff --git a/drivers/acpi/nfit.c b/drivers/acpi/nfit.c > index 5731e4a..a255f3a 100644 > --- a/drivers/acpi/nfit.c > +++ b/drivers/acpi/nfit.c > @@ -1255,6 +1255,8 @@ static int acpi_nfit_register_region(struct acpi_nfit_desc *acpi_desc, > ndr_desc->res = &res; > ndr_desc->provider_data = nfit_spa; > ndr_desc->attr_groups = acpi_nfit_region_attribute_groups; > + ndr_desc->numa_node = acpi_map_pxm_to_node(spa->proximity_domain); > + > list_for_each_entry(nfit_memdev, &acpi_desc->memdevs, list) { > struct acpi_nfit_memory_map *memdev = nfit_memdev->memdev; > struct nd_mapping *nd_mapping; > diff --git a/drivers/nvdimm/btt.c b/drivers/nvdimm/btt.c > index 2d7ce9e..3b3e115 100644 > --- a/drivers/nvdimm/btt.c > +++ b/drivers/nvdimm/btt.c > @@ -1369,6 +1369,8 @@ static int nd_btt_probe(struct device *dev) > rc = -ENOMEM; > goto err_btt; > } > + > + set_dev_node(dev, nd_region->numa_node); > dev_set_drvdata(dev, btt); > > return 0; > diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c > index d8a1794..5c34e68 100644 > --- a/drivers/nvdimm/bus.c > +++ b/drivers/nvdimm/bus.c > @@ -339,9 +339,21 @@ static ssize_t devtype_show(struct device *dev, struct device_attribute *attr, > } > static DEVICE_ATTR_RO(devtype); > > +#ifdef CONFIG_NUMA > +static ssize_t numa_node_show(struct device *dev, struct device_attribute *attr, > + char *buf) > +{ > + return sprintf(buf, "%d\n", dev->numa_node); > +} > +DEVICE_ATTR_RO(numa_node); > +#endif > + > static struct attribute *nd_device_attributes[] = { > &dev_attr_modalias.attr, > &dev_attr_devtype.attr, > +#ifdef CONFIG_NUMA > + &dev_attr_numa_node.attr, > +#endif > NULL, > }; I'd prefer you define is_visible() in the nd_device_attribute_group and gate showing this attribute on IS_ENABLED(CONFIG_NUMA) rather than including these ifdef guards. The ifdef guards aren't necessary in the CONFIG_NUMA=n case. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/