Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read additional performance counters. #376

Open
vext01 opened this issue May 29, 2018 · 0 comments
Open

Read additional performance counters. #376

vext01 opened this issue May 29, 2018 · 0 comments

Comments

@vext01
Copy link
Member

vext01 commented May 29, 2018

[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.]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant