lkml.org 
[lkml]   [1998]   [Jul]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectOldie but goodie patch for statistics..
Curious how efficient the dcache is?
Curious how well the fat cache is doing?
Say no more..

This patch is a few revisions old (made off 2.1.99 but patches cleanly into
the latest and greatest kernels) but it still works great.

Appends 3 lines to the /proc/stat file with dcache, buffer cache, and fat cache
hit and miss counts.. a trivial userspace program can figure out the
percentages for you (which I might be coding later tonite)

Have fun with it.. let me know your experiences with it.

--
Which is worse, ignorance or apathy? Who knows? Who cares?
IBM: It may be slow, but at least it's expensive.
Mir is the Russian word for 'duck-tape' - Dennis Miller
You've won Solitaire! For your high score to register, Win95 must be restarted.
--- linux/fs/fat/cache.c.virgin Tue May 5 01:52:58 1998
+++ linux/fs/fat/cache.c Tue May 5 01:54:13 1998
@@ -10,6 +10,7 @@
#include <linux/string.h>
#include <linux/stat.h>
#include <linux/fat_cvf.h>
+#include <linux/kernel_stat.h>

#include "msbuffer.h"

@@ -155,8 +156,10 @@
#ifdef DEBUG
printk("cache hit: %d (%d)\n",walk->file_cluster,*d_clu);
#endif
+ kstat.fat_hit++;
if ((*f_clu = walk->file_cluster) == cluster) return;
}
+ kstat.fat_miss++;
#ifdef DEBUG
printk("cache miss\n");
#endif
--- linux/fs/proc/array.c.virgin Tue May 5 01:57:24 1998
+++ linux/fs/proc/array.c Tue May 5 02:29:15 1998
@@ -296,10 +296,23 @@
len += sprintf(buffer + len,
"\nctxt %u\n"
"btime %lu\n"
- "processes %lu\n",
+ "processes %lu\n"
+ "bufcache %lu %lu\n"
+ "dircache %lu %lu\n"
+ "fatcache %lu %lu\n"
+ "smbcache %lu %lu\n",
kstat.context_swtch,
xtime.tv_sec - jiffies / HZ,
- total_forks);
+ total_forks,
+ kstat.buf_hit,
+ kstat.buf_miss,
+ kstat.dir_hit,
+ kstat.dir_miss,
+ kstat.fat_hit,
+ kstat.fat_miss,
+ kstat.smb_hit,
+ kstat.smb_miss
+);
return len;
}

--- linux/fs/smbfs/cache.c.virgin Tue May 5 01:50:38 1998
+++ linux/fs/smbfs/cache.c Tue May 5 01:52:23 1998
@@ -15,6 +15,7 @@
#include <linux/errno.h>
#include <linux/dirent.h>
#include <linux/smb_fs.h>
+#include <linux/kernel_stat.h>

#include <asm/page.h>

@@ -248,6 +249,11 @@
#endif
break;
}
+ if (offset == 0)
+ kstat.smb_miss++;
+ else
+ kstat.smb_hit++;
+
return offset;
}

--- linux/fs/dcache.c.virgin Tue May 5 01:35:02 1998
+++ linux/fs/dcache.c Tue May 5 01:39:04 1998
@@ -18,6 +18,7 @@
#include <linux/fs.h>
#include <linux/malloc.h>
#include <linux/init.h>
+#include <linux/kernel_stat.h>

#include <asm/uaccess.h>

@@ -560,8 +561,10 @@
if (memcmp(dentry->d_name.name, str, len))
continue;
}
+ kstat.dir_hit++;
return dget(dentry);
}
+ kstat.dir_miss++;
return NULL;
}

--- linux/fs/buffer.c.virgin Tue May 5 01:39:20 1998
+++ linux/fs/buffer.c Tue May 5 02:15:14 1998
@@ -43,6 +43,7 @@
#include <linux/sysrq.h>
#include <linux/file.h>
#include <linux/quotaops.h>
+#include <linux/kernel_stat.h>

#include <asm/system.h>
#include <asm/uaccess.h>
@@ -585,6 +586,12 @@
next = tmp;
break;
}
+
+ if (next)
+ kstat.buf_hit++;
+ else
+ kstat.buf_miss++;
+
return next;
}

--- linux/include/linux/kernel_stat.h.virgin Tue May 5 01:32:11 1998
+++ linux/include/linux/kernel_stat.h Tue May 5 01:54:42 1998
@@ -31,6 +31,10 @@
unsigned int ierrors, oerrors;
unsigned int collisions;
unsigned int context_swtch;
+ unsigned int buf_hit, buf_miss;
+ unsigned int dir_hit, dir_miss;
+ unsigned int fat_hit, fat_miss;
+ unsigned int smb_hit, smb_miss;
};

extern struct kernel_stat kstat;
\
 
 \ /
  Last update: 2005-03-22 13:43    [W:0.057 / U:0.044 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site