Re: [PATCH v4] perf/x86/amd: Don't touch the Host-only bit inside the guest hypervisor

Peter Zijlstra
2022-03-24T10:42:40Z

On Sun, Mar 20, 2022 at 08:21:06AM +0800, Dongli Si wrote:

> @@ -1027,7 +1028,8 @@ void amd_pmu_enable_virt(void)
> {
> struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events);
>
> - cpuc->perf_ctr_virt_mask = 0;
> + if (hypervisor_is_type(X86_HYPER_NATIVE))
> + cpuc->perf_ctr_virt_mask = 0;

So I had to go and read the original commit to figure out wth this code
is supposed to be doing. I'm thinking this all can use a wee comment.

Also, the above is very ambiguous as to what it does. Specifically if we
don't set perf_ctr_virt_mask, then what is the actual value (yes, I
know, but its not very clear is it). Also, if we don't in fact change
perf_ctr_virt_mask then these following two lines:

>
> /* Reload all events */
> amd_pmu_disable_all();
amd_pmu_enable_all(0);

are somewhat completely pointless, no?

So can we please get a patch that clarifies things instead of making
things even more obscure?