Are hardware performance counters (PMU) in WSL2 physical or virtual? #14023
Unanswered
ZhenyuXiao
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello everyone,
I am trying to clarify the behavior of hardware performance counters (PMU) inside WSL2.
When I run Linux tools such as perf inside WSL2, I can see events listed and /sys/bus/event_source/devices/cpu/rdpmc reports 1, which means user‑space access to PMU is allowed.
However, I am not sure whether these counters reflect the physical CPU PMU directly, or if they are provided through a virtual PMU (vPMU) abstraction by Hyper‑V.
My use case is measuring function‑level performance events (e.g., cycles, instructions) in C code, so I need to know whether the values are accurate hardware counts or virtualization‑based approximations.
Questions:
In WSL2, are PMU events backed by the physical CPU counters, or are they virtualized by Hyper‑V?
If they are virtualized, which events are reliable (e.g., cycles, instructions) and which are simulated or unavailable?
Is there any official documentation or confirmation from Microsoft about PMU support in WSL2?
Thanks in advance for any clarification!
Beta Was this translation helpful? Give feedback.
All reactions