Skip to content

Commit b57fc65

Browse files
committed
drivers/base/node: Add a helper function node_update_perf_attrs()
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. Acked-by: David Hildenbrand <david@redhat.com> Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com> Link: https://patch.msgid.link/20250829222907.1290912-3-dave.jiang@intel.com Signed-off-by: Dave Jiang <dave.jiang@intel.com>
1 parent 6512886 commit b57fc65

2 files changed

Lines changed: 46 additions & 0 deletions

File tree

drivers/base/node.c

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,44 @@ void node_set_perf_attrs(unsigned int nid, struct access_coordinate *coord,
248248
}
249249
EXPORT_SYMBOL_GPL(node_set_perf_attrs);
250250

251+
/**
252+
* node_update_perf_attrs - Update the performance values for given access class
253+
* @nid: Node identifier to be updated
254+
* @coord: Heterogeneous memory performance coordinates
255+
* @access: The access class for the given attributes
256+
*/
257+
void node_update_perf_attrs(unsigned int nid, struct access_coordinate *coord,
258+
enum access_coordinate_class access)
259+
{
260+
struct node_access_nodes *access_node;
261+
struct node *node;
262+
int i;
263+
264+
if (WARN_ON_ONCE(!node_online(nid)))
265+
return;
266+
267+
node = node_devices[nid];
268+
list_for_each_entry(access_node, &node->access_list, list_node) {
269+
if (access_node->access != access)
270+
continue;
271+
272+
access_node->coord = *coord;
273+
for (i = 0; access_attrs[i]; i++) {
274+
sysfs_notify(&access_node->dev.kobj,
275+
NULL, access_attrs[i]->name);
276+
}
277+
break;
278+
}
279+
280+
/* When setting CPU access coordinates, update mempolicy */
281+
if (access != ACCESS_COORDINATE_CPU)
282+
return;
283+
284+
if (mempolicy_set_node_perf(nid, coord))
285+
pr_info("failed to set mempolicy attrs for node %d\n", nid);
286+
}
287+
EXPORT_SYMBOL_GPL(node_update_perf_attrs);
288+
251289
/**
252290
* struct node_cache_info - Internal tracking for memory node caches
253291
* @dev: Device represeting the cache level

include/linux/node.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ struct node_cache_attrs {
8585
void node_add_cache(unsigned int nid, struct node_cache_attrs *cache_attrs);
8686
void node_set_perf_attrs(unsigned int nid, struct access_coordinate *coord,
8787
enum access_coordinate_class access);
88+
void node_update_perf_attrs(unsigned int nid, struct access_coordinate *coord,
89+
enum access_coordinate_class access);
8890
#else
8991
static inline void node_add_cache(unsigned int nid,
9092
struct node_cache_attrs *cache_attrs)
@@ -96,6 +98,12 @@ static inline void node_set_perf_attrs(unsigned int nid,
9698
enum access_coordinate_class access)
9799
{
98100
}
101+
102+
static inline void node_update_perf_attrs(unsigned int nid,
103+
struct access_coordinate *coord,
104+
enum access_coordinate_class access)
105+
{
106+
}
99107
#endif
100108

101109
struct node {

0 commit comments

Comments
 (0)