[关闭]
@ljm 2018-05-07T16:09:10.000000Z 字数 886 阅读 1627

perf源码解析

kernel-reading


perf stat -e cache-misses -I 1000 -p 2197

sys_perf_event_open

code: sys_perf_event_open
- https://www.processon.com/view/58a55155e4b0669d9942fdbe

  1. static int perf_event_read_one(struct perf_event *event,
  2. u64 read_format, char __user *buf)
  3. {
  4. u64 enabled, running;
  5. u64 values[4];
  6. int n = 0;
  7. values[n++] = perf_event_read_value(event, &enabled, &running);
  8. printk("<0>""liujunming perf_event_read_one value%llu\n", values[0]);
  9. if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED)
  10. values[n++] = enabled;
  11. if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING)
  12. values[n++] = running;
  13. if (read_format & PERF_FORMAT_ID)
  14. values[n++] = primary_event_id(event);
  15. if (copy_to_user(buf, values, n * sizeof(u64)))
  16. return -EFAULT;
  17. return n * sizeof(u64);
  18. }
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注