device polling and weird timer interrupt count from vmstat
olli at lurza.secnetix.de
Tue Sep 25 05:59:21 PDT 2007
Artem Kuchin wrote:
> I enabled device polling in the kernel, in nics and
> set HZ=1000.
HZ=1000 is the default anyway. You only need to set it
if you want a value other than 1000.
For example, on my notebook I have set HZ=600 because that
machine often used for various media playback (video).
600 is a multiple of 24, 25 and 30, which are common frame
rates of video files. Aligning the kernel's scheduling
quantum with the frame rate improves video playback.
On a very fast processor I would probably use HZ=1200,
but mine is only an older single-core.
> How, when i do
> omni2# vmstat -i
> i see
> interrupt total rate
> irq14: ata0 47 0
> irq15: ata1 41 0
> irq28: em0 2268 4
> irq72: twe0 58380 120
> cpu0: timer 965994 1995
> cpu3: timer 1 0
> cpu1: timer 1 0
> cpu2: timer 965857 1995
> Total 1992589 4116
Looks perfectly normal.
> What i don't understand is why timer rate on each cpu is 1995? I have
> set it to 1000, not 1995 or 2000. I have seen it showing 2000 on
> another box.
The timer frequencies are not necessarily the same as the
HZ setting. They are related, but don't have to be the
same. It depends on several things, in particular the type
of your processor and sysctl kern.timecounter settings.
There are several formulas, dependencies and requirements
for time counters. For example, the frequency must be
set so the counter does not roll over in less than about
max(2 msec, 2/HZ sec), which depends on the bit width of
the counter (see src/sys/sys/timetc.h). On the other
hand, you want a counter which runs as fast as possible,
so you get better precision for time keeping. For those
reasons the cpu timer can be set to a multiple of HZ.
I've made a quick survery on a few machines around me
(unless otherwise noted, all of these run FreeBSD/i386
6-stable and have the default of HZ=1000):
Pentium III, 800 MHz:
cpu0: timer 1893955760 1999
Xeon 5160, 3000 MHz:
cpu0: timer 2466663483 1996
Athlon64, 2200 MHz:
cpu0: timer 3964659397 960
Athlon64 X2, 2x 2000 MHz, 7-current:
cpu0: timer 847083650 2000
cpu1: timer 847081624 2000
VIA C3 Nehemiah, 1000 MHz, HZ=250:
irq0: clk 167288669 249
> 3) Is timer int really generated on each cpu? Am i really wasting cpu
> time on ~4000 ints per second?
4000 ints per second is rather nothing on any modern CPU.
Have a look at the top(1) display of an otherwise idle
system. The "%interrupt" column should be zero, even if
it's processing 4000 timer interrupts per second. As far
as I know, the cpu timer interrupt handler is very light-
> 4) does twe driver use polling? whay about twa?
No, they don't. They aren't even NIC drivers. Currently
polling is only implemented for (some of) the NIC drivers.
> how to check it in the sources?
The polling(4) manual page lists all supported devices.
Oliver Fromme, secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing b. M.
Handelsregister: Registergericht Muenchen, HRA 74606, Geschäftsfuehrung:
secnetix Verwaltungsgesellsch. mbH, Handelsregister: Registergericht Mün-
chen, HRB 125758, Geschäftsführer: Maik Bachmann, Olaf Erb, Ralf Gebhart
FreeBSD-Dienstleistungen, -Produkte und mehr: http://www.secnetix.de/bsd
"When your hammer is C++, everything begins to look like a thumb."
-- Steve Haflich, in comp.lang.c++
More information about the freebsd-stable