]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/base/node.c
[PATCH] zoned vm counters: conversion of nr_bounce to per zone counter
[linux-2.6-omap-h63xx.git] / drivers / base / node.c
index 904b27caf697df2c0d14d1cab426212bad27bb25..772eadac57a72e553cad3402f13443d9f1235b40 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"),
@@ -46,6 +47,7 @@ static ssize_t node_read_meminfo(struct sys_device * dev, char * buf)
        si_meminfo_node(&i, nid);
        __get_zone_counts(&active, &inactive, &free, NODE_DATA(nid));
 
+
        n = sprintf(buf, "\n"
                       "Node %d MemTotal:     %8lu kB\n"
                       "Node %d MemFree:      %8lu kB\n"
@@ -55,7 +57,16 @@ static ssize_t node_read_meminfo(struct sys_device * dev, char * buf)
                       "Node %d HighTotal:    %8lu kB\n"
                       "Node %d HighFree:     %8lu kB\n"
                       "Node %d LowTotal:     %8lu kB\n"
-                      "Node %d LowFree:      %8lu kB\n",
+                      "Node %d LowFree:      %8lu kB\n"
+                      "Node %d Dirty:        %8lu kB\n"
+                      "Node %d Writeback:    %8lu kB\n"
+                      "Node %d FilePages:    %8lu kB\n"
+                      "Node %d Mapped:       %8lu kB\n"
+                      "Node %d AnonPages:    %8lu kB\n"
+                      "Node %d PageTables:   %8lu kB\n"
+                      "Node %d NFS Unstable: %8lu kB\n"
+                      "Node %d Bounce:       %8lu kB\n"
+                      "Node %d Slab:         %8lu kB\n",
                       nid, K(i.totalram),
                       nid, K(i.freeram),
                       nid, K(i.totalram - i.freeram),
@@ -64,7 +75,16 @@ static ssize_t node_read_meminfo(struct sys_device * dev, char * buf)
                       nid, K(i.totalhigh),
                       nid, K(i.freehigh),
                       nid, K(i.totalram - i.totalhigh),
-                      nid, K(i.freeram - i.freehigh));
+                      nid, K(i.freeram - i.freehigh),
+                      nid, K(node_page_state(nid, NR_FILE_DIRTY)),
+                      nid, K(node_page_state(nid, NR_WRITEBACK)),
+                      nid, K(node_page_state(nid, NR_FILE_PAGES)),
+                      nid, K(node_page_state(nid, NR_FILE_MAPPED)),
+                      nid, K(node_page_state(nid, NR_ANON_PAGES)),
+                      nid, K(node_page_state(nid, NR_PAGETABLE)),
+                      nid, K(node_page_state(nid, NR_UNSTABLE_NFS)),
+                      nid, K(node_page_state(nid, NR_BOUNCE)),
+                      nid, K(node_page_state(nid, NR_SLAB)));
        n += hugetlb_report_node_meminfo(nid, buf + n);
        return n;
 }
@@ -86,7 +106,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;
@@ -170,6 +190,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);