Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp3363047imc; Wed, 13 Mar 2019 16:16:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqxffhP0m4qOQd37Oail7C15t4j5Q5aUiFkpEeDPWZke2H8EJ2yoBro21tFICOoiNFh6vdgO X-Received: by 2002:a17:902:2e03:: with SMTP id q3mr567164plb.166.1552519016790; Wed, 13 Mar 2019 16:16:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552519016; cv=none; d=google.com; s=arc-20160816; b=pf96bBgFvEQHOaUeXjVpMFklUoiycav85rkRijw403NW9xlqW7RMrC4LGC/jlrcieT JDSjtiMeCe6nQayyf2RDKY9wGTSU+fZSBUi6ZQ181VXlryLN1YfLa9rVoJlFqHAHEn6R tItDC/2aWkQTUkKma64bJOUbP7BJuapA9PeC2Bu5ifqLGjntfo1f/7iJvgKv+KTbkJuj fI14WAmMKnt+udpgrOuAAiMEICO+jQzxigZUfWZwXhSuZDJYEp9ufZVDmOUU/SJDiPti pZaTPBjbHnIJ7KA4BFVsYlq6egfSvuQ0JnI26hdSkSte4fZA5i/F+4u4WSfutN4CXdBt v5wA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=k6s7+MyaJ7lmyZgaX8+pCT5G3jU2yjbRiWoxLQGD/hc=; b=GlcAadbYonZXEMFuFH5eIrkxEH7Zr/DZYITlmRBkwDd49Flcy/nKvCM+QlYwxMqK++ ILsLPCWYwnwI67xLgilcmGh4MD2AEG8Kgn1CrwMgnUygMBbtgNilhBpMkGLkUL5R7sb1 NGTDuvLrEAGr9s+EilWoUtS6VWJs8NoW/AMIOeCvRyevyaM1fEciyEoFIwU/v66AGLUE wGuasFQWpTAkPRsQTs4Ym5Au5jNvK4DQwVTezjqY7LbZUXpS78A6oSt+I96OMEAeGf6Z xjkX6ngZB0kCy9o549amH6FIBjy7cFx7PfXAcckOd7rFi6orlcaZaTxFyghTCntw+AtS uvXQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d2si10930549pgb.137.2019.03.13.16.16.40; Wed, 13 Mar 2019 16:16:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727080AbfCMXQJ (ORCPT + 99 others); Wed, 13 Mar 2019 19:16:09 -0400 Received: from mail-ot1-f68.google.com ([209.85.210.68]:39163 "EHLO mail-ot1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726078AbfCMXQI (ORCPT ); Wed, 13 Mar 2019 19:16:08 -0400 Received: by mail-ot1-f68.google.com with SMTP id e15so3412373otk.6; Wed, 13 Mar 2019 16:16:07 -0700 (PDT) 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=k6s7+MyaJ7lmyZgaX8+pCT5G3jU2yjbRiWoxLQGD/hc=; b=cQpZw81qMrPL17JeZRgRyXxkm+RJ+hGDXPwS+pDeOpG+6w91UQKyDNRi0AHGna/9yb aiA5sIzBT+/uLlcHvMnpRUDI3j38sexelQ3I7aMntkfwT5GwPHxIjyrb/b0CxDNu5hHJ KAK4t8Dmnl4TBxDTY/b7rsp7zI8OrFstnDNxXgBTlqrFq1eGgJ/np/GDqRXpIRAx8D4z 1LcR/h7a7mn7xweqscxPhBYTEuA5Z0YJBrAJs1f81jvpPC5Nmx4QGI/FToFDtgw1VoTP NtremO4oZMei4ufIctJb9wkfShVPICJTCvGiE5Ne9riLDsZ45dx9w9tV8g1BLyenKbc+ ROmg== X-Gm-Message-State: APjAAAVzUEn8te8N9rr8UG4vFp4hc5t07Et0+PHTLKMJL0/hK8W3/w2D xORRnH6Wvnam23SLeAGFVndgt2cAgs8BpVf+l2s= X-Received: by 2002:a9d:7a58:: with SMTP id z24mr1122847otm.244.1552518967328; Wed, 13 Mar 2019 16:16:07 -0700 (PDT) MIME-Version: 1.0 References: <20190311205606.11228-1-keith.busch@intel.com> <20190311205606.11228-6-keith.busch@intel.com> In-Reply-To: <20190311205606.11228-6-keith.busch@intel.com> From: "Rafael J. Wysocki" Date: Thu, 14 Mar 2019 00:15:56 +0100 Message-ID: Subject: Re: [PATCHv8 05/10] node: Add heterogenous memory access attributes To: Keith Busch Cc: Linux Kernel Mailing List , ACPI Devel Maling List , Linux Memory Management List , Linux API , Greg Kroah-Hartman , Rafael Wysocki , Dave Hansen , Dan Williams , Jonathan Cameron , Brice Goglin Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 11, 2019 at 9:55 PM Keith Busch wrote: > > Heterogeneous memory systems provide memory nodes with different latency > and bandwidth performance attributes. Provide a new kernel interface > for subsystems to register the attributes under the memory target > node's initiator access class. If the system provides this information, > applications may query these attributes when deciding which node to > request memory. > > The following example shows the new sysfs hierarchy for a node exporting > performance attributes: > > # tree -P "read*|write*"/sys/devices/system/node/nodeY/accessZ/initiators/ > /sys/devices/system/node/nodeY/accessZ/initiators/ > |-- read_bandwidth > |-- read_latency > |-- write_bandwidth > `-- write_latency > > The bandwidth is exported as MB/s and latency is reported in > nanoseconds. The values are taken from the platform as reported by the > manufacturer. > > Memory accesses from an initiator node that is not one of the memory's > access "Z" initiator nodes linked in the same directory may observe > different performance than reported here. When a subsystem makes use > of this interface, initiators of a different access number may not have > the same performance relative to initiators in other access numbers, or > omitted from the any access class' initiators. > > Descriptions for memory access initiator performance access attributes > are added to sysfs stable documentation. > > Acked-by: Jonathan Cameron > Tested-by: Jonathan Cameron > Signed-off-by: Keith Busch Reviewed-by: Rafael J. Wysocki > --- > Documentation/ABI/stable/sysfs-devices-node | 28 ++++++++++++++ > drivers/base/Kconfig | 8 ++++ > drivers/base/node.c | 59 +++++++++++++++++++++++++++++ > include/linux/node.h | 26 +++++++++++++ > 4 files changed, 121 insertions(+) > > diff --git a/Documentation/ABI/stable/sysfs-devices-node b/Documentation/ABI/stable/sysfs-devices-node > index 433bcc04e542..735a40a3f9b2 100644 > --- a/Documentation/ABI/stable/sysfs-devices-node > +++ b/Documentation/ABI/stable/sysfs-devices-node > @@ -114,3 +114,31 @@ Contact: Keith Busch > Description: > The directory containing symlinks to memory targets that > this initiator node has class "Y" access. > + > +What: /sys/devices/system/node/nodeX/accessY/initiators/read_bandwidth > +Date: December 2018 > +Contact: Keith Busch > +Description: > + This node's read bandwidth in MB/s when accessed from > + nodes found in this access class's linked initiators. > + > +What: /sys/devices/system/node/nodeX/accessY/initiators/read_latency > +Date: December 2018 > +Contact: Keith Busch > +Description: > + This node's read latency in nanoseconds when accessed > + from nodes found in this access class's linked initiators. > + > +What: /sys/devices/system/node/nodeX/accessY/initiators/write_bandwidth > +Date: December 2018 > +Contact: Keith Busch > +Description: > + This node's write bandwidth in MB/s when accessed from > + found in this access class's linked initiators. > + > +What: /sys/devices/system/node/nodeX/accessY/initiators/write_latency > +Date: December 2018 > +Contact: Keith Busch > +Description: > + This node's write latency in nanoseconds when access > + from nodes found in this class's linked initiators. > diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig > index 059700ea3521..a7438a58c250 100644 > --- a/drivers/base/Kconfig > +++ b/drivers/base/Kconfig > @@ -149,6 +149,14 @@ config DEBUG_TEST_DRIVER_REMOVE > unusable. You should say N here unless you are explicitly looking to > test this functionality. > > +config HMEM_REPORTING > + bool > + default n > + depends on NUMA > + help > + Enable reporting for heterogenous memory access attributes under > + their non-uniform memory nodes. > + > source "drivers/base/test/Kconfig" > > config SYS_HYPERVISOR > diff --git a/drivers/base/node.c b/drivers/base/node.c > index 6f4097680580..2de546a040a5 100644 > --- a/drivers/base/node.c > +++ b/drivers/base/node.c > @@ -71,6 +71,9 @@ struct node_access_nodes { > struct device dev; > struct list_head list_node; > unsigned access; > +#ifdef CONFIG_HMEM_REPORTING > + struct node_hmem_attrs hmem_attrs; > +#endif > }; > #define to_access_nodes(dev) container_of(dev, struct node_access_nodes, dev) > > @@ -148,6 +151,62 @@ static struct node_access_nodes *node_init_node_access(struct node *node, > return NULL; > } > > +#ifdef CONFIG_HMEM_REPORTING > +#define ACCESS_ATTR(name) \ > +static ssize_t name##_show(struct device *dev, \ > + struct device_attribute *attr, \ > + char *buf) \ > +{ \ > + return sprintf(buf, "%u\n", to_access_nodes(dev)->hmem_attrs.name); \ > +} \ > +static DEVICE_ATTR_RO(name); > + > +ACCESS_ATTR(read_bandwidth) > +ACCESS_ATTR(read_latency) > +ACCESS_ATTR(write_bandwidth) > +ACCESS_ATTR(write_latency) > + > +static struct attribute *access_attrs[] = { > + &dev_attr_read_bandwidth.attr, > + &dev_attr_read_latency.attr, > + &dev_attr_write_bandwidth.attr, > + &dev_attr_write_latency.attr, > + NULL, > +}; > + > +/** > + * node_set_perf_attrs - Set the performance values for given access class > + * @nid: Node identifier to be set > + * @hmem_attrs: Heterogeneous memory performance attributes > + * @access: The access class the for the given attributes > + */ > +void node_set_perf_attrs(unsigned int nid, struct node_hmem_attrs *hmem_attrs, > + unsigned access) > +{ > + struct node_access_nodes *c; > + struct node *node; > + int i; > + > + if (WARN_ON_ONCE(!node_online(nid))) > + return; > + > + node = node_devices[nid]; > + c = node_init_node_access(node, access); > + if (!c) > + return; > + > + c->hmem_attrs = *hmem_attrs; > + for (i = 0; access_attrs[i] != NULL; i++) { > + if (sysfs_add_file_to_group(&c->dev.kobj, access_attrs[i], > + "initiators")) { > + pr_info("failed to add performance attribute to node %d\n", > + nid); > + break; > + } > + } > +} > +#endif > + > #define K(x) ((x) << (PAGE_SHIFT - 10)) > static ssize_t node_read_meminfo(struct device *dev, > struct device_attribute *attr, char *buf) > diff --git a/include/linux/node.h b/include/linux/node.h > index bb288817ed33..4139d728f8b3 100644 > --- a/include/linux/node.h > +++ b/include/linux/node.h > @@ -20,6 +20,32 @@ > #include > #include > > +/** > + * struct node_hmem_attrs - heterogeneous memory performance attributes > + * > + * @read_bandwidth: Read bandwidth in MB/s > + * @write_bandwidth: Write bandwidth in MB/s > + * @read_latency: Read latency in nanoseconds > + * @write_latency: Write latency in nanoseconds > + */ > +struct node_hmem_attrs { > + unsigned int read_bandwidth; > + unsigned int write_bandwidth; > + unsigned int read_latency; > + unsigned int write_latency; > +}; > + > +#ifdef CONFIG_HMEM_REPORTING > +void node_set_perf_attrs(unsigned int nid, struct node_hmem_attrs *hmem_attrs, > + unsigned access); > +#else > +static inline void node_set_perf_attrs(unsigned int nid, > + struct node_hmem_attrs *hmem_attrs, > + unsigned access) > +{ > +} > +#endif > + > struct node { > struct device dev; > struct list_head access_list; > -- > 2.14.4 >