Using sched cpucaps-sleep and cpucaps-wakeup

You can use cpucaps-sleep and cpucaps-wakeup probes to understand the impact CPU Caps have on specific processes and threads. The following example shows how much various processes spend on wait queues:

sched:::cpucaps-sleep
{
  sleep[args[1]->pr_pid] = timestamp;
}

sched:::cpucaps-wakeup
/sleep[args[1]->pr_pid]/
{
  @sleeps[args[1]->pr_fname] = quantize(timestamp - sleep[args[1]->pr_pid]);
  sleep[args[1]->pr_pid] = 0;
}

Running the preceding script results in output similar to the following example:

# dtrace -s /capswait.d
dtrace: script './capswait.d' matched 2 probes
^C

  exmh                                              
           value  ------------- Distribution ------------- count    
         8388608 |                                         0        
        16777216 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 4        
        33554432 |                                         0        

  scan                                              
           value  ------------- Distribution ------------- count    
        16777216 |                                         0        
        33554432 |@@@@@@@@@@@@@@@@@@@@                     1        
        67108864 |                                         0        
       134217728 |@@@@@@@@@@@@@@@@@@@@                     1        
       268435456 |                                         0        

  firefox-bin                                       
           value  ------------- Distribution ------------- count    
         4194304 |                                         0        
         8388608 |@@                                       1        
        16777216 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@      19       
        33554432 |@@@@                                     2        
        67108864 |                                         0