Enabling hardware counter profiling
I encountered an issue when trying to do hardware counter profiling with gprofng. There is already a similar closed issue but I am not sure if this is related to my problem.
When running gprofng I get:
~$ gprofng collect app -h
Run "x86_64-linux-gnu-gprofng collect app --help" for a usage message.
HW counter profiling is not supported on this system
I'm on WSL2
~$ uname -r
5.15.167.4-microsoft-standard-WSL2
with Ubuntu:
~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 24.04.2 LTS
Release: 24.04
Codename: noble
My processor is a Intel Core Ultra 7 155H
~$ cat /proc/cpuinfo | grep "model name" | head -1
model name : Intel(R) Core(TM) Ultra 7 155H
I installed perf from source and it seems to be working generally, but I don't think I have hardware events available:
~$ perf list
List of pre-defined events (to be used in -e or -M):
alignment-faults [Software event]
bpf-output [Software event]
cgroup-switches [Software event]
context-switches OR cs [Software event]
cpu-clock [Software event]
cpu-migrations OR migrations [Software event]
dummy [Software event]
emulation-faults [Software event]
major-faults [Software event]
minor-faults [Software event]
page-faults OR faults [Software event]
task-clock [Software event]
tool:
duration_time
user_time
system_time
msr/tsc/ [Kernel PMU event]
rNNN [Raw hardware event descriptor]
cpu/t1=v1[,t2=v2,t3 ...]/modifier [Raw hardware event descriptor]
[(see 'man perf-list' on how to encode it)]
mem:<addr>[/len][:access] [Hardware breakpoint]
Error: failed to open tracing events directory
I also get the following message:
~$ dmesg | grep PMU
[ 0.128659] Performance Events: unsupported p6 CPU model 170 no PMU driver, software events only.
Is there a way how I can turn on hardware counter pofiling or is there a general problem with my system?
Logs are required for review from WSL team
If this a feature request, please reply with '/feature'. If this is a question, reply with '/question'. Otherwise please attach logs by following the instructions below, your issue will not be reviewed unless they are added. These logs will help us understand what is going on in your machine.
How to collect WSL logs
Download and execute collect-wsl-logs.ps1 in an administrative powershell prompt:
Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/collect-wsl-logs.ps1" -OutFile collect-wsl-logs.ps1
Set-ExecutionPolicy Bypass -Scope Process -Force
.\collect-wsl-logs.ps1
The script will output the path of the log file once done.
If this is a networking issue, please use collect-networking-logs.ps1, following the instructions here
Once completed please upload the output files to this Github issue.
Click here for more info on logging If you choose to email these logs instead of attaching to the bug, please send them to [email protected] with the number of the github issue in the subject, and in the message a link to your comment in the github issue and reply with '/emailed-logs'.
/question
Diagnostic information
Found '/question', adding tag 'question'
Could you try running wsl --update --pre-release to get to the latest WSL version, and then try and run the dmesg | grep PMU command again? I'm curious if kernel modules will help address this.
Performance Events: PMU not available due to virtualization, using software events only
Kernel 6.6.84.1-microsoft-standard-WSL2 and WSL version 2.5.6
After wsl --update --pre-release I am at
~$ uname -r
6.6.84.1-microsoft-standard-WSL2
But I still only have software events:
~$ dmesg | grep PMU
[ 0.062006] Performance Events: unsupported p6 CPU model 183 no PMU driver, software events only.
[ 0.134691] RAPL PMU: API unit is 2^-32 Joules, 0 fixed counters, 10737418240 ms ovfl timer
Just curious, should perf be part of the pre-release?
Because right now it isn't present on my system and I have to build it from source again.
See discussions here, they found that vm in hyper-v can support PMU, but wsl2 not.
I test 3 computers for wsl2 performance counters support, intel i5-11400 and amd r5-5600u are both OK, only the one with intel i9-12900H fails.
@craigloewen-msft This is a duplicate of #8155.
TL;DR: For Alderlake CPUs and later, Linux requires the arch_perfmon CPU feature to be available for supporting PMU.
Hyper-V supports this, but HCS and therefore also WSL for some reason don't support it. In theory, HCS also supports enabling perfmon features like Hyper-V, but when enabling any of them the VM creation fails for me with an error saying that enabling the feature is not supported.
Thank you! So that means right now that is expected behavior and there's nothing I could do except not using WSL?