Commit b1e7a8fd authored by Christoph Lameter's avatar Christoph Lameter Committed by Linus Torvalds

[PATCH] zoned vm counters: conversion of nr_dirty to per zone counter

This makes nr_dirty a per zone counter.  Looping over all processors is
avoided during writeback state determination.

The counter aggregation for nr_dirty had to be undone in the NFS layer since
we summed up the page counts from multiple zones.  Someone more familiar with
NFS should probably review what I have done.

[akpm@osdl.org: bugfix]
Signed-off-by: default avatarChristoph Lameter <clameter@sgi.com>
Cc: Trond Myklebust <trond.myklebust@fys.uio.no>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent df849a15
...@@ -59,7 +59,7 @@ void show_mem(void) ...@@ -59,7 +59,7 @@ void show_mem(void)
printk(KERN_INFO "%d pages swap cached\n", cached); printk(KERN_INFO "%d pages swap cached\n", cached);
get_page_state(&ps); get_page_state(&ps);
printk(KERN_INFO "%lu pages dirty\n", ps.nr_dirty); printk(KERN_INFO "%lu pages dirty\n", global_page_state(NR_FILE_DIRTY));
printk(KERN_INFO "%lu pages writeback\n", ps.nr_writeback); printk(KERN_INFO "%lu pages writeback\n", ps.nr_writeback);
printk(KERN_INFO "%lu pages mapped\n", global_page_state(NR_FILE_MAPPED)); printk(KERN_INFO "%lu pages mapped\n", global_page_state(NR_FILE_MAPPED));
printk(KERN_INFO "%lu pages slab\n", global_page_state(NR_SLAB)); printk(KERN_INFO "%lu pages slab\n", global_page_state(NR_SLAB));
......
...@@ -50,8 +50,6 @@ static ssize_t node_read_meminfo(struct sys_device * dev, char * buf) ...@@ -50,8 +50,6 @@ static ssize_t node_read_meminfo(struct sys_device * dev, char * buf)
__get_zone_counts(&active, &inactive, &free, NODE_DATA(nid)); __get_zone_counts(&active, &inactive, &free, NODE_DATA(nid));
/* Check for negative values in these approximate counters */ /* Check for negative values in these approximate counters */
if ((long)ps.nr_dirty < 0)
ps.nr_dirty = 0;
if ((long)ps.nr_writeback < 0) if ((long)ps.nr_writeback < 0)
ps.nr_writeback = 0; ps.nr_writeback = 0;
...@@ -81,7 +79,7 @@ static ssize_t node_read_meminfo(struct sys_device * dev, char * buf) ...@@ -81,7 +79,7 @@ static ssize_t node_read_meminfo(struct sys_device * dev, char * buf)
nid, K(i.freehigh), nid, K(i.freehigh),
nid, K(i.totalram - i.totalhigh), nid, K(i.totalram - i.totalhigh),
nid, K(i.freeram - i.freehigh), nid, K(i.freeram - i.freehigh),
nid, K(ps.nr_dirty), nid, K(node_page_state(nid, NR_FILE_DIRTY)),
nid, K(ps.nr_writeback), nid, K(ps.nr_writeback),
nid, K(node_page_state(nid, NR_FILE_PAGES)), 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_FILE_MAPPED)),
......
...@@ -852,7 +852,7 @@ int __set_page_dirty_buffers(struct page *page) ...@@ -852,7 +852,7 @@ int __set_page_dirty_buffers(struct page *page)
write_lock_irq(&mapping->tree_lock); write_lock_irq(&mapping->tree_lock);
if (page->mapping) { /* Race with truncate? */ if (page->mapping) { /* Race with truncate? */
if (mapping_cap_account_dirty(mapping)) if (mapping_cap_account_dirty(mapping))
inc_page_state(nr_dirty); __inc_zone_page_state(page, NR_FILE_DIRTY);
radix_tree_tag_set(&mapping->page_tree, radix_tree_tag_set(&mapping->page_tree,
page_index(page), page_index(page),
PAGECACHE_TAG_DIRTY); PAGECACHE_TAG_DIRTY);
......
...@@ -464,7 +464,7 @@ void sync_inodes_sb(struct super_block *sb, int wait) ...@@ -464,7 +464,7 @@ void sync_inodes_sb(struct super_block *sb, int wait)
.range_start = 0, .range_start = 0,
.range_end = LLONG_MAX, .range_end = LLONG_MAX,
}; };
unsigned long nr_dirty = read_page_state(nr_dirty); unsigned long nr_dirty = global_page_state(NR_FILE_DIRTY);
unsigned long nr_unstable = read_page_state(nr_unstable); unsigned long nr_unstable = read_page_state(nr_unstable);
wbc.nr_to_write = nr_dirty + nr_unstable + wbc.nr_to_write = nr_dirty + nr_unstable +
......
...@@ -315,6 +315,7 @@ nfs_scan_lock_dirty(struct nfs_inode *nfsi, struct list_head *dst, ...@@ -315,6 +315,7 @@ nfs_scan_lock_dirty(struct nfs_inode *nfsi, struct list_head *dst,
req->wb_index, NFS_PAGE_TAG_DIRTY); req->wb_index, NFS_PAGE_TAG_DIRTY);
nfs_list_remove_request(req); nfs_list_remove_request(req);
nfs_list_add_request(req, dst); nfs_list_add_request(req, dst);
dec_zone_page_state(req->wb_page, NR_FILE_DIRTY);
res++; res++;
} }
} }
......
...@@ -497,7 +497,7 @@ nfs_mark_request_dirty(struct nfs_page *req) ...@@ -497,7 +497,7 @@ nfs_mark_request_dirty(struct nfs_page *req)
nfs_list_add_request(req, &nfsi->dirty); nfs_list_add_request(req, &nfsi->dirty);
nfsi->ndirty++; nfsi->ndirty++;
spin_unlock(&nfsi->req_lock); spin_unlock(&nfsi->req_lock);
inc_page_state(nr_dirty); inc_zone_page_state(req->wb_page, NR_FILE_DIRTY);
mark_inode_dirty(inode); mark_inode_dirty(inode);
} }
...@@ -609,7 +609,6 @@ nfs_scan_dirty(struct inode *inode, struct list_head *dst, unsigned long idx_sta ...@@ -609,7 +609,6 @@ nfs_scan_dirty(struct inode *inode, struct list_head *dst, unsigned long idx_sta
if (nfsi->ndirty != 0) { if (nfsi->ndirty != 0) {
res = nfs_scan_lock_dirty(nfsi, dst, idx_start, npages); res = nfs_scan_lock_dirty(nfsi, dst, idx_start, npages);
nfsi->ndirty -= res; nfsi->ndirty -= res;
sub_page_state(nr_dirty,res);
if ((nfsi->ndirty == 0) != list_empty(&nfsi->dirty)) if ((nfsi->ndirty == 0) != list_empty(&nfsi->dirty))
printk(KERN_ERR "NFS: desynchronized value of nfs_i.ndirty.\n"); printk(KERN_ERR "NFS: desynchronized value of nfs_i.ndirty.\n");
} }
......
...@@ -190,7 +190,7 @@ static int meminfo_read_proc(char *page, char **start, off_t off, ...@@ -190,7 +190,7 @@ static int meminfo_read_proc(char *page, char **start, off_t off,
K(i.freeram-i.freehigh), K(i.freeram-i.freehigh),
K(i.totalswap), K(i.totalswap),
K(i.freeswap), K(i.freeswap),
K(ps.nr_dirty), K(global_page_state(NR_FILE_DIRTY)),
K(ps.nr_writeback), K(ps.nr_writeback),
K(global_page_state(NR_ANON_PAGES)), K(global_page_state(NR_ANON_PAGES)),
K(global_page_state(NR_FILE_MAPPED)), K(global_page_state(NR_FILE_MAPPED)),
......
...@@ -53,6 +53,7 @@ enum zone_stat_item { ...@@ -53,6 +53,7 @@ enum zone_stat_item {
NR_FILE_PAGES, NR_FILE_PAGES,
NR_SLAB, /* Pages used by slab allocator */ NR_SLAB, /* Pages used by slab allocator */
NR_PAGETABLE, /* used for pagetables */ NR_PAGETABLE, /* used for pagetables */
NR_FILE_DIRTY,
NR_VM_ZONE_STAT_ITEMS }; NR_VM_ZONE_STAT_ITEMS };
struct per_cpu_pages { struct per_cpu_pages {
......
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
* commented here. * commented here.
*/ */
struct page_state { struct page_state {
unsigned long nr_dirty; /* Dirty writeable pages */
unsigned long nr_writeback; /* Pages under writeback */ unsigned long nr_writeback; /* Pages under writeback */
unsigned long nr_unstable; /* NFS unstable pages */ unsigned long nr_unstable; /* NFS unstable pages */
#define GET_PAGE_STATE_LAST nr_unstable #define GET_PAGE_STATE_LAST nr_unstable
......
...@@ -109,7 +109,7 @@ struct writeback_state ...@@ -109,7 +109,7 @@ struct writeback_state
static void get_writeback_state(struct writeback_state *wbs) static void get_writeback_state(struct writeback_state *wbs)
{ {
wbs->nr_dirty = read_page_state(nr_dirty); wbs->nr_dirty = global_page_state(NR_FILE_DIRTY);
wbs->nr_unstable = read_page_state(nr_unstable); wbs->nr_unstable = read_page_state(nr_unstable);
wbs->nr_mapped = global_page_state(NR_FILE_MAPPED) + wbs->nr_mapped = global_page_state(NR_FILE_MAPPED) +
global_page_state(NR_ANON_PAGES); global_page_state(NR_ANON_PAGES);
...@@ -641,7 +641,8 @@ int __set_page_dirty_nobuffers(struct page *page) ...@@ -641,7 +641,8 @@ int __set_page_dirty_nobuffers(struct page *page)
if (mapping2) { /* Race with truncate? */ if (mapping2) { /* Race with truncate? */
BUG_ON(mapping2 != mapping); BUG_ON(mapping2 != mapping);
if (mapping_cap_account_dirty(mapping)) if (mapping_cap_account_dirty(mapping))
inc_page_state(nr_dirty); __inc_zone_page_state(page,
NR_FILE_DIRTY);
radix_tree_tag_set(&mapping->page_tree, radix_tree_tag_set(&mapping->page_tree,
page_index(page), PAGECACHE_TAG_DIRTY); page_index(page), PAGECACHE_TAG_DIRTY);
} }
...@@ -728,9 +729,9 @@ int test_clear_page_dirty(struct page *page) ...@@ -728,9 +729,9 @@ int test_clear_page_dirty(struct page *page)
radix_tree_tag_clear(&mapping->page_tree, radix_tree_tag_clear(&mapping->page_tree,
page_index(page), page_index(page),
PAGECACHE_TAG_DIRTY); PAGECACHE_TAG_DIRTY);
write_unlock_irqrestore(&mapping->tree_lock, flags);
if (mapping_cap_account_dirty(mapping)) if (mapping_cap_account_dirty(mapping))
dec_page_state(nr_dirty); __dec_zone_page_state(page, NR_FILE_DIRTY);
write_unlock_irqrestore(&mapping->tree_lock, flags);
return 1; return 1;
} }
write_unlock_irqrestore(&mapping->tree_lock, flags); write_unlock_irqrestore(&mapping->tree_lock, flags);
...@@ -761,7 +762,7 @@ int clear_page_dirty_for_io(struct page *page) ...@@ -761,7 +762,7 @@ int clear_page_dirty_for_io(struct page *page)
if (mapping) { if (mapping) {
if (TestClearPageDirty(page)) { if (TestClearPageDirty(page)) {
if (mapping_cap_account_dirty(mapping)) if (mapping_cap_account_dirty(mapping))
dec_page_state(nr_dirty); dec_zone_page_state(page, NR_FILE_DIRTY);
return 1; return 1;
} }
return 0; return 0;
......
...@@ -1314,7 +1314,7 @@ void show_free_areas(void) ...@@ -1314,7 +1314,7 @@ void show_free_areas(void)
"unstable:%lu free:%u slab:%lu mapped:%lu pagetables:%lu\n", "unstable:%lu free:%u slab:%lu mapped:%lu pagetables:%lu\n",
active, active,
inactive, inactive,
ps.nr_dirty, global_page_state(NR_FILE_DIRTY),
ps.nr_writeback, ps.nr_writeback,
ps.nr_unstable, ps.nr_unstable,
nr_free_pages(), nr_free_pages(),
......
...@@ -400,9 +400,9 @@ static char *vmstat_text[] = { ...@@ -400,9 +400,9 @@ static char *vmstat_text[] = {
"nr_file_pages", "nr_file_pages",
"nr_slab", "nr_slab",
"nr_page_table_pages", "nr_page_table_pages",
"nr_dirty",
/* Page state */ /* Page state */
"nr_dirty",
"nr_writeback", "nr_writeback",
"nr_unstable", "nr_unstable",
......
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