[RFC][PATCH] counting bounce pages.

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[RFC][PATCH] counting bounce pages.

KAMEZAWA Hiroyuki
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 <[hidden email]>



count the number of bounce pages.

Signed-off-by: KAMEZAWA Hiroyuki <[hidden email]>



---

 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(-)

diff -puN mm/highmem.c~count_bounce mm/highmem.c
--- linux-2.6.12-rc2-mm3/mm/highmem.c~count_bounce 2005-04-25 12:04:28.000000000 +0900
+++ linux-2.6.12-rc2-mm3-kamezawa/mm/highmem.c 2005-04-25 16:10:52.000000000 +0900
@@ -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;
diff -puN fs/proc/proc_misc.c~count_bounce fs/proc/proc_misc.c
--- 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;
 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),

_
Reply | Threaded
Open this post in threaded view
|

Re: [RFC][PATCH] counting bounce pages.

Andrew Morton-8
KAMEZAWA Hiroyuki <[hidden email]> wrote:
>
> 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.

>  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.

>  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.

>  --- 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.

>  + "Bounce :      %8lu kB\n"

There's an unneeded space in there.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/