* [PATCH] perf/x86/p4: Fix "Wunused-but-set-variable" warning
@ 2023-10-07 18:55 Lucy Mielke
2023-10-07 20:34 ` Peter Zijlstra
0 siblings, 1 reply; 5+ messages in thread
From: Lucy Mielke @ 2023-10-07 18:55 UTC (permalink / raw)
To: peterz, mingo, acme, mark.rutland, alexander.shishkin, jolsa,
namhyung, irogers, adrian.hunter, tglx, bp, dave.hansen, x86, hpa
Cc: linux-perf-users, linux-kernel
This fixes a compiler warning when compiling an allyesconfig with W=1:
warning: variable ´high´ set but not used [-Wunused-but-set-variable]
Signed-off-by: Lucy Mielke <lucymielke@icloud.com>
---
arch/x86/events/intel/p4.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/events/intel/p4.c b/arch/x86/events/intel/p4.c
index 35936188db01..69aaf7c0f340 100644
--- a/arch/x86/events/intel/p4.c
+++ b/arch/x86/events/intel/p4.c
@@ -1366,7 +1366,7 @@ static __initconst const struct x86_pmu p4_pmu = {
__init int p4_pmu_init(void)
{
- unsigned int low, high;
+ unsigned int low, __maybe_unused high;
int i, reg;
/* If we get stripped -- indexing fails */
--
2.42.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] perf/x86/p4: Fix "Wunused-but-set-variable" warning
2023-10-07 18:55 [PATCH] perf/x86/p4: Fix "Wunused-but-set-variable" warning Lucy Mielke
@ 2023-10-07 20:34 ` Peter Zijlstra
2023-10-09 16:29 ` Sean Christopherson
0 siblings, 1 reply; 5+ messages in thread
From: Peter Zijlstra @ 2023-10-07 20:34 UTC (permalink / raw)
To: Lucy Mielke
Cc: mingo, acme, mark.rutland, alexander.shishkin, jolsa, namhyung,
irogers, adrian.hunter, tglx, bp, dave.hansen, x86, hpa,
linux-perf-users, linux-kernel
On Sat, Oct 07, 2023 at 08:55:19PM +0200, Lucy Mielke wrote:
> This fixes a compiler warning when compiling an allyesconfig with W=1:
> warning: variable ´high´ set but not used [-Wunused-but-set-variable]
What compiler and what .config?
> Signed-off-by: Lucy Mielke <lucymielke@icloud.com>
> ---
> arch/x86/events/intel/p4.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/x86/events/intel/p4.c b/arch/x86/events/intel/p4.c
> index 35936188db01..69aaf7c0f340 100644
> --- a/arch/x86/events/intel/p4.c
> +++ b/arch/x86/events/intel/p4.c
> @@ -1366,7 +1366,7 @@ static __initconst const struct x86_pmu p4_pmu = {
>
> __init int p4_pmu_init(void)
> {
> - unsigned int low, high;
> + unsigned int low, __maybe_unused high;
> int i, reg;
>
> /* If we get stripped -- indexing fails */
Right after this we have:
rdmsr(MSR_IA32_MISC_ENABLE, low, high);
which should get high unconditionally used. If there's a problem then
it's probably inside that rdmsr macro.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] perf/x86/p4: Fix "Wunused-but-set-variable" warning
2023-10-07 20:34 ` Peter Zijlstra
@ 2023-10-09 16:29 ` Sean Christopherson
2023-10-12 10:26 ` Lucy Mielke
0 siblings, 1 reply; 5+ messages in thread
From: Sean Christopherson @ 2023-10-09 16:29 UTC (permalink / raw)
To: Peter Zijlstra
Cc: Lucy Mielke, mingo, acme, mark.rutland, alexander.shishkin, jolsa,
namhyung, irogers, adrian.hunter, tglx, bp, dave.hansen, x86, hpa,
linux-perf-users, linux-kernel
On Sat, Oct 07, 2023, Peter Zijlstra wrote:
> On Sat, Oct 07, 2023 at 08:55:19PM +0200, Lucy Mielke wrote:
> > This fixes a compiler warning when compiling an allyesconfig with W=1:
> > warning: variable ´high´ set but not used [-Wunused-but-set-variable]
>
> What compiler and what .config?
>
> > Signed-off-by: Lucy Mielke <lucymielke@icloud.com>
> > ---
> > arch/x86/events/intel/p4.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/arch/x86/events/intel/p4.c b/arch/x86/events/intel/p4.c
> > index 35936188db01..69aaf7c0f340 100644
> > --- a/arch/x86/events/intel/p4.c
> > +++ b/arch/x86/events/intel/p4.c
> > @@ -1366,7 +1366,7 @@ static __initconst const struct x86_pmu p4_pmu = {
> >
> > __init int p4_pmu_init(void)
> > {
> > - unsigned int low, high;
> > + unsigned int low, __maybe_unused high;
> > int i, reg;
> >
> > /* If we get stripped -- indexing fails */
>
> Right after this we have:
>
> rdmsr(MSR_IA32_MISC_ENABLE, low, high);
>
> which should get high unconditionally used. If there's a problem then
> it's probably inside that rdmsr macro.
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)))
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] perf/x86/p4: Fix "Wunused-but-set-variable" warning
2023-10-09 16:29 ` Sean Christopherson
@ 2023-10-12 10:26 ` Lucy Mielke
2023-10-13 16:13 ` Sean Christopherson
0 siblings, 1 reply; 5+ messages in thread
From: Lucy Mielke @ 2023-10-12 10:26 UTC (permalink / raw)
To: Sean Christopherson
Cc: Peter Zijlstra, mingo, acme, mark.rutland, alexander.shishkin,
jolsa, namhyung, irogers, adrian.hunter, tglx, bp, dave.hansen,
x86, hpa, linux-perf-users, linux-kernel
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] perf/x86/p4: Fix "Wunused-but-set-variable" warning
2023-10-12 10:26 ` Lucy Mielke
@ 2023-10-13 16:13 ` Sean Christopherson
0 siblings, 0 replies; 5+ messages in thread
From: Sean Christopherson @ 2023-10-13 16:13 UTC (permalink / raw)
To: Lucy Mielke
Cc: Peter Zijlstra, mingo, acme, mark.rutland, alexander.shishkin,
jolsa, namhyung, irogers, adrian.hunter, tglx, bp, dave.hansen,
x86, hpa, linux-perf-users, linux-kernel
On Thu, Oct 12, 2023, Lucy Mielke wrote:
> 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?
Yep, which is the only reason I haven't force the issue.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-10-13 16:14 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-07 18:55 [PATCH] perf/x86/p4: Fix "Wunused-but-set-variable" warning Lucy Mielke
2023-10-07 20:34 ` Peter Zijlstra
2023-10-09 16:29 ` Sean Christopherson
2023-10-12 10:26 ` Lucy Mielke
2023-10-13 16:13 ` Sean Christopherson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).