From: Nathan Lynch <nathanl@austin.ibm.com>
To: linux-kernel@vger.kernel.org
Cc: greg@kroah.com, rusty@rustcorp.com.au, mochel@digitalimplant.org,
Nathan Lynch <nathanl@austin.ibm.com>,
anton@samba.org
Subject: [RFC/PATCH 2/4] drivers/base/node.c changes for dynamic cpu registration
Date: Sun, 24 Oct 2004 05:42:24 -0400 [thread overview]
Message-ID: <20041024094606.28808.7701.89376@biclops> (raw)
In-Reply-To: <20041024094551.28808.28284.87316@biclops>
Register numa node system devices in the core code instead of leaving
it to the architecture. Add an array of MAX_NUMNODES node devices and
register those which are online at boot. Create sysfs symlinks to
each node's cpu devices.
Signed-off-by: Nathan Lynch <nathanl@austin.ibm.com>
---
diff -puN drivers/base/node.c~move-node-sysdev-registration-to-core drivers/base/node.c
--- 2.6.10-rc1/drivers/base/node.c~move-node-sysdev-registration-to-core 2004-10-24 03:52:53.000000000 -0500
+++ 2.6.10-rc1-nathanl/drivers/base/node.c 2004-10-24 03:52:53.000000000 -0500
@@ -9,7 +9,9 @@
#include <linux/node.h>
#include <linux/hugetlb.h>
#include <linux/cpumask.h>
+#include <linux/nodemask.h>
#include <linux/topology.h>
+#include <linux/cpu.h>
static struct sysdev_class node_class = {
set_kset_name("node"),
@@ -133,9 +135,65 @@ int __init register_node(struct node *no
return error;
}
+static struct node *node_devices;
+
+static int node_cpu_add_dev (struct sys_device * sys_dev)
+{
+ unsigned int cpu = sys_dev->id;
+ int ret, node = cpu_to_node(cpu);
+
+ ret = sysfs_create_link(&node_devices[node].sysdev.kobj,
+ &sys_dev->kobj,
+ kobject_name(&sys_dev->kobj));
+ return ret;
+}
+
+static int node_cpu_remove_dev (struct sys_device * sys_dev)
+{
+ unsigned int cpu = sys_dev->id;
+ int node = cpu_to_node(cpu);
+
+ sysfs_remove_link(&node_devices[node].sysdev.kobj,
+ kobject_name(&sys_dev->kobj));
+ return 0;
+
+}
+
+/* Methods for notifying us when cpus are added and removed */
+static struct sysdev_driver node_cpu_sysdev_driver = {
+ .add = node_cpu_add_dev,
+ .remove = node_cpu_remove_dev,
+};
int __init register_node_type(void)
{
- return sysdev_class_register(&node_class);
+ int i, ret = 0;
+ size_t size = sizeof(*node_devices) * num_online_nodes();
+
+ sysdev_class_register(&node_class);
+
+ node_devices = kmalloc(size, GFP_KERNEL);
+ if (!node_devices)
+ return -ENOMEM;
+
+ memset(node_devices, 0, size);
+
+ for_each_online_node(i) {
+ int pnum = parent_node(i);
+ struct node *parent = NULL;
+
+ if (pnum != i)
+ parent = &node_devices[pnum];
+
+ ret = register_node(&node_devices[i], i, parent);
+
+ if (ret)
+ goto out;
+ }
+
+ ret = sysdev_driver_register(&cpu_sysdev_class,
+ &node_cpu_sysdev_driver);
+out:
+ return ret;
}
postcore_initcall(register_node_type);
_
next prev parent reply other threads:[~2004-10-24 9:45 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-10-24 9:42 [RFC/PATCH 0/4] cpus, nodes, and the device model: dynamic cpu registration Nathan Lynch
2004-10-24 9:42 ` [RFC/PATCH 1/4] dynamic cpu registration - core changes Nathan Lynch
2004-11-05 1:51 ` Ashok Raj
2004-11-09 3:45 ` Nathan Lynch
2004-10-24 9:42 ` Nathan Lynch [this message]
2004-10-24 9:42 ` [RFC/PATCH 3/4] introduce cpu_add and cpu_remove Nathan Lynch
2004-11-05 1:57 ` Ashok Raj
2004-11-05 23:14 ` Matthew Dobson
2004-10-24 9:42 ` [RFC/PATCH 4/4] ppc64: convert to sysdev_driver Nathan Lynch
2004-10-25 6:12 ` [RFC/PATCH 0/4] cpus, nodes, and the device model: dynamic cpu registration Rusty Russell
2004-10-25 11:20 ` Nathan Lynch
2004-11-05 1:09 ` Ashok Raj
2004-11-09 3:45 ` Nathan Lynch
2004-11-05 1:54 ` Keshavamurthy Anil S
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=20041024094606.28808.7701.89376@biclops \
--to=nathanl@austin.ibm.com \
--cc=anton@samba.org \
--cc=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mochel@digitalimplant.org \
--cc=rusty@rustcorp.com.au \
/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