From: KAMEZAWA Hiroyuki This is a patch for counting the number of pages for bounce buffers. It's shown in /proc/vmstat. Currently, the number of bounce pages are not counted anywhere. So, if there are many bounce pages, it seems that there are leaked pages. And it's difficult for a user to imagine the usage of bounce pages. So, it's meaningful to show # of bouce pages. Signed-off-by: KAMEZAWA Hiroyuki Signed-off-by: Andrew Morton --- include/linux/page-flags.h | 1 + mm/highmem.c | 2 ++ mm/page_alloc.c | 1 + 3 files changed, 4 insertions(+) diff -puN include/linux/page-flags.h~count-bounce-buffer-pages-in-vmstat include/linux/page-flags.h --- 25/include/linux/page-flags.h~count-bounce-buffer-pages-in-vmstat 2005-04-26 23:49:04.159291184 -0700 +++ 25-akpm/include/linux/page-flags.h 2005-04-26 23:49:29.364459416 -0700 @@ -131,6 +131,7 @@ struct page_state { unsigned long allocstall; /* direct reclaim calls */ unsigned long pgrotated; /* pages rotated to tail of the LRU */ + unsigned long nr_bounce; /* pages for bounce buffers */ }; extern void get_page_state(struct page_state *ret); diff -puN mm/highmem.c~count-bounce-buffer-pages-in-vmstat mm/highmem.c --- 25/mm/highmem.c~count-bounce-buffer-pages-in-vmstat 2005-04-26 23:49:04.160291032 -0700 +++ 25-akpm/mm/highmem.c 2005-04-26 23:49:04.166290120 -0700 @@ -325,6 +325,7 @@ static void bounce_end_io(struct bio *bi continue; mempool_free(bvec->bv_page, pool); + dec_page_state(nr_bounce); } bio_endio(bio_orig, bio_orig->bi_size, err); @@ -405,6 +406,7 @@ static void __blk_queue_bounce(request_q to->bv_page = mempool_alloc(pool, q->bounce_gfp); to->bv_len = from->bv_len; to->bv_offset = from->bv_offset; + inc_page_state(nr_bounce); if (rw == WRITE) { char *vto, *vfrom; diff -puN mm/page_alloc.c~count-bounce-buffer-pages-in-vmstat mm/page_alloc.c --- 25/mm/page_alloc.c~count-bounce-buffer-pages-in-vmstat 2005-04-26 23:49:04.162290728 -0700 +++ 25-akpm/mm/page_alloc.c 2005-04-26 23:49:49.571387496 -0700 @@ -2010,6 +2010,7 @@ static char *vmstat_text[] = { "allocstall", "pgrotated", + "nr_bounce", }; static void *vmstat_start(struct seq_file *m, loff_t *pos) _