Skip to contentSkip to conversation

counting bounce pages.

RFC PATCH In review KAMEZAWA Hiroyuki 2 participants 2 messages Apr 25, 2005

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 counting bounce pages.

Hi

This is a patch for counting bounce pages.
With this, pages for bounce buffer is coutned and shown in /proc/meminfo.

Because pages for bounce buffer are not counted in anywhere, sometimes it seems that there are many leaked pages.
ex)
I found 1.7GB of bounce buffer pages in a crash dump of ia64 kernel, which was passed me to check memory usage. :(

BTW, I'm not sure whether # of bounce buffer should be includeded in Buffers:
of /proc/meminfo.

-- Kame <[email protected]>

count the number of bounce pages.

---

 linux-2.6.12-rc2-mm3-kamezawa/fs/proc/proc_misc.c |    7 +++++--
 linux-2.6.12-rc2-mm3-kamezawa/mm/highmem.c        |    3 +++
 2 files changed, 8 insertions(+), 2 deletions(-)
mm/highmem.c renamed from mm/highmem.c~count_bounce +3 -0
diff -puN mm/highmem.c~count_bounce mm/highmem.c
@@ -214,6 +214,7 @@ void fastcall kunmap_high(struct page *p
 EXPORT_SYMBOL(kunmap_high);
 
 #define POOL_SIZE	64
+atomic_t nr_bounce_pages = ATOMIC_INIT(0);
 
 static __init int init_emergency_pool(void)
 {
@@ -325,6 +326,7 @@ static void bounce_end_io(struct bio *bi
 			continue;
 
 		mempool_free(bvec->bv_page, pool);	
+		atomic_dec(&nr_bounce_pages);
 	}
 
 	bio_endio(bio_orig, bio_orig->bi_size, err);
@@ -405,6 +407,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;
+		atomic_inc(&nr_bounce_pages);
 
 		if (rw == WRITE) {
 			char *vto, *vfrom;
fs/proc/proc_misc.c renamed from fs/proc/proc_misc.c~count_bounce +5 -2
diff -puN fs/proc/proc_misc.c~count_bounce fs/proc/proc_misc.c
@@ -114,7 +114,7 @@ static int uptime_read_proc(char *page, 
 
 	return proc_calc_metrics(page, start, off, count, eof, len);
 }
-
+extern atomic_t nr_bounce_pages;
 static int meminfo_read_proc(char *page, char **start, off_t off,
 				 int count, int *eof, void *data)
 {
@@ -128,6 +128,7 @@ static int meminfo_read_proc(char *page,
 	unsigned long allowed;
 	struct vmalloc_info vmi;
 	long cached;
+	unsigned long bounce;
 
 	get_page_state(&ps);
 	get_zone_counts(&active, &inactive, &free);
@@ -147,7 +148,7 @@ static int meminfo_read_proc(char *page,
 		cached = 0;
 
 	get_vmalloc_info(&vmi);
-
+	bounce = atomic_read(&nr_bounce_pages);
 	/*
 	 * Tagged format, for easy grepping and expansion.
 	 */
@@ -169,6 +170,7 @@ static int meminfo_read_proc(char *page,
 		"Writeback:    %8lu kB\n"
 		"Mapped:       %8lu kB\n"
 		"Slab:         %8lu kB\n"
+		"Bounce :      %8lu kB\n"
 		"CommitLimit:  %8lu kB\n"
 		"Committed_AS: %8lu kB\n"
 		"PageTables:   %8lu kB\n"
@@ -192,6 +194,7 @@ static int meminfo_read_proc(char *page,
 		K(ps.nr_writeback),
 		K(ps.nr_mapped),
 		K(ps.nr_slab),
+		K(bounce),
 		K(allowed),
 		K(committed),
 		K(ps.nr_page_table_pages),

_

#1 lore raw
Quoted 3 lines · KAMEZAWA Hiroyuki

This is a patch for counting bounce pages.
With this, pages for bounce buffer is coutned and shown in /proc/meminfo.

As it's purely a debug thing, perhaps /proc/vmstat would be a better place for displaying this info.

Quoted 5 lines

Because pages for bounce buffer are not counted in anywhere, sometimes it seems that there are many leaked pages.
ex)
I found 1.7GB of bounce buffer pages in a crash dump of ia64 kernel, which was passed me to check memory usage. :(

whoops.

Quoted 2 lines

BTW, I'm not sure whether # of bounce buffer should be includeded in Buffers:
of /proc/meminfo.

No, "Buffers:" is "the number of bytes allocated to blockdevice pagecache". Usually this is filesystem metadata.

Quoted 8 lines

--- linux-2.6.12-rc2-mm3/fs/proc/proc_misc.c~count_bounce 2005-04-25 12:08:28.000000000 +0900
+++ linux-2.6.12-rc2-mm3-kamezawa/fs/proc/proc_misc.c 2005-04-25 16:06:39.000000000 +0900
@@ -114,7 +114,7 @@ static int uptime_read_proc(char *page,

return proc_calc_metrics(page, start, off, count, eof, len);
}
-
+extern atomic_t nr_bounce_pages;

Please always put extern declarations into .h files, with the declaration visible to the definition and to all users.

Quoted 1 line

+ "Bounce : %8lu kB\n"

There's an unneeded space in there.