[dtrace-discuss] sched provider - what do on-cpu & off-cpu signify?

Peter Lawrence Peter.Lawrence at Sun.COM
Fri Jul 20 18:21:46 PDT 2007


Tim,
    the "idle loop" is actually a separate thread in the kernel,
so the system is almost always on _some_ thread ~!~ (in fact I
have a hard time imagining what your system was doing in the other
10% of its time...)

here's what I do, even though some folks don't like its coefficient
of Interface Stability...


in S-11, and newer S-10, the functions named

	fbt:::idle_enter()
and
	fbt:::idle_exit()

are called by the Solaris idle loop in the order suggested by
their names.


YMMV, but this is "openSolaris" so you can always verify it with
the actual idle loop source code any time you want. on the other
hand if the folks hadn't made the comment to me I would have given you
the wrong function names (see pps below), so they do have a point ~!~


-Pete Lawrence.



ps, the "idle" loop can be quite active!, searching the ready queue
for scheduled/runable threads...


pps, in S-9, and older S-10, the functions are named

	fbt:::set_cpu_idle()
and
	fbt:::unset_cpu_idle()

don'cha just love backwards compatability...!...









Cook - PAE wrote On 07/20/07 05:06 PM,:
> *,
> 
> So, I was reading the definition of sched:::on-cpu and sched:::off-cpu
> to mean that any thread dispatched on a CPU would have that activity
> bounded by on-cpu and off-cpu firings, and that the use of "timestamp"
> between these points would accurately show how much CPU the thread was
> using.
> 
> My prototype script gets a little over 90% on a nearly idle system, though (this 
> system has 2 CPUs, BTW):
> 
> $ cat on-off.d
> #!/usr/sbin/dtrace -s
> 
> #pragma D option quiet
> 
> int64_t start_bolt;
> uint64_t start_n;
> int64_t util;
> 
> BEGIN
> {
>          start_bolt = `lbolt64;
>          start_n = timestamp;
>          util = 0;
> }
> 
> sched:::on-cpu
> {
>          self->on_n = timestamp;
> }
> 
> 
> sched:::off-cpu
> /self->on_n/
> {
>          util += timestamp - self->on_n;
>          self->on_n = 0;
> }
> 
> profile:::tick-5s
> {
>          printf("elapsed (ticks): %ld\n", `lbolt64 - start_bolt);
>          printf("elapsed (ns)   : %lu\n", timestamp - start_n);
>          printf("util (ns)      : %ld\n", util);
>          start_bolt = `lbolt64;
>          start_n = timestamp;
>          util = 0;
> }
> 
> 
> 
> mashie[bash]# ./on-off.d
> elapsed (ticks): 498
> elapsed (ns)   : 4979669863
> util (ns)      : 9137442436
> elapsed (ticks): 500
> elapsed (ns)   : 5000000822
> util (ns)      : 9185407490
> elapsed (ticks): 500
> elapsed (ns)   : 4999999221
> util (ns)      : 9157844649
> 
> 
> mashie[bash]# vmstat 5 4		(run at the same time)
> mashie ) vmstat 5 4
>   kthr      memory            page            disk          faults      cpu
>   r b w   swap  free  re  mf pi po fr de sr s0 s1 -- --   in   sy   cs us sy id
>   0 0 0 815384 906900  2  16  7  1  1  0  6  1 -5  0  0  646 1605  816  6  4 90
>   0 0 0 625700 706632  0   6  0  0  0  0  0  0  0  0  0  848  880  628  2  2 97
>   0 0 0 625700 706632  0   0  0  0  0  0  0  0  0  0  0  850  909  659  2  2 96
>   0 0 0 625700 706632  0   0  0  0  0  0  0  0  0  0  0  869 1297  823  2  2 96
> 
> 
> Does on-cpu, off-cpu also pick up when threads are in idle()?  If so, what is 
> the best way to exclude that (just put clauses on fbt::idle)?
> 
> Thanks,
> Tim
> 
> 



More information about the dtrace-discuss mailing list