Commit fca174cc authored by Andrew Morton's avatar Andrew Morton Committed by Christoph Hellwig

[PATCH] resurrect /proc/meminfo:Buffers

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.
parent e572ef2e
......@@ -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);
......
......@@ -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),
......
......@@ -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
......
......@@ -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();
......
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