[netperf-talk] FreeBSD sysctl cpu utilization diffs
Rick Jones
rick.jones2 at hp.com
Fri Apr 14 13:31:32 PDT 2006
Andrew Gallatin wrote:
> I use the attached patch to netperf 2.4.1 to measure cpu utilization
> on FreeBSD. The existing method in 2.2.4 and 2.4.1 confused me, and I
> did not want to wait for a calibration period.
If the mechanism is what I think it was, basically, the idea was to
compare how fast something increments when the system is "idle" vs when
the system is running netperf. Hence the calibration period.
> The FreeBSD kern.cp_time is quite simple. It returns a copy of an
> array of counters maintained by the kernel. One of these counters is
> incremented stathz times per second on each processor. The choice of
> counter (user, nice, sys, intr, idle) depends on the state of the CPU
> when the stathz clock tick happens. This array is global (not
> per-CPU) and is protected by a spinlock in SMP versions of the FreeBSD
> kernel.
That just shows they haven't gotten to very high CPU counts yet :)
> See the statclock() routine in sys/kern/kern_clock.c
> (http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/kern/kern_clock.c?rev=1.187&content-type=text/x-cvsweb-markup)
>
> The patch simply takes a snapshot of the counters when the test
> starts, another snapshot when the test ends, and caclulates the
> CPU utilization by figuring out how much idle time there was as
> compared to the other, non-idle CPU states.
>
> I have tested my patch on FreeBSD 5.4 i386 UP, 6.0 i386 SMP, and
> 7.0 amd64 SMP and the CPU time reported by netperf agrees with
> the CPU time reported by the FreeBSD CPU monitoring tools (vmstat,
> systat -vm, iostat).
Since they are likely using the same mechanism I would hope so :)
What does it look like compared to the looper method? One of the
concerns I have about all these "statistical" sampling methods is
whether or not they remain accurate under a very high interrupt load
such as that produced by netperf.
Not that some of the non-statistical mechanisms upon which netperf
relies are golden either.
>
> I was not sure what calibrate_idle_rate() should return. As a
> stopgap, I had it return sysconf(_SC_CLK_TCK); like the linux
> procstat code, but I have no idea if that is correct, or if
> it even matters. I suspect that I just need to return a non-zero
> value.
For a CPU method that requires no calibration, it doesn't really matter
what is returned.
rick jones
>
> Thanks for listening,
>
> Drew
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> netperf-talk mailing list
> netperf-talk at netperf.org
> http://www.netperf.org/cgi-bin/mailman/listinfo/netperf-talk
More information about the netperf-talk
mailing list