Skip to content

Read additional performance counters. #376

@vext01

Description

@vext01

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions