1

I enabled sampling on sched:sched_switch for each CPU and for a particular process.

My perf_event_attr:

    e_open->attr.disabled           = 1;
    e_open->attr.type               = PERF_TYPE_TRACEPOINT;
    e_open->attr.config             = 87;
    e_open->attr.size               = sizeof(e_open->attr);
    e_open->attr.sample_period      = 1;
    e_open->attr.inherit            = 1;
    e_open->attr.sample_type        = PERF_SAMPLE_TIME      |
                                      PERF_SAMPLE_RAW       |
                                      PERF_SAMPLE_CPU       |
                                      PERF_SAMPLE_TID       ;

Opening event:
cpu 0: perf_event_open(&e_open->attr,pid,0,-1,0)
cpu 1: perf_event_open(&e_open->attr,pid,1,-1,0)

But this doesnt give any data points.
So i checked using:

  bash-4.1# sudo perf stat -e sched:sched_switch sleep 1

  Performance counter stats for 'sleep 1':

             0 sched:sched_switch

  1.004714901 seconds time elapsed

Same here, no counts.

But using:

  bash-4.1# perf stat -e cs sleep 1

  Performance counter stats for 'sleep 1':

             1 cs

   1.003306642 seconds time elapsed

So, this gives me actual counts. I dont understand why sched:sched_switch doesnt give any. And, if there is any way to enable sampling for context switches for particular process.

0 Answers0