[PATCH] ZVC: Support NR_SLAB_RECLAIMABLE / NR_SLAB_UNRECLAIMABLE
authorChristoph Lameter <clameter@sgi.com>
Tue, 26 Sep 2006 06:31:51 +0000 (23:31 -0700)
committerLinus Torvalds <torvalds@g5.osdl.org>
Tue, 26 Sep 2006 15:48:51 +0000 (08:48 -0700)
Remove the atomic counter for slab_reclaim_pages and replace the counter
and NR_SLAB with two ZVC counter that account for unreclaimable and
reclaimable slab pages: NR_SLAB_RECLAIMABLE and NR_SLAB_UNRECLAIMABLE.

Change the check in vmscan.c to refer to to NR_SLAB_RECLAIMABLE.  The
intend seems to be to check for slab pages that could be freed.

Signed-off-by: Christoph Lameter <clameter@sgi.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
12 files changed:
arch/i386/mm/pgtable.c
drivers/base/node.c
fs/proc/proc_misc.c
include/linux/mmzone.h
include/linux/slab.h
mm/mmap.c
mm/nommu.c
mm/page_alloc.c
mm/slab.c
mm/slob.c
mm/vmscan.c
mm/vmstat.c

index bd98768..a9f4910 100644 (file)
@@ -60,7 +60,9 @@ void show_mem(void)
        printk(KERN_INFO "%lu pages writeback\n",
                                        global_page_state(NR_WRITEBACK));
        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_RECLAIMABLE) +
+               global_page_state(NR_SLAB_UNRECLAIMABLE));
        printk(KERN_INFO "%lu pages pagetables\n",
                                        global_page_state(NR_PAGETABLE));
 }
index e09f5c2..001e6f6 100644 (file)
@@ -68,7 +68,9 @@ static ssize_t node_read_meminfo(struct sys_device * dev, char * buf)
                       "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",
+                      "Node %d Slab:         %8lu kB\n"
+                      "Node %d SReclaimable: %8lu kB\n"
+                      "Node %d SUnreclaim:   %8lu kB\n",
                       nid, K(i.totalram),
                       nid, K(i.freeram),
                       nid, K(i.totalram - i.freeram),
@@ -88,7 +90,10 @@ static ssize_t node_read_meminfo(struct sys_device * dev, char * buf)
                       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)));
+                      nid, K(node_page_state(nid, NR_SLAB_RECLAIMABLE) +
+                               node_page_state(nid, NR_SLAB_UNRECLAIMABLE)),
+                      nid, K(node_page_state(nid, NR_SLAB_RECLAIMABLE)),
+                      nid, K(node_page_state(nid, NR_SLAB_UNRECLAIMABLE)));
        n += hugetlb_report_node_meminfo(nid, buf + n);
        return n;
 }
