]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/base/node.c
Merge git://oss.sgi.com:8090/nathans/xfs-2.6
[linux-2.6-omap-h63xx.git] / drivers / base / node.c
index 16c513aa4d4877afa7522eedc7e695568648cbf7..eae2bdc183bb7741a85c23f086d156c95b1d0317 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/cpumask.h>
 #include <linux/topology.h>
 #include <linux/nodemask.h>
+#include <linux/cpu.h>
 
 static struct sysdev_class node_class = {
        set_kset_name("node"),
@@ -106,7 +107,7 @@ static ssize_t node_read_numastat(struct sys_device * dev, char * buf)
        other_node = 0;
        for (i = 0; i < MAX_NR_ZONES; i++) {
                struct zone *z = &pg->node_zones[i];
-               for (cpu = 0; cpu < NR_CPUS; cpu++) {
+               for_each_online_cpu(cpu) {
                        struct per_cpu_pageset *ps = zone_pcp(z,cpu);
                        numa_hit += ps->numa_hit;
                        numa_miss += ps->numa_miss;
@@ -190,6 +191,66 @@ void unregister_node(struct node *node)
        sysdev_unregister(&node->sysdev);
 }
 
+struct node node_devices[MAX_NUMNODES];
+
+/*
+ * register cpu under node
+ */
+int register_cpu_under_node(unsigned int cpu, unsigned int nid)
+{
+       if (node_online(nid)) {
+               struct sys_device *obj = get_cpu_sysdev(cpu);
+               if (!obj)
+                       return 0;
+               return sysfs_create_link(&node_devices[nid].sysdev.kobj,
+                                        &obj->kobj,
+                                        kobject_name(&obj->kobj));
+        }
+
+       return 0;
+}
+
+int unregister_cpu_under_node(unsigned int cpu, unsigned int nid)
+{
+       if (node_online(nid)) {
+               struct sys_device *obj = get_cpu_sysdev(cpu);
+               if (obj)
+                       sysfs_remove_link(&node_devices[nid].sysdev.kobj,
+                                        kobject_name(&obj->kobj));
+       }
+       return 0;
+}
+
+int register_one_node(int nid)
+{
+       int error = 0;
+       int cpu;
+
+       if (node_online(nid)) {
+               int p_node = parent_node(nid);
+               struct node *parent = NULL;
+
+               if (p_node != nid)
+                       parent = &node_devices[p_node];
+
+               error = register_node(&node_devices[nid], nid, parent);
+
+               /* link cpu under this node */
+               for_each_present_cpu(cpu) {
+                       if (cpu_to_node(cpu) == nid)
+                               register_cpu_under_node(cpu, nid);
+               }
+       }
+
+       return error;
+
+}
+
+void unregister_one_node(int nid)
+{
+       unregister_node(&node_devices[nid]);
+}
+
 static int __init register_node_type(void)
 {
        return sysdev_class_register(&node_class);