
From: mita akinobu <amgta@yacht.ocn.ne.jp>

The patch below enable to display the size of Active/Inactive pages on
per-node meminfo (/sys/devices/system/node/node%d/meminfo) like
/proc/meminfo.

By a little change to procps, "vmstat -a" can show these statistics about
particular node.

Signed-off-by: Akinobu Mita <amgta@yacht.ocn.ne.jp>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/drivers/base/node.c    |   10 ++++++++++
 25-akpm/include/linux/mmzone.h |    2 ++
 25-akpm/mm/page_alloc.c        |   28 +++++++++++++++++++++++-----
 3 files changed, 35 insertions(+), 5 deletions(-)

diff -puN drivers/base/node.c~shows-active-inactive-on-per-node-meminfo drivers/base/node.c
--- 25/drivers/base/node.c~shows-active-inactive-on-per-node-meminfo	Fri Aug 20 15:26:38 2004
+++ 25-akpm/drivers/base/node.c	Fri Aug 20 15:26:38 2004
@@ -38,11 +38,19 @@ static ssize_t node_read_meminfo(struct 
 	int n;
 	int nid = dev->id;
 	struct sysinfo i;
+	unsigned long inactive;
+	unsigned long active;
+	unsigned long free;
+
 	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"
 		       "Node %d MemUsed:      %8lu kB\n"
+		       "Node %d Active:       %8lu kB\n"
+		       "Node %d Inactive:     %8lu kB\n"
 		       "Node %d HighTotal:    %8lu kB\n"
 		       "Node %d HighFree:     %8lu kB\n"
 		       "Node %d LowTotal:     %8lu kB\n"
@@ -50,6 +58,8 @@ static ssize_t node_read_meminfo(struct 
 		       nid, K(i.totalram),
 		       nid, K(i.freeram),
 		       nid, K(i.totalram - i.freeram),
+		       nid, K(active),
+		       nid, K(inactive),
 		       nid, K(i.totalhigh),
 		       nid, K(i.freehigh),
 		       nid, K(i.totalram - i.totalhigh),
diff -puN include/linux/mmzone.h~shows-active-inactive-on-per-node-meminfo include/linux/mmzone.h
--- 25/include/linux/mmzone.h~shows-active-inactive-on-per-node-meminfo	Fri Aug 20 15:26:38 2004
+++ 25-akpm/include/linux/mmzone.h	Fri Aug 20 15:26:38 2004
@@ -272,6 +272,8 @@ typedef struct pglist_data {
 extern int numnodes;
 extern struct pglist_data *pgdat_list;
 
+void __get_zone_counts(unsigned long *active, unsigned long *inactive,
+			unsigned long *free, struct pglist_data *pgdat);
 void get_zone_counts(unsigned long *active, unsigned long *inactive,
 			unsigned long *free);
 void build_all_zonelists(void);
diff -puN mm/page_alloc.c~shows-active-inactive-on-per-node-meminfo mm/page_alloc.c
--- 25/mm/page_alloc.c~shows-active-inactive-on-per-node-meminfo	Fri Aug 20 15:26:38 2004
+++ 25-akpm/mm/page_alloc.c	Fri Aug 20 15:26:38 2004
@@ -1072,18 +1072,36 @@ unsigned long __read_page_state(unsigned
 	return ret;
 }
 
+void __get_zone_counts(unsigned long *active, unsigned long *inactive,
+			unsigned long *free, struct pglist_data *pgdat)
+{
+	struct zone *zones = pgdat->node_zones;
+	int i;
+
+	*active = 0;
+	*inactive = 0;
+	*free = 0;
+	for (i = 0; i < MAX_NR_ZONES; i++) {
+		*active += zones[i].nr_active;
+		*inactive += zones[i].nr_inactive;
+		*free += zones[i].free_pages;
+	}
+}
+
 void get_zone_counts(unsigned long *active,
 		unsigned long *inactive, unsigned long *free)
 {
-	struct zone *zone;
+	struct pglist_data *pgdat;
 
 	*active = 0;
 	*inactive = 0;
 	*free = 0;
-	for_each_zone(zone) {
-		*active += zone->nr_active;
-		*inactive += zone->nr_inactive;
-		*free += zone->free_pages;
+	for_each_pgdat(pgdat) {
+		unsigned long l, m, n;
+		__get_zone_counts(&l, &m, &n, pgdat);
+		*active += l;
+		*inactive += m;
+		*free += n;
 	}
 }
 
_
