Per-CPU VFS Namecache Effectiveness Statistics:
authorHiten Pandya <hmp@dragonflybsd.org>
Fri, 2 Apr 2004 05:46:03 +0000 (05:46 +0000)
committerHiten Pandya <hmp@dragonflybsd.org>
Fri, 2 Apr 2004 05:46:03 +0000 (05:46 +0000)
commit24e51f365f430d8752746f57569847b24b09b9ed
tree6ebe0c82c8e2c4ceff816a30833b136be475dcb2
parent9babcab8fc8b1a330e075c8e2ed1d3db572ff883
Per-CPU VFS Namecache Effectiveness Statistics:

* Convert nchstats into a CPU indexed array

* Export the per-CPU nchstats as a sysctl vfs.cache.nchstats
  and let user-land aggregate them.

* Add a function called kvm_nch_cpuagg() to libkvm; it is
  shared by systat(1) and vmstat(1) and the ncache-stats test
  program.  As the function name suggests, it aggregates
  the per-CPU nchstats.

* Move struct nchstats into a separate header to avoid
  header file namespace pollution; sys/nchstats.h.

* Keep a cached copy of the globaldata pointer in the VFS
  specific LOOKUP op, and use that to increment the
  namecache effectiveness counters (nchstats).

* Modify systat(1) and vmstat(1) to accomodate the new
  behavior of accessing nchstats.  Remove a (now) redundant
  sysctl to get the cpu count (hw.ncpu), instead we just divide
  the total length of the nchstats array returned by sysctl
  by sizeof(struct nchstats) to get the CPU count.

* Garbage-collect unused variables and fix nearby warnings
  in systat(1) an vmstat(1).

* Add a very-cool test program, that prints the nchstats
  per-CPU statistics to show CPU distribution.  Here is the
  output it generates on an 2-processor SMP machine:

  gray# ncache-stats
  VFS Name Cache Effectiveness Statistics
     4207370 total name lookups
  COUNTER             CPU-1       CPU-2           TOTAL
  goodhits            2477657     1060677         (3538334  )
  neghits             107531      47294           (154825   )
  badhits             28968       7720            (36688    )
  falsehits           0           0               (0        )
  misses              339671      137852          (477523   )
  longnames           0           0               (0        )
  passes 2            13104       6813            (19917    )
  2-passes            25134       15257           (40391    )

The SMP machine used for testing this commit was proudly presented
by David Rhodus <drhodus@dragonflybsd.org>.

Reviewed-by: Matthew Dillon <dillon@backplane.com>
15 files changed:
lib/libkvm/Makefile
lib/libkvm/kvm.h
lib/libkvm/kvm_util.c [new file with mode: 0644]
sys/kern/vfs_cache.c
sys/sys/globaldata.h
sys/sys/namei.h
sys/sys/nchstats.h [new file with mode: 0644]
sys/vfs/gnu/ext2fs/ext2_lookup.c
sys/vfs/isofs/cd9660/cd9660_lookup.c
sys/vfs/udf/udf_vnops.c
sys/vfs/ufs/ufs_lookup.c
test/pcpu/Makefile [new file with mode: 0644]
test/pcpu/ncache-stats.c [new file with mode: 0644]
usr.bin/systat/vmstat.c
usr.bin/vmstat/vmstat.c