index caa0a51..5bbd608 100644 (file)
@@ -170,6 +170,8 @@ static int meminfo_read_proc(char *page, char **start, off_t off,
                "AnonPages:    %8lu kB\n"
                "Mapped:       %8lu kB\n"
                "Slab:         %8lu kB\n"
+               "SReclaimable: %8lu kB\n"
+               "SUnreclaim:   %8lu kB\n"
                "PageTables:   %8lu kB\n"
                "NFS_Unstable: %8lu kB\n"
                "Bounce:       %8lu kB\n"
@@ -197,7 +199,10 @@ static int meminfo_read_proc(char *page, char **start, off_t off,
                K(global_page_state(NR_WRITEBACK)),
                K(global_page_state(NR_ANON_PAGES)),
                K(global_page_state(NR_FILE_MAPPED)),
-               K(global_page_state(NR_SLAB)),
+               K(global_page_state(NR_SLAB_RECLAIMABLE) +
+                               global_page_state(NR_SLAB_UNRECLAIMABLE)),
+               K(global_page_state(NR_SLAB_RECLAIMABLE)),
+               K(global_page_state(NR_SLAB_UNRECLAIMABLE)),
                K(global_page_state(NR_PAGETABLE)),
                K(global_page_state(NR_UNSTABLE_NFS)),
                K(global_page_state(NR_BOUNCE)),
index a703527..08c41b9 100644 (file)
@@ -51,7 +51,8 @@ enum zone_stat_item {
        NR_FILE_MAPPED, /* pagecache pages mapped into pagetables.
                           only modified from process context */
        NR_FILE_PAGES,
-       NR_SLAB,        /* Pages used by slab allocator */
+       NR_SLAB_RECLAIMABLE,
+       NR_SLAB_UNRECLAIMABLE,
        NR_PAGETABLE,   /* used for pagetables */
        NR_FILE_DIRTY,
        NR_WRITEBACK,
index 2f6bef6..66d6eb7 100644 (file)
@@ -284,8 +284,6 @@ extern kmem_cache_t *fs_cachep;
 extern kmem_cache_t    *sighand_cachep;
 extern kmem_cache_t    *bio_cachep;
 
-extern atomic_t slab_reclaim_pages;
-
 #endif /* __KERNEL__ */
 
 #endif /* _LINUX_SLAB_H */
index 8507ee9..eea8eef 100644 (file)
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -116,7 +116,7 @@ int __vm_enough_memory(long pages, int cap_sys_admin)
                 * which are reclaimable, under pressure.  The dentry
                 * cache and most inode caches should fall into this
                 */
-               free += atomic_read(&slab_reclaim_pages);
+               free += global_page_state(NR_SLAB_RECLAIMABLE);
 
                /*
                 * Leave the last 3% for root
index c576df7..d99dea3 100644 (file)
@@ -1133,7 +1133,7 @@ int __vm_enough_memory(long pages, int cap_sys_admin)
                 * which are reclaimable, under pressure.  The dentry
                 * cache and most inode caches should fall into this
                 */
-               free += atomic_read(&slab_reclaim_pages);
+               free += global_page_state(NR_SLAB_RECLAIMABLE);
 
                /*
                 * Leave the last 3% for root
index 5da6bc4..47e9842 100644 (file)
@@ -1304,7 +1304,8 @@ void show_free_areas(void)
                global_page_state(NR_WRITEBACK),
                global_page_state(NR_UNSTABLE_NFS),
                nr_free_pages(),
-               global_page_state(NR_SLAB),
+               global_page_state(NR_SLAB_RECLAIMABLE) +
+                       global_page_state(NR_SLAB_UNRECLAIMABLE),
                global_page_state(NR_FILE_MAPPED),
                global_page_state(NR_PAGETABLE));
 
index 13b5050..7a48eb1 100644 (file)
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -736,14 +736,6 @@ static DEFINE_MUTEX(cache_chain_mutex);
 static struct list_head cache_chain;
 
 /*
- * vm_enough_memory() looks at this to determine how many slab-allocated pages
- * are possibly freeable under pressure
- *
- * SLAB_RECLAIM_ACCOUNT turns this on per-slab
- */
-atomic_t slab_reclaim_pages;
-
-/*
  * chicken and egg problem: delay the per-cpu array allocation
  * until the general caches are up.
  */
@@ -1580,8 +1572,11 @@ static void *kmem_getpages(struct kmem_cache *cachep, gfp_t flags, int nodeid)
 
        nr_pages = (1 << cachep->gfporder);
        if (cachep->flags & SLAB_RECLAIM_ACCOUNT)
-               atomic_add(nr_pages, &slab_reclaim_pages);
-       add_zone_page_state(page_zone(page), NR_SLAB, nr_pages);
+               add_zone_page_state(page_zone(page),
+                       NR_SLAB_RECLAIMABLE, nr_pages);
+       else
+               add_zone_page_state(page_zone(page),
+                       NR_SLAB_UNRECLAIMABLE, nr_pages);
        for (i = 0; i < nr_pages; i++)
                __SetPageSlab(page + i);
        return page_address(page);
@@ -1596,7 +1591,12 @@ static void kmem_freepages(struct kmem_cache *cachep, void *addr)
        struct page *page = virt_to_page(addr);
        const unsigned long nr_freed = i;
 
-       sub_zone_page_state(page_zone(page), NR_SLAB, nr_freed);
+       if (cachep->flags & SLAB_RECLAIM_ACCOUNT)
+               sub_zone_page_state(page_zone(page),
+                               NR_SLAB_RECLAIMABLE, nr_freed);
+       else
+               sub_zone_page_state(page_zone(page),
+                               NR_SLAB_UNRECLAIMABLE, nr_freed);
        while (i--) {
                BUG_ON(!PageSlab(page));
                __ClearPageSlab(page);
@@ -1605,8 +1605,6 @@ static void kmem_freepages(struct kmem_cache *cachep, void *addr)
        if (current->reclaim_state)
                current->reclaim_state->reclaimed_slab += nr_freed;
        free_pages((unsigned long)addr, cachep->gfporder);
-       if (cachep->flags & SLAB_RECLAIM_ACCOUNT)
-               atomic_sub(1 << cachep->gfporder, &slab_reclaim_pages);
 }
 
 static void kmem_rcu_free(struct rcu_head *head)
index 4c28a42..2018862 100644 (file)
--- a/mm/slob.c
+++ b/mm/slob.c
@@ -339,7 +339,3 @@ void kmem_cache_init(void)
 
        mod_timer(&slob_timer, jiffies + HZ);
 }
-
-atomic_t slab_reclaim_pages = ATOMIC_INIT(0);
-EXPORT_SYMBOL(slab_reclaim_pages);
-
index 5154c25..349797b 100644 (file)
@@ -1378,7 +1378,7 @@ unsigned long shrink_all_memory(unsigned long nr_pages)
        for_each_zone(zone)
                lru_pages += zone->nr_active + zone->nr_inactive;
 
-       nr_slab = global_page_state(NR_SLAB);
+       nr_slab = global_page_state(NR_SLAB_RECLAIMABLE);
        /* If slab caches are huge, it's better to hit them first */
        while (nr_slab >= lru_pages) {
                reclaim_state.reclaimed_slab = 0;
index 968c007..490d8c1 100644 (file)
@@ -458,7 +458,8 @@ static char *vmstat_text[] = {
        "nr_anon_pages",
        "nr_mapped",
        "nr_file_pages",
-       "nr_slab",
+       "nr_slab_reclaimable",
+       "nr_slab_unreclaimable",
        "nr_page_table_pages",
        "nr_dirty",
        "nr_writeback",