linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dave Jiang <dave.jiang@intel.com>
To: linux-cxl@vger.kernel.org, linux-acpi@vger.kernel.org,
	linux-kernel@vger.kernel.org
Cc: gregkh@linuxfoundation.org, rafael@kernel.org, dakr@kernel.org,
	dave@stgolabs.net, jonathan.cameron@huawei.com,
	alison.schofield@intel.com, vishal.l.verma@intel.com,
	ira.weiny@intel.com, dan.j.williams@intel.com,
	marc.herbert@linux.intel.com, akpm@linux-foundation.org,
	david@redhat.com
Subject: [PATCH 2/4] drivers/base/node: Add a helper function node_update_perf_attrs()
Date: Thu, 14 Aug 2025 10:16:48 -0700	[thread overview]
Message-ID: <20250814171650.3002930-3-dave.jiang@intel.com> (raw)
In-Reply-To: <20250814171650.3002930-1-dave.jiang@intel.com>

Add helper function node_update_perf_attrs() to allow update of node access
coordinates computed by an external agent such as CXL. The helper allows
updating of coordinates after the attribute being created by HMAT.

Signed-off-by: Dave Jiang <dave.jiang@intel.com>
---
 drivers/base/node.c  | 39 +++++++++++++++++++++++++++++++++++++++
 include/linux/node.h |  8 ++++++++
 2 files changed, 47 insertions(+)

diff --git a/drivers/base/node.c b/drivers/base/node.c
index 3399594136b2..cf395da18c9b 100644
--- a/drivers/base/node.c
+++ b/drivers/base/node.c
@@ -248,6 +248,45 @@ void node_set_perf_attrs(unsigned int nid, struct access_coordinate *coord,
 }
 EXPORT_SYMBOL_GPL(node_set_perf_attrs);
 
+/**
+ * node_update_perf_attrs - Update the performance values for given access class
+ * @nid: Node identifier to be updated
+ * @coord: Heterogeneous memory performance coordinates
+ * @access: The access class the for the given attributes
+ */
+void node_update_perf_attrs(unsigned int nid, struct access_coordinate *coord,
+			    enum access_coordinate_class access)
+{
+	struct node_access_nodes *access_node;
+	struct node *node;
+	int i;
+
+	if (WARN_ON_ONCE(!node_online(nid)))
+		return;
+
+	node = node_devices[nid];
+	list_for_each_entry(access_node, &node->access_list, list_node) {
+		if (access_node->access != access)
+			continue;
+
+		access_node->coord = *coord;
+		for (i = 0; access_attrs[i]; i++) {
+			sysfs_notify(&access_node->dev.kobj,
+				     NULL, access_attrs[i]->name);
+		}
+		break;
+	}
+
+	/* When setting CPU access coordinates, update mempolicy */
+	if (access == ACCESS_COORDINATE_CPU) {
+		if (mempolicy_set_node_perf(nid, coord)) {
+			pr_info("failed to set mempolicy attrs for node %d\n",
+				nid);
+		}
+	}
+}
+EXPORT_SYMBOL_GPL(node_update_perf_attrs);
+
 /**
  * struct node_cache_info - Internal tracking for memory node caches
  * @dev:	Device represeting the cache level
diff --git a/include/linux/node.h b/include/linux/node.h
index 2c7529335b21..866e3323f1fd 100644
--- a/include/linux/node.h
+++ b/include/linux/node.h
@@ -85,6 +85,8 @@ struct node_cache_attrs {
 void node_add_cache(unsigned int nid, struct node_cache_attrs *cache_attrs);
 void node_set_perf_attrs(unsigned int nid, struct access_coordinate *coord,
 			 enum access_coordinate_class access);
+void node_update_perf_attrs(unsigned int nid, struct access_coordinate *coord,
+			    enum access_coordinate_class access);
 #else
 static inline void node_add_cache(unsigned int nid,
 				  struct node_cache_attrs *cache_attrs)
@@ -96,6 +98,12 @@ static inline void node_set_perf_attrs(unsigned int nid,
 				       enum access_coordinate_class access)
 {
 }
+
+static inline void node_update_perf_attrs(unsigned int nid,
+					  struct access_coordinate *coord,
+					  enum access_coordinate_class access)
+{
+}
 #endif
 
 struct node {
-- 
2.50.1


  parent reply	other threads:[~2025-08-14 17:17 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-14 17:16 [PATCH 0/4] cxl, acpi/hmat, node: Update CXL access coordinates to node directly Dave Jiang
2025-08-14 17:16 ` [PATCH 1/4] mm/memory_hotplug: Update comment for hotplug memory callback priorities Dave Jiang
2025-08-16  7:29   ` David Hildenbrand
2025-08-18 14:08     ` Dave Jiang
2025-08-19  3:14       ` Marc Herbert
2025-08-19  9:18         ` David Hildenbrand
2025-08-19 15:39           ` Dave Jiang
2025-08-19 19:08             ` David Hildenbrand
2025-08-14 17:16 ` Dave Jiang [this message]
2025-08-15 13:28   ` [PATCH 2/4] drivers/base/node: Add a helper function node_update_perf_attrs() Jonathan Cameron
2025-08-18  9:49   ` David Hildenbrand
2025-08-19 17:00     ` Dave Jiang
2025-08-14 17:16 ` [PATCH 3/4] cxl, acpi/hmat: Update CXL access coordinates directly instead of through HMAT Dave Jiang
2025-08-14 22:33   ` dan.j.williams
2025-08-14 22:59     ` Dave Jiang
2025-08-14 23:09     ` Marc Herbert
2025-08-15 13:31   ` Jonathan Cameron
2025-08-15 15:35     ` Dave Jiang
2025-08-15 15:56       ` Jonathan Cameron
2025-08-14 17:16 ` [PATCH 4/4] acpi/hmat: Remove now unused hmat_update_target_coordinates() Dave Jiang
2025-08-15 13:31   ` Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250814171650.3002930-3-dave.jiang@intel.com \
    --to=dave.jiang@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=alison.schofield@intel.com \
    --cc=dakr@kernel.org \
    --cc=dan.j.williams@intel.com \
    --cc=dave@stgolabs.net \
    --cc=david@redhat.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=ira.weiny@intel.com \
    --cc=jonathan.cameron@huawei.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-cxl@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marc.herbert@linux.intel.com \
    --cc=rafael@kernel.org \
    --cc=vishal.l.verma@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).