Index: linux-2.6.15-rc3/include/linux/page-flags.h =================================================================== --- linux-2.6.15-rc3.orig/include/linux/page-flags.h 2005-11-29 03:51:27.000000000 +0000 +++ linux-2.6.15-rc3/include/linux/page-flags.h 2005-11-29 20:29:59.000000000 +0000 @@ -86,6 +86,7 @@ struct page_state { unsigned long nr_unstable; /* NFS unstable pages */ unsigned long nr_page_table_pages;/* Pages used for pagetables */ unsigned long nr_mapped; /* mapped into pagetables */ + unsigned long nr_pagecache; /* pages in the page cache */ unsigned long nr_slab; /* In slab */ #define GET_PAGE_STATE_LAST nr_slab @@ -133,6 +134,7 @@ struct page_state { unsigned long nr_bounce; /* pages for bounce buffers */ }; + extern void get_page_state(struct page_state *ret); extern void get_page_state_node(struct page_state *ret, int node); extern void get_full_page_state(struct page_state *ret); Index: linux-2.6.15-rc3/include/linux/pagemap.h =================================================================== --- linux-2.6.15-rc3.orig/include/linux/pagemap.h 2005-11-29 03:51:27.000000000 +0000 +++ linux-2.6.15-rc3/include/linux/pagemap.h 2005-11-29 20:29:59.000000000 +0000 @@ -99,49 +99,9 @@ int add_to_page_cache_lru(struct page *p extern void remove_from_page_cache(struct page *page); extern void __remove_from_page_cache(struct page *page); -extern atomic_t nr_pagecache; - -#ifdef CONFIG_SMP - -#define PAGECACHE_ACCT_THRESHOLD max(16, NR_CPUS * 2) -DECLARE_PER_CPU(long, nr_pagecache_local); - -/* - * pagecache_acct implements approximate accounting for pagecache. - * vm_enough_memory() do not need high accuracy. Writers will keep - * an offset in their per-cpu arena and will spill that into the - * global count whenever the absolute value of the local count - * exceeds the counter's threshold. - * - * MUST be protected from preemption. - * current protection is mapping->page_lock. - */ -static inline void pagecache_acct(int count) -{ - long *local; - - local = &__get_cpu_var(nr_pagecache_local); - *local += count; - if (*local > PAGECACHE_ACCT_THRESHOLD || *local < -PAGECACHE_ACCT_THRESHOLD) { - atomic_add(*local, &nr_pagecache); - *local = 0; - } -} - -#else - -static inline void pagecache_acct(int count) -{ - atomic_add(count, &nr_pagecache); -} -#endif - static inline unsigned long get_page_cache_size(void) { - int ret = atomic_read(&nr_pagecache); - if (unlikely(ret < 0)) - ret = 0; - return ret; + return read_page_state(nr_pagecache); } /* Index: linux-2.6.15-rc3/mm/filemap.c =================================================================== --- linux-2.6.15-rc3.orig/mm/filemap.c 2005-11-29 03:51:27.000000000 +0000 +++ linux-2.6.15-rc3/mm/filemap.c 2005-11-29 20:29:59.000000000 +0000 @@ -115,7 +115,7 @@ void __remove_from_page_cache(struct pag radix_tree_delete(&mapping->page_tree, page->index); page->mapping = NULL; mapping->nrpages--; - pagecache_acct(-1); + dec_page_state(nr_pagecache); } void remove_from_page_cache(struct page *page) @@ -390,7 +390,7 @@ int add_to_page_cache(struct page *page, page->mapping = mapping; page->index = offset; mapping->nrpages++; - pagecache_acct(1); + inc_page_state(nr_pagecache); } write_unlock_irq(&mapping->tree_lock); radix_tree_preload_end(); Index: linux-2.6.15-rc3/mm/swap_state.c =================================================================== --- linux-2.6.15-rc3.orig/mm/swap_state.c 2005-11-29 03:51:27.000000000 +0000 +++ linux-2.6.15-rc3/mm/swap_state.c 2005-11-29 20:29:59.000000000 +0000 @@ -84,7 +84,7 @@ static int __add_to_swap_cache(struct pa SetPageSwapCache(page); set_page_private(page, entry.val); total_swapcache_pages++; - pagecache_acct(1); + inc_page_state(nr_pagecache); } write_unlock_irq(&swapper_space.tree_lock); radix_tree_preload_end(); @@ -129,7 +129,7 @@ void __delete_from_swap_cache(struct pag set_page_private(page, 0); ClearPageSwapCache(page); total_swapcache_pages--; - pagecache_acct(-1); + dec_page_state(nr_pagecache); INC_CACHE_INFO(del_total); } Index: linux-2.6.15-rc3/mm/page_alloc.c =================================================================== --- linux-2.6.15-rc3.orig/mm/page_alloc.c 2005-11-29 03:51:27.000000000 +0000 +++ linux-2.6.15-rc3/mm/page_alloc.c 2005-11-29 20:29:59.000000000 +0000 @@ -1165,12 +1165,6 @@ static void show_node(struct zone *zone) */ static DEFINE_PER_CPU(struct page_state, page_states) = {0}; -atomic_t nr_pagecache = ATOMIC_INIT(0); -EXPORT_SYMBOL(nr_pagecache); -#ifdef CONFIG_SMP -DEFINE_PER_CPU(long, nr_pagecache_local) = 0; -#endif - void __get_page_state(struct page_state *ret, int nr, cpumask_t *cpumask) { int cpu = 0;