Per CPU cpu-statistics under SMP

Marco van Tol marco at tols.org
Thu Apr 20 22:40:54 UTC 2006


On Wed, Apr 19, 2006 at 07:26:27AM +0000, Marco van Tol wrote:
> On Tue, Apr 18, 2006 at 06:38:26PM -0400, John Baldwin wrote:

[...]

> > Ah, hmm.  On 6.x we don't have per-thread stat ticks yet, which is
> > probably why it is failing.  It also isn't safe to move sched_lock
> > down either on 6.x.  You can still apply the rest of the patch by
> > hand, just leave the 'mtx_lock_spin(&sched_lock)' where it is and
> > change all the 'cp_time[FOO]++' to 'PCPU_LAZY_INC(cp_time[FOO])'.
> 
> OK, thanks.
> 
> What I will do is replace my gentoo partition with a BSD current partition
> so I don't loose my workstation as it were, and use that to work on this.
> 
> Will let you know how that goes.  Thanks.

Ha! It succeeded. :)

For additional information:
- I'm running an Athlon64 X2 4200+ in 64bit mode.
  (I won't start about the nvidia controller it also has ;)
- I'm using the SCHED_ULE scheduler (Does that make a difference for this?)
- All patching took place against todays CURRENT.
- I manually patched the first hunk of kern_clock.c, as the rest of the
  hunks succeeded on their own. (Hadn't used .rej files much before, but
  they're very usefull :)

Thank you very much!
I think this should suffice for what I intend to do to gkrellm for now.

If you want any additional information from me, or if you want me to test
other patches, I'd be more then happy to supply/try it/them.

Here's the result:
-----< cut here >-----
1:0[marco at donald marco]sysctl hw.ncpu
hw.ncpu: 2
-----< cut here >-----
1:0[marco at donald marco]for (( i = 0 ; $i < 10 ; i++ )) ; do sysctl kern.pcpu_time kern.cp_time ; sleep 1 ; echo -- ; done
kern.pcpu_time: 156 0 397 225 20542 21 0 30 0 21259
kern.cp_time: 177 0 427 225 41801
--
kern.pcpu_time: 156 0 397 225 20675 21 0 30 0 21392
kern.cp_time: 177 0 427 225 42067
--
kern.pcpu_time: 157 0 398 225 20807 21 0 30 0 21526
kern.cp_time: 178 0 428 225 42333
--
kern.pcpu_time: 157 0 398 225 20940 21 0 30 0 21659
kern.cp_time: 178 0 428 225 42599
--
kern.pcpu_time: 157 0 398 225 21074 21 0 30 0 21793
kern.cp_time: 178 0 428 225 42867
--
kern.pcpu_time: 157 0 398 225 21207 21 0 30 0 21926
kern.cp_time: 178 0 428 225 43133
--
kern.pcpu_time: 157 0 398 225 21340 21 0 30 0 22059
kern.cp_time: 178 0 428 225 43399
--
kern.pcpu_time: 157 0 399 225 21473 21 0 30 0 22193
kern.cp_time: 178 0 429 225 43666
--
kern.pcpu_time: 157 0 399 225 21606 21 0 30 0 22326
kern.cp_time: 178 0 429 225 43932
--
kern.pcpu_time: 157 0 399 225 21740 21 0 30 0 22460
kern.cp_time: 178 0 429 225 44200
--
0:0[marco at donald marco]
-----< cut here >-----

Marco

-- 
The difference between theory and practice
is a lot bigger in practice then in theory
- Peter van der Linden in `Deep C Secrets'


More information about the freebsd-hackers mailing list