[pre-2.1.46-1] Dir/buffer/fat cache stat patch (slight return)

Aaron Tiensivu (tiensivu@pilot.msu.edu)
Fri, 18 Jul 1997 18:13:24 -0400


--OgqxwSJOaUobr8KG
Content-Type: text/plain; charset=us-ascii

Updated my handy-dandy statistic patch for 2.1.45 (and pre-2.1.46-1).
I'll be giving the new code a work-out this weekend to see just how
featureful this new kernel is.

Have fun :)

The biggest thing I notice about the new kernel is that opening a 2MB
mail folder with mutt is now instantaneous.. unreal.

Patch follows below.

--
Which is worse: ignorance or apathy?  Who knows?  Who cares?
Have cool, will travel.
There is no mojo from the mofo in the HoJo.
UNIX is user friendly. It's just selective about who its friends are.

--OgqxwSJOaUobr8KG Content-Type: text/plain; charset=us-ascii Content-Description: Hit/miss stat. patch for 2.1.45+ Content-Disposition: attachment; filename="hm-2.1.45.diff"

--- linux/fs/proc/array.c.virgin Fri Jul 18 17:58:35 1997 +++ linux/fs/proc/array.c Fri Jul 18 18:04:29 1997 @@ -28,6 +28,9 @@ * * Yves Arrouye : remove removal of trailing spaces in get_array. * <Yves.Arrouye@marin.fdn.fr> + * + * Aaron Tiensivu : added dir, buffer, and FAT buffer cache hits/misses. + * <tiensivu@pilot.msu.edu> */ #include <linux/types.h> @@ -252,10 +255,20 @@ len += sprintf(buffer + len, "\nctxt %u\n" "btime %lu\n" - "processes %lu\n", + "processes %lu\n" + "dircache %u %u\n" + "bufcache %u %u\n" + "fatcache %u %u\n", kstat.context_swtch, xtime.tv_sec - jiffies / HZ, - total_forks); + total_forks, + kstat.dirc_hit, + kstat.dirc_miss, + kstat.bufc_hit, + kstat.bufc_miss, + kstat.fatc_hit, + kstat.fatc_miss); + return len; } --- linux/fs/fat/cache.c.virgin Fri Jul 18 18:01:49 1997 +++ linux/fs/fat/cache.c Fri Jul 18 18:04:29 1997 @@ -9,6 +9,7 @@ #include <linux/errno.h> #include <linux/string.h> #include <linux/stat.h> +#include <linux/kernel_stat.h> #include "msbuffer.h" @@ -134,8 +135,12 @@ #ifdef DEBUG printk("cache hit: %d (%d)\n",walk->file_cluster,*d_clu); #endif - if ((*f_clu = walk->file_cluster) == cluster) return; + if ((*f_clu = walk->file_cluster) == cluster) { + kstat.fatc_hit++; + return; + } } + kstat.fatc_miss++; #ifdef DEBUG printk("cache miss\n"); #endif --- linux/fs/dcache.c.virgin Fri Jul 18 17:58:57 1997 +++ linux/fs/dcache.c Fri Jul 18 18:04:29 1997 @@ -17,6 +17,7 @@ #include <linux/mm.h> #include <linux/fs.h> #include <linux/malloc.h> +#include <linux/kernel_stat.h> /* * This is the single most critical data structure when it comes @@ -219,8 +220,10 @@ continue; if (memcmp(dentry->d_name.name, str, len)) continue; + kstat.dirc_hit++; return dentry; } + kstat.dirc_miss++; return NULL; } --- linux/include/linux/kernel_stat.h.virgin Fri Jul 18 18:01:27 1997 +++ linux/include/linux/kernel_stat.h Fri Jul 18 18:04:29 1997 @@ -25,6 +25,9 @@ unsigned int ierrors, oerrors; unsigned int collisions; unsigned int context_swtch; + unsigned int dirc_hit, dirc_miss; + unsigned int bufc_hit, bufc_miss; + unsigned int fatc_hit, fatc_miss; }; extern struct kernel_stat kstat; --- linux/fs/buffer.c.virgin Fri Jul 18 17:56:07 1997 +++ linux/fs/buffer.c Fri Jul 18 18:06:49 1997 @@ -37,6 +37,7 @@ #include <linux/vmalloc.h> #include <linux/blkdev.h> #include <linux/sysrq.h> +#include <linux/kernel_stat.h> #include <asm/system.h> #include <asm/uaccess.h> @@ -539,8 +540,11 @@ next = tmp->b_next; if (tmp->b_blocknr != block || tmp->b_size != size || tmp->b_dev != dev) continue; + + kstat.bufc_hit++; return tmp; } + kstat.bufc_miss++; return NULL; }

--OgqxwSJOaUobr8KG--