diff mbox series

[RFC,v3,2/4] node: add accessors to sysfs when nodes are created

Message ID 20231031003810.4532-3-gregory.price@memverge.com
State New, archived
Headers show
Series Node Weights and Weighted Interleave | expand

Commit Message

Gregory Price Oct. 31, 2023, 12:38 a.m. UTC
Accessor information is presently only exposed when hmat information
is registered. Add accessor information at node creation to allow
new attributes to be added even in the absense of hmat information.

Signed-off-by: Gregory Price <gregory.price@memverge.com>
---
 drivers/base/node.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
diff mbox series

Patch

diff --git a/drivers/base/node.c b/drivers/base/node.c
index 4d588f4658c8..b09c9c8e6830 100644
--- a/drivers/base/node.c
+++ b/drivers/base/node.c
@@ -868,7 +868,9 @@  int __register_one_node(int nid)
 {
 	int error;
 	int cpu;
+	int onid;
 	struct node *node;
+	struct node_access_nodes *acc;
 
 	node = kzalloc(sizeof(struct node), GFP_KERNEL);
 	if (!node)
@@ -887,6 +889,20 @@  int __register_one_node(int nid)
 
 	node_init_caches(nid);
 
+	/*
+	 * for each cpu node - add accessor to this node
+	 * if this is a cpu node, add accessor to each other node
+	 */
+	for_each_online_node(onid) {
+		/* During system bringup nodes may not be fully initialized */
+		if (!node_devices[onid])
+			continue;
+		if (node_state(onid, N_CPU))
+			acc = node_init_node_access(node, onid);
+		if (node_state(nid, N_CPU))
+			acc = node_init_node_access(node_devices[onid], nid);
+	}
+
 	return error;
 }