[Libsysio-commit] HEAD: libsysio/src inode.c
Brought to you by:
lward
From: Lee W. <lw...@us...> - 2008-03-04 15:24:13
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4108/src Modified Files: inode.c Log Message: All cache stats now kept in a record instead of as separate file-scoped globals. Index: inode.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/inode.c,v retrieving revision 1.34 retrieving revision 1.35 diff -u -w -b -B -p -r1.34 -r1.35 --- inode.c 20 Nov 2007 18:01:42 -0000 1.34 +++ inode.c 4 Mar 2008 15:24:05 -0000 1.35 @@ -115,9 +115,35 @@ struct pnodes_head _sysio_idle_pnodes; struct pnode *_sysio_root = NULL; #ifdef I_STATS -static unsigned long i_probes, i_hits; -static unsigned long pb_probes, pb_hits; -static unsigned long p_reclaims, p_examined, p_dismissed; +#define INO_CACHE_STATS +#endif + +#ifdef INO_CACHE_STATS +static struct { + unsigned long long cst_iprobes; + unsigned long long cst_ihits; + unsigned long long cst_pbprobes; + unsigned long long cst_pbhits; + unsigned long long cst_preclaims; + unsigned long long cst_pexamined; + unsigned long long cst_pdismissed; +} cstats; + +static void +ino_cstats_init() +{ + + cstats.cst_iprobes = cstats.cst_ihits = 0; + cstats.cst_pbprobes = cstats.cst_pbhits = 0; + cstats.cst_preclaims = + cstats.cst_pexamined = + cstats.cst_pdismissed = 0; +} + +#define INO_CST_UPDCNT(__which) \ + do { \ + (cstats.cst_##__which)++; \ + } while (0) #endif /* @@ -138,10 +164,8 @@ _sysio_i_init() max_names = desired_names; -#ifdef I_STATS - i_probes = i_hits = 0; - pb_probes = pb_hits = 0; - p_reclaims = p_examined = p_dismissed = 0; +#ifdef INO_CACHE_STATS + ino_cstats_init(); #endif return 0; @@ -270,15 +294,11 @@ _sysio_i_find(struct filesys *fs, struct fid->fid_data, fid->fid_len) == 0) { I_REF(ino); -#ifdef I_STATS - i_hits++; -#endif + INO_CST_UPDCNT(ihits); break; } -#ifdef I_STATS - i_probes++; -#endif + INO_CST_UPDCNT(iprobes); return ino; } @@ -344,17 +364,13 @@ p_reclaim(unsigned count) if (count) adjust = 1; -#ifdef I_STATS - p_reclaims++; -#endif + INO_CST_UPDCNT(preclaims); next = _sysio_idle_pnodes.tqh_first; if (!next) return; t = n_names / 2; do { -#ifdef I_STATS - p_examined++; -#endif + INO_CST_UPDCNT(pexamined); pno = next; next = pno->p_idle.tqe_next; if (pno->p_ref) @@ -366,9 +382,7 @@ p_reclaim(unsigned count) continue; } nxtpb = pno->p_base; -#ifdef I_STATS - p_dismissed++; -#endif + INO_CST_UPDCNT(pdismissed); _sysio_p_gone(pno); /* * Have to run up the tree, too. We might @@ -593,11 +607,17 @@ void _sysio_i_shutdown() { -#ifdef I_STATS - _sysio_cprintf("inode: probe %lu, hit %lu\n", i_probes, i_hits); - _sysio_cprintf("pbnode: probe %lu, hit %lu\n", pb_probes, pb_hits); - _sysio_cprintf("pnode: reclaims %lu, examined %lu dismissed %lu\n", - p_reclaims, p_examined, p_dismissed); +#ifdef INO_CACHE_STATS + _sysio_cprintf("inode: probe %llu, hit %llu\n", + cstats.cst_iprobes, + cstats.cst_ihits); + _sysio_cprintf("pbnode: probe %llu, hit %llu\n", + cstats.cst_pbprobes, + cstats.cst_pbhits); + _sysio_cprintf("pnode: reclaims %llu, examined %llu dismissed %llu\n", + cstats.cst_preclaims, + cstats.cst_pexamined, + cstats.cst_pdismissed); #endif max_names = desired_names; @@ -705,16 +725,12 @@ _sysio_p_find_alias(struct pnode *parent /* * Try the names table. */ -#ifdef I_STATS - pb_probes++; -#endif + INO_CST_UPDCNT(pbprobes); key.pbk_name = *name; key.pbk_parent = parent->p_base; pb = ncache_lookup(&key); -#ifdef I_STATS if (pb) - pb_hits++; -#endif + INO_CST_UPDCNT(pbhits); } if (!pb) { /* |