Re: [PATCH] perf/x86/p4: Fix "Wunused-but-set-variable" warning

From: Lucy Mielke
Date: Thu Oct 12 2023 - 06:26:59 EST


Am Mon, Oct 09, 2023 at 09:29:50AM -0700 schrieb Sean Christopherson:
>
> rdmsr() writes to "high", but nothing ever reads from high. FWIW, I would _love_
> for rdmsrl() to have return semantics, e.g. to be able to do:
>
> low = (u32)rdmsrl(MSR_IA32_MISC_ENABLE);
>
> or even
>
> if (!(rdmsrl(MSR_IA32_MISC_ENABLE) & BIT(7)))

I have taken a look and it seems to me like this macro is called quite a lot
for different things thoughout the kernel tree, including drivers. If
one were to change it to have return semantics instead of the way it
currently works, you'd have to change around 300 occurences, right?
(Let me know if I misunderstood something.)

Return semantics or not, since the only way "high" is used in p4_pmu_init()
is by being written to by rdmsr(), the variable can be completely removed by
just using rdmsrl(). Would this be a patch you'd be interested in?

Mit freundlichen Grüßen / Best regards,
Lucy