hardware custom PMC probes
The Linux perf commands allows custom PMCs (performance monitoring counters) to be specified. For example, CPU_CLK_UNHALTED.THREAD_P, which is accessed via Event Select = 0x3c and Umask = 0x0:
perf stat -e r003c -a # r == raw mode
perf stat -e cpu/event=0x3c,umask=0x0/ -a
Flags can also be added, eg:
perf stat -e r003c:u -a # user-mode only
perf stat -e r003c:up -a # user-mode and first level of precise
perf stat -e r003c:upp -a # user-mode and second level of precise
All the PMCs are listed in the Intel 64 and IA-32 Architectures Software Developer's Manual Volume 3B: System Programming Guide, Part 2 and the BIOS and Kernel Developer's Guide (BKDG) For AMD Family 10h Processors. I last wrote about them here: http://www.brendangregg.com/perf.html#HardwareEvents
For this addition, we can discuss how best to present them, but here's a starting suggestion, where both forms are supported:
hardware:event=0x3c,umask=0x0: # default count
hardware:event=0x3c,umask=0x0:1000000 # specified count
hardware:event=0x3c,umask=0x0,flags=up: # example with flags
hardware:r003c: # default count
hardware:r003c:1000000 # specified count
hardware:r003c,flags=up: # example with flags
I think as version 1 of this change we should do the verbose version ("event=..."), and only do the raw version ("rMMEE") later on if people really need it.
Any chance to get this implemented ? That would really be useful. Unfortunately, my lack of C++ skills prevents me to come with a concrete solution proposal.
It's not on my list of things to fix, but it would be nice to have. Having a good usecase would also help to figure out the syntax for it.
Unfortunately, my lack of C++ skills prevents me to come with a concrete solution proposal.
I'd be happy to give some guidance / pointers and stuff to get to a working PR. I think this mostly boils down to extending the attach_point parser, https://github.com/iovisor/bpftrace/blob/master/src/ast/attachpoint_parser.cpp#L606 and the probe attach logic, https://github.com/iovisor/bpftrace/blob/master/src/attached_probe.cpp#L1149 . If you know a bit of C this part shouldn't be too hard :)