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

From: Gregory Price
Date: Mon Oct 30 2023 - 20:38:32 EST


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@xxxxxxxxxxxx>
---
drivers/base/node.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)

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;
}

--
2.39.1