Commit d9660d82 authored by Akinobu Mita's avatar Akinobu Mita Committed by Linus Torvalds

[PATCH] show Active/Inactive on per-node meminfo

  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.

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

  get_zone_counts() is used by max_sane_readahead(), and
  max_sane_readahead() is often called in filemap_nopage().
Signed-off-by: default avatarAkinobu Mita <amgta@yacht.ocn.ne.jp>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent c9d12e45
...@@ -38,11 +38,19 @@ static ssize_t node_read_meminfo(struct sys_device * dev, char * buf) ...@@ -38,11 +38,19 @@ static ssize_t node_read_meminfo(struct sys_device * dev, char * buf)
int n; int n;
int nid = dev->id; int nid = dev->id;
struct sysinfo i; struct sysinfo i;
unsigned long inactive;
unsigned long active;
unsigned long free;
si_meminfo_node(&i, nid); si_meminfo_node(&i, nid);
__get_zone_counts(&active, &inactive, &free, NODE_DATA(nid));
n = sprintf(buf, "\n" n = sprintf(buf, "\n"
"Node %d MemTotal: %8lu kB\n" "Node %d MemTotal: %8lu kB\n"
"Node %d MemFree: %8lu kB\n" "Node %d MemFree: %8lu kB\n"
"Node %d MemUsed: %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 HighTotal: %8lu kB\n"
"Node %d HighFree: %8lu kB\n" "Node %d HighFree: %8lu kB\n"
"Node %d LowTotal: %8lu kB\n" "Node %d LowTotal: %8lu kB\n"
...@@ -50,6 +58,8 @@ static ssize_t node_read_meminfo(struct sys_device * dev, char * buf) ...@@ -50,6 +58,8 @@ static ssize_t node_read_meminfo(struct sys_device * dev, char * buf)
nid, K(i.totalram), nid, K(i.totalram),
nid, K(i.freeram), nid, K(i.freeram),
nid, K(i.totalram - i.freeram), nid, K(i.totalram - i.freeram),
nid, K(active),
nid, K(inactive),
nid, K(i.totalhigh), nid, K(i.totalhigh),
nid, K(i.freehigh), nid, K(i.freehigh),
nid, K(i.totalram - i.totalhigh), nid, K(i.totalram - i.totalhigh),
......
...@@ -272,6 +272,8 @@ typedef struct pglist_data { ...@@ -272,6 +272,8 @@ typedef struct pglist_data {
extern int numnodes; extern int numnodes;
extern struct pglist_data *pgdat_list; 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, void get_zone_counts(unsigned long *active, unsigned long *inactive,
unsigned long *free); unsigned long *free);
void build_all_zonelists(void); void build_all_zonelists(void);
......
...@@ -961,18 +961,36 @@ unsigned long __read_page_state(unsigned offset) ...@@ -961,18 +961,36 @@ unsigned long __read_page_state(unsigned offset)
return ret; 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, void get_zone_counts(unsigned long *active,
unsigned long *inactive, unsigned long *free) unsigned long *inactive, unsigned long *free)
{ {
struct zone *zone; struct pglist_data *pgdat;
*active = 0; *active = 0;
*inactive = 0; *inactive = 0;
*free = 0; *free = 0;
for_each_zone(zone) { for_each_pgdat(pgdat) {
*active += zone->nr_active; unsigned long l, m, n;
*inactive += zone->nr_inactive; __get_zone_counts(&l, &m, &n, pgdat);
*free += zone->free_pages; *active += l;
*inactive += m;
*free += n;
} }
} }
......
...@@ -571,6 +571,6 @@ unsigned long max_sane_readahead(unsigned long nr) ...@@ -571,6 +571,6 @@ unsigned long max_sane_readahead(unsigned long nr)
unsigned long inactive; unsigned long inactive;
unsigned long free; unsigned long free;
get_zone_counts(&active, &inactive, &free); __get_zone_counts(&active, &inactive, &free, NODE_DATA(numa_node_id()));
return min(nr, (inactive + free) / 2); return min(nr, (inactive + free) / 2);
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment