@ljm
2018-05-07T16:09:10.000000Z
字数 886
阅读 1627
kernel-reading
perf stat -e cache-misses -I 1000 -p 2197
code: sys_perf_event_open
- https://www.processon.com/view/58a55155e4b0669d9942fdbe
static int perf_event_read_one(struct perf_event *event,
u64 read_format, char __user *buf)
{
u64 enabled, running;
u64 values[4];
int n = 0;
values[n++] = perf_event_read_value(event, &enabled, &running);
printk("<0>""liujunming perf_event_read_one value%llu\n", values[0]);
if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED)
values[n++] = enabled;
if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING)
values[n++] = running;
if (read_format & PERF_FORMAT_ID)
values[n++] = primary_event_id(event);
if (copy_to_user(buf, values, n * sizeof(u64)))
return -EFAULT;
return n * sizeof(u64);
}