[dtrace-discuss] sched provider - what do on-cpu & off-cpu signify?
Alexander Kolbasov
akolb at eng.sun.com
Fri Jul 20 17:27:02 PDT 2007
Tim,
you are observing the idle thread. Try adding
sched:::on-cpu
/(uintptr_t)curthread->t_startpc != (uintptr_t)`idle/
- akolb
> *,
>
> 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)?
More information about the dtrace-discuss
mailing list