]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] resurrect /proc/meminfo:Buffers
authorAndrew Morton <akpm@digeo.com>
Sun, 15 Sep 2002 15:50:24 +0000 (08:50 -0700)
committerChristoph Hellwig <hch@hera.kernel.org>
Sun, 15 Sep 2002 15:50:24 +0000 (08:50 -0700)
The /proc/meminfo:Buffers statistic is quite useful - it tells us
how effective we are being at caching filesystem metadata.

For example, increases in this figure are a measure of success of the
slablru and buffer_head-limitation patches.

The patch resurrects buffermem accounting.  The metric is calculated
on-demand, via a walk of the blockdev hashtable.

fs/block_dev.c
fs/proc/proc_misc.c
include/linux/blkdev.h
mm/page_alloc.c

index f5a3d314bcd411be4d8d67b1ca70052f34fcd710..9b20fd7b9f524c8290e677e228bce846578f78c4 100644 (file)
@@ -332,6 +332,29 @@ struct block_device *bdget(dev_t dev)
        return bdev;
 }
 
+long nr_blockdev_pages(void)
+{
+       long ret = 0;
+       int i;
+
+       spin_lock(&bdev_lock);
+       for (i = 0; i < ARRAY_SIZE(bdev_hashtable); i++) {
+               struct list_head *head = &bdev_hashtable[i];
+               struct list_head *lh;
+
+               if (head == NULL)
+                       continue;
+               list_for_each(lh, head) {
+                       struct block_device *bdev;
+
+                       bdev = list_entry(lh, struct block_device, bd_hash);
+                       ret += bdev->bd_inode->i_mapping->nrpages;
+               }
+       }
+       spin_unlock(&bdev_lock);
+       return ret;
+}
+
 static inline void __bd_forget(struct inode *inode)
 {
        list_del_init(&inode->i_devices);
index 5bf8dbc9d8712e820a54d074c19af8d585b43030..8e75f1f9a57ce42b36a32eb22a29b15e01cedd5a 100644 (file)
@@ -165,6 +165,7 @@ static int meminfo_read_proc(char *page, char **start, off_t off,
                "MemTotal:     %8lu kB\n"
                "MemFree:      %8lu kB\n"
                "MemShared:    %8lu kB\n"
+               "Buffers:      %8lu kB\n"
                "Cached:       %8lu kB\n"
                "SwapCached:   %8lu kB\n"
                "Active:       %8lu kB\n"
@@ -185,7 +186,8 @@ static int meminfo_read_proc(char *page, char **start, off_t off,
                K(i.totalram),
                K(i.freeram),
                K(i.sharedram),
-               K(ps.nr_pagecache-swapper_space.nrpages),
+               K(i.bufferram),
+               K(ps.nr_pagecache-swapper_space.nrpages-i.bufferram),
                K(swapper_space.nrpages),
                K(active),
                K(inactive),
index 7ef082f9462f8ab4cb8678e607fd27c0b68e0a08..70781c985caac53372c3a600100068957d9119c3 100644 (file)
@@ -327,7 +327,7 @@ extern struct backing_dev_info *blk_get_backing_dev_info(struct block_device *bd
 extern int blk_rq_map_sg(request_queue_t *, struct request *, struct scatterlist *);
 extern void blk_dump_rq_flags(struct request *, char *);
 extern void generic_unplug_device(void *);
-
+extern long nr_blockdev_pages(void);
 
 /*
  * tag stuff
index fdf25f60d93f9d52c53ae1732b7d2a32bdfa80e9..7a85123602ad810c1f963758ee64b454873a09de 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/module.h>
 #include <linux/suspend.h>
 #include <linux/pagevec.h>
+#include <linux/blkdev.h>
 
 unsigned long totalram_pages;
 unsigned long totalhigh_pages;
@@ -589,7 +590,7 @@ void si_meminfo(struct sysinfo *val)
        val->totalram = totalram_pages;
        val->sharedram = 0;
        val->freeram = nr_free_pages();
-       val->bufferram = get_page_cache_size();
+       val->bufferram = nr_blockdev_pages();
 #ifdef CONFIG_HIGHMEM
        val->totalhigh = totalhigh_pages;
        val->freehigh = nr_free_highpages();