systimer: Fix statclock() intr% counting for i8254 interrupt cputimer
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Thu, 14 Apr 2011 05:10:55 +0000 (13:10 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Thu, 14 Apr 2011 05:10:55 +0000 (13:10 +0800)
commit96d52ac818036eee9591e612e829d78217bd2d3b
treeb1d19941fdc0baf38641c777083fc95dd5f2fb72
parent75a0ef5d8b4b2c0c80e5951e8e0b65b0958aab15
systimer: Fix statclock() intr% counting for i8254 interrupt cputimer

If i8254 is used as interrupt cputimer, it will send IPIs to APs to get
statclock() called.  In order to detect fast interrupt, statclock()
tests gd_intr_nesting_level to see whether it should bump intr% or not,
however, during IPI processing, gd_intr_nesting_level is bumped up, which
tricks statclock() to believe that intr% should be incremented.  This
usually leads to 100% interrupt time on APs reported by utilities like
systat(1).  To solve this problem:

- Pass in_ipi to systimer functions to indicate whether the functions are
  called during IPI processing or not.
- In statclock(): if it is called during IPI processing, using
  (gd_intr_nesting_level - 1) to test whether intr% should be incremented
  or not.

Additional cleanup:
- Make systimer_init_*() interface stricter, by using "systimer_func_t"
  instead of "void *"
12 files changed:
sys/cpu/i386/include/cpu.h
sys/cpu/x86_64/include/cpu.h
sys/kern/kern_clock.c
sys/kern/kern_intr.c
sys/kern/kern_poll.c
sys/kern/kern_systimer.c
sys/kern/kern_time.c
sys/net/dummynet/ip_dummynet.c
sys/net/if_poll.c
sys/platform/pc32/isa/clock.c
sys/platform/pc64/isa/clock.c
sys/sys/systimer.h