lkml.org 
[lkml]   [1999]   [Sep]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[patch] show_buffers() resurrection
With the buffer SMP threading show_buffers() is been removed from the
kernel. This patch will reinsert it. It's safe as it uses the trylock
type of spinlocks. I find it extremely useful to know what's going on in
the buffer layer.

Patch against 2.3.18ac1:

diff -urN 2.3.18ac1/arch/alpha/mm/init.c 2.3.18ac1-buffers/arch/alpha/mm/init.c
--- 2.3.18ac1/arch/alpha/mm/init.c Thu Aug 12 02:53:17 1999
+++ 2.3.18ac1-buffers/arch/alpha/mm/init.c Sun Sep 12 00:44:13 1999
@@ -166,6 +166,7 @@
printk("%ld pages shared\n",shared);
printk("%ld pages swap cached\n",cached);
printk("%ld pages in page table cache\n",pgtable_cache_size);
+ show_buffers();
#ifdef CONFIG_NET
show_net_buffers();
#endif
diff -urN 2.3.18ac1/arch/arm/mm/init.c 2.3.18ac1-buffers/arch/arm/mm/init.c
--- 2.3.18ac1/arch/arm/mm/init.c Wed Sep 8 00:25:39 1999
+++ 2.3.18ac1-buffers/arch/arm/mm/init.c Sun Sep 12 00:43:49 1999
@@ -115,6 +115,7 @@
printk("%d free pages\n",free);
printk("%d reserved pages\n",reserved);
printk("%d pages shared\n",shared);
+ show_buffers();
#ifdef CONFIG_NET
show_net_buffers();
#endif
diff -urN 2.3.18ac1/arch/i386/mm/init.c 2.3.18ac1-buffers/arch/i386/mm/init.c
--- 2.3.18ac1/arch/i386/mm/init.c Wed Sep 8 18:18:45 1999
+++ 2.3.18ac1-buffers/arch/i386/mm/init.c Sun Sep 12 00:43:26 1999
@@ -180,6 +180,7 @@
printk("%d pages shared\n",shared);
printk("%d pages swap cached\n",cached);
printk("%ld pages in page table cache\n",pgtable_cache_size);
+ show_buffers();
#ifdef CONFIG_NET
show_net_buffers();
#endif
diff -urN 2.3.18ac1/arch/m68k/mm/init.c 2.3.18ac1-buffers/arch/m68k/mm/init.c
--- 2.3.18ac1/arch/m68k/mm/init.c Wed Sep 8 18:18:46 1999
+++ 2.3.18ac1-buffers/arch/m68k/mm/init.c Sun Sep 12 00:43:11 1999
@@ -112,6 +112,7 @@
printk("%d pages shared\n",shared);
printk("%d pages swap cached\n",cached);
printk("%ld pages in page table cache\n",pgtable_cache_size);
+ show_buffers();
#ifdef CONFIG_NET
show_net_buffers();
#endif
diff -urN 2.3.18ac1/arch/mips/mm/init.c 2.3.18ac1-buffers/arch/mips/mm/init.c
--- 2.3.18ac1/arch/mips/mm/init.c Wed Sep 8 00:25:41 1999
+++ 2.3.18ac1-buffers/arch/mips/mm/init.c Sun Sep 12 00:42:53 1999
@@ -265,6 +265,7 @@
printk("%d pages swap cached\n",cached);
printk("%ld pages in page table cache\n",pgtable_cache_size);
printk("%d free pages\n", free);
+ show_buffers();
#ifdef CONFIG_NET
show_net_buffers();
#endif
diff -urN 2.3.18ac1/arch/ppc/mm/init.c 2.3.18ac1-buffers/arch/ppc/mm/init.c
--- 2.3.18ac1/arch/ppc/mm/init.c Sat Sep 11 02:47:53 1999
+++ 2.3.18ac1-buffers/arch/ppc/mm/init.c Sun Sep 12 00:42:25 1999
@@ -285,6 +285,7 @@
printk("%d pages shared\n",shared);
printk("%d pages swap cached\n",cached);
printk("%d pages in page table cache\n",(int)pgtable_cache_size);
+ show_buffers();
#ifdef CONFIG_NET
show_net_buffers();
#endif
diff -urN 2.3.18ac1/arch/sparc/mm/init.c 2.3.18ac1-buffers/arch/sparc/mm/init.c
--- 2.3.18ac1/arch/sparc/mm/init.c Sat Sep 11 02:47:53 1999
+++ 2.3.18ac1-buffers/arch/sparc/mm/init.c Sun Sep 12 00:42:09 1999
@@ -106,6 +106,7 @@
printk("%ld page tables cached\n",pgtable_cache_size);
if (sparc_cpu_model == sun4m || sparc_cpu_model == sun4d)
printk("%ld page dirs cached\n", pgd_cache_size);
+ show_buffers();
#ifdef CONFIG_NET
show_net_buffers();
#endif
diff -urN 2.3.18ac1/arch/sparc64/mm/init.c 2.3.18ac1-buffers/arch/sparc64/mm/init.c
--- 2.3.18ac1/arch/sparc64/mm/init.c Sat Sep 11 02:47:53 1999
+++ 2.3.18ac1-buffers/arch/sparc64/mm/init.c Sun Sep 12 00:41:53 1999
@@ -150,6 +150,7 @@
#ifndef __SMP__
printk("%d entries in page dir cache\n",pgd_cache_size);
#endif
+ show_buffers();
#ifdef CONFIG_NET
show_net_buffers();
#endif
diff -urN 2.3.18ac1/drivers/sgi/char/sgiserial.c 2.3.18ac1-buffers/drivers/sgi/char/sgiserial.c
--- 2.3.18ac1/drivers/sgi/char/sgiserial.c Wed Sep 8 00:26:00 1999
+++ 2.3.18ac1-buffers/drivers/sgi/char/sgiserial.c Sun Sep 12 00:41:26 1999
@@ -408,6 +408,7 @@
show_state();
return;
} else if (ch == 2) {
+ show_buffers();
return;
}
/* It is a 'keyboard interrupt' ;-) */
diff -urN 2.3.18ac1/fs/buffer.c 2.3.18ac1-buffers/fs/buffer.c
--- 2.3.18ac1/fs/buffer.c Sat Sep 11 16:33:32 1999
+++ 2.3.18ac1-buffers/fs/buffer.c Sun Sep 12 00:54:30 1999
@@ -2160,6 +2160,45 @@
goto out;
}

+/* ================== Debugging =================== */
+
+void show_buffers(void)
+{
+ struct buffer_head * bh;
+ int found = 0, locked = 0, dirty = 0, used = 0, lastused = 0;
+ int protected = 0;
+ int nlist;
+ static char *buf_types[NR_LIST] = { "CLEAN", "LOCKED", "DIRTY" };
+
+ printk("Buffer memory: %6dkB\n", atomic_read(&buffermem) >> 10);
+
+ if (!spin_trylock(&lru_list_lock))
+ return;
+ for(nlist = 0; nlist < NR_LIST; nlist++) {
+ found = locked = dirty = used = lastused = protected = 0;
+ bh = lru_list[nlist];
+ if(!bh) continue;
+
+ do {
+ found++;
+ if (buffer_locked(bh))
+ locked++;
+ if (buffer_protected(bh))
+ protected++;
+ if (buffer_dirty(bh))
+ dirty++;
+ if (atomic_read(&bh->b_count))
+ used++, lastused = found;
+ bh = bh->b_next_free;
+ } while (bh != lru_list[nlist]);
+ printk("%8s: %d buffers, %d used (last=%d), "
+ "%d locked, %d protected, %d dirty\n",
+ buf_types[nlist], found, used, lastused,
+ locked, protected, dirty);
+ }
+ spin_unlock(&lru_list_lock);
+}
+
/* ===================== Init ======================= */

/*
diff -urN 2.3.18ac1/include/linux/fs.h 2.3.18ac1-buffers/include/linux/fs.h
--- 2.3.18ac1/include/linux/fs.h Sun Sep 12 01:03:03 1999
+++ 2.3.18ac1-buffers/include/linux/fs.h Sun Sep 12 00:51:46 1999
@@ -937,6 +937,7 @@
unsigned long generate_cluster_swab32(kdev_t, int b[], int);
extern kdev_t ROOT_DEV;

+extern void show_buffers(void);
extern void mount_root(void);

#ifdef CONFIG_BLK_DEV_INITRD

Andrea


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:53    [from the cache]
©2003-2011 Jasper Spaans