我在每个CPU和特定进程的sched:sched_switch上启用了采样。
我的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 ;
开幕活动:
cpu 0:perf_event_open(& e_open-> attr,pid,0,-1,0)
cpu 1:perf_event_open(& e_open-> attr,pid,1,-1,0)
但这并没有给出任何数据点
所以我检查使用:
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
同样,没有重要。
但使用:
bash-4.1# perf stat -e cs sleep 1
Performance counter stats for 'sleep 1':
1 cs
1.003306642 seconds time elapsed
所以,这给了我实际的数量。我不明白为什么sched:sched_switch不给任何。并且,如果有任何方法可以为特定进程启用上下文切换的采样。