function_profile_enabled | 跟踪函数的profile |
kprobe_events | 创建event并跟踪,见kprobe |
实现文件 trace_kprobe.c |
主要参考函数为 __trace_kprobe_create arm64的实现时通过将原指令替换为BRK指令实现。 |
echo 'p task_tick_fair' > kprobe_events | 添加 task_tick_fair event,会生成 events/kprobes/p_task_tick_fair_0 |
echo '- task_tick_fair' > kprobe_events | 删除上面添加的event |
echo 'p task_tick_fair $arg1 $arg2 $arg3' > kprobe_events | task_tick_fair的定义为 task_tick_fair(struct rq *rq, struct task_struct *curr, int queued) 这里arg1对于与rq,arg2对应于curr,arg3对应与queued |
echo 'p task_tick_fair rq=$arg1 cur=$arg2 queued=$arg3' > kprobe_events | 同上,只是在显示时将arg1显示为rq,方便调试 |
echo 'r __pick_next_task_fair $retval' > kprobe_events | 添加 return probe,添加成功,但获取不到想要的结果 |
perf probe -x /home/xxx/test/a.out /home/xxx/test/main.c:4 argc argv k | 在main.c的第4行probe,打印出argc argv和k这三个参数 |
perf probe /home/xxx/test/a.out main argc argv | 在函数main的入口处probe,打印出argc和argv |
perf probe /home/xxx/test/a.out main:4 | 在main的第4行插入probe |
perf probe scheduler* | 在所有scheduler开头的函数入口处probe |
root@kickseed:~/test# perf probe -V do_sys_open Available variables at do_sys_open @<do_sys_open+0> char* filename int dfd int flags struct open_flags op umode_t mode |
查看do_sys_open有哪些变量可以在probe中使用 |
root@kickseed:~/test# perf probe -V do_sys_open --range Available variables at do_sys_open |
查看变量的有效范围 |
|
a.out-14389 [000] .... 2459018.446122: do_sys_open: (do_sys_open+0x0/0x2c0) filename_string="/lib/x86_64-linux-gnu/libdl.so.2" flags=557056 mode=0xff20 |
perf probe __pick_next_task_fair%return $retval | 添加ret probe,但没有返回值,待查 |
perf probe -k /userdata/vmlinux -m /mps/ko/cexxxxv100_isp.ko cnispCreatePipe pipe=viPipe attr='pstPipeAttr->u32Maxw' | perf向ko中添加kprobe event |
perf buildid-cache -a /mps/ko/ceisp.ko | 将ko加载到buildid中,路径是 /root/.debug/.build-id |
perf top --symbols kfree | // 仅显示指定的符号 |
|
添加一个synthetic event,统计latency。 |
|
统计schedule函数的执行时间,并在最大时做snapshot。 |