1

I am using Linux 5.8.18 to do performance tuning, then I hit a confusion.
PMU in X86 is limited resource, and perf is the tool to use the PMU to complete profiling/sampling.
IIRC, perf document says the PMU resource is being shared by different processes, so Linux kernel will keep/snapshot the PMCs during process scheduling.

To verify that PMU setting is process specific, I did following tests.
A process running in background to call perf API to enable and use X86 FIXed_Counter0 (instruction retired) (MSR 0x309) on CPU0.
Then in the bash, I rdmsr -p0 0x309, I found the counter is increasing when the process is running in the background.

I had thought that each process (A and Bash) should have its own snapshot of the PMC (FIXed_Counter0 in this case), but the test shows that the PMC is global visible...

I got really confused.

wangt13
  • 959
  • 7
  • 17
  • Can you share the code snippet you use to call the perf API that uses the fixed_counter0? – Arnabjyoti Kalita Jul 26 '21 at 07:23
  • After more tests, I found the MSR 0x38D (FIXED0_CONTROL) is process specific, which means process A called perf API to use counter FIXED0, so 0x38D is setup accordingly when process A is running. Other processes which don't use FIXED0 have MSR 0x38D = 0. Now the question is how Linux can make the 0x38D process specific (where it is in the process's context)? Thanks, – wangt13 Jul 29 '21 at 09:25

0 Answers0