what clock is used by select()/HZ ?

From: Luigi Rizzo <rizzo_at_iet.unipi.it>
Date: Fri, 4 Sep 2009 21:57:18 +0200
Hi,
I am running a kernel (8.0) with HZ=5000 trying to generate
packets which are apart from each other by something that is
not an exact multiple of 1ms . I have a modified ping version
which essentially accepts a microsecond spec, loops around
select() and tries to send a packet at precise intervals
(taking care not to accumulate errors).

running it with
	./ping -i 0.050200 some.host
and looking at the tcpdump output captured on the same host, i see
that packets get out of the system at intervals that (according to
the tcpdump timestamps are .050121 (60% of them) or .050322 (40%
of them) seconds apart (values are scattered within 10us of each
of the two values).

Overall the average delta is correct, but individual samples are not.
The system reports the following values:

kern.timecounter.choice: TSC(-100) HPET(900) ACPI-safe(850) i8254(0) dummy(-1000000)
kern.timecounter.hardware: HPET
kern.timecounter.tc.i8254.frequency: 1193182
kern.timecounter.tc.HPET.frequency: 25000000
kern.timecounter.tc.ACPI-safe.frequency: 3579545
kern.timecounter.tc.TSC.frequency: 2314976129
kern.timecounter.tick: 5 # (not sure what this means)

The only way i can explain the differences in the delays is that
the internal value of HZ is slightly different than the correct
value (50121/50200 or 50322/50200 times 5000) due to some approximation
in the divider used to generate the peridic interrupt, whereas
gettimeofday() is reasonably correct and prevents the accumulation
of errors.

However, HPET (which seems to be the one used) is a multiple of 5000
so the divider should be correct, and i cannot figure out what other
clock source could cause, due to a rounding error in the divisor,
such a large difference (50121/50200 or 50322/50200)

Any ideas ?

	cheers
	luigi
Received on Fri Sep 04 2009 - 18:08:56 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:54 UTC