-
Notifications
You must be signed in to change notification settings - Fork 10
Description
[This issue is the outcome of a discussion at a softdev thrash]
The Idea
On modern Intel CPUs there are 8 programmable performance counters which can be used to measure things like:
- Number of cache hit/misses (at varying L-levels).
- Number of branch predilections.
- ...
Krun could collect some of this stuff and it may help in diagnosing odd behaviours.
How
The programmable performance counters can be read from userspace if a flag in an MSR is set (and I think there's a Linux /proc or /sys node to enable it too). However in order to be able to read the counter for the specified core, you would need a way to force the instruction execute on a given core. This can be done with:
cpu_set_affinity()from user space.smp_call_function_single()from the kernel.
[We already have code in the kernel to do the latter for a couple of fixed-function performance counters (albeit via MSRs, just because we could), but also to read APERF and MPERF.]