Hi,
I’m bearing down on a perf issue that I hope to avoid debugging kernel code to solve.
cat /etc/nv_tegra_release | head -n 1
# R24 (release), REVISION: 2.1, GCID: 8028265, BOARD: t210ref, EABI: aarch64, DATE: Thu Nov 10 03:51:59 UTC 2016
uname -a
Linux tegra-ubuntu 3.10.96-tegra #1 SMP PREEMPT Wed Nov 9 19:42:57 PST 2016 aarch64 aarch64 aarch64 GNU/Linux
perf_event_open doc: perf_event_open(2) - Linux manual page
To summarise: events opened (perf_event_open) with cpu=0, pid=-1 (to measure a performance counter for all PIDs on a CPU), return bogus data:
[INFO] [PERF] Parsing event id INSTR
[INFO] [PERF] ID 0x1
[INFO] [PERF] Opened for CPU 0 fd 43
[INFO] [PERF] Read 8 chars 0x7fffffff (2147483647) fd 43
[INFO] [PERF] Read 8 chars 0x0 (0) fd 43
[INFO] [PERF] Read 8 chars 0x0 (0) fd 43
while doing exactly the same, but for the calling process on all cpus (cpu=-1, pid=0), produces correct results:
[INFO] [PERF] Parsing event id INSTR
[INFO] [PERF] ID 0x1
[INFO] [PERF] Opened for CPU 0 fd 43
[INFO] [PERF] Read 8 chars 0xb67 (2919) fd 43
[INFO] [PERF] Read 8 chars 0x6f4 (1780) fd 43
[INFO] [PERF] Read 8 chars 0x7c3 (1987) fd 43
[INFO] [PERF] Read 8 chars 0x7f9 (2041) fd 43
I am already aware of some (possibly related) issues with perf and idle state power management on the CPU:
- https://devtalk.nvidia.com/default/topic/955554/jetson-tx1/performance-counters-reset-itself/post/4963456/#4963456
- https://devtalk.nvidia.com/default/topic/975769/collecting-cpu-performance-counters-for-tx1/
I also checked that the perf_event_paranoid value is -1 and also tried CAP_SYS_ADMIN.
Now stuck compiling kernels wildly looking for clues… any ideas?
Some excerpts from my code:
Opening perf counters work fine:
pattr = data->pattr[data->num_fds];
pattr->type = PERF_TYPE_RAW;
pattr->size = sizeof(struct perf_event_attr);
pattr->config = (uint64_t) id; // Set to cpu specifi event
pattr->sample_type = PERF_SAMPLE_READ;
pattr->sample_type = 0;
pattr->read_format = 0;
pattr->disabled = 0; // event count starts at once
pattr->inherit = 1;
pattr->enable_on_exec = 1;
pattr->pinned = 1; // always count; reads return eof when not running (read return 0)
ret = perf_event_open(pattr, -1, 0, data->group_fds[cpu], 0); // (pattr, pid, cpu, group, flags)
if(-1 == ret)
{
ERROR("event open %d (%s) group %d", cpu, strerror(errno), data->group_fds[cpu]);
}
…reading them also fine without any issues (no error flags, everything looks fine programatically).
Can supply some simplified sources if required…