linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Lucy Mielke <lucymielke@icloud.com>,
	mingo@redhat.com, acme@kernel.org,  mark.rutland@arm.com,
	alexander.shishkin@linux.intel.com, jolsa@kernel.org,
	 namhyung@kernel.org, irogers@google.com,
	adrian.hunter@intel.com,  tglx@linutronix.de, bp@alien8.de,
	dave.hansen@linux.intel.com, x86@kernel.org,  hpa@zytor.com,
	linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] perf/x86/p4: Fix "Wunused-but-set-variable" warning
Date: Mon, 9 Oct 2023 09:29:50 -0700	[thread overview]
Message-ID: <ZSQqfr96SfZM_OEk@google.com> (raw)
In-Reply-To: <20231007203411.GA8085@noisy.programming.kicks-ass.net>

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)))

  reply	other threads:[~2023-10-09 16:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2023-10-12 10:26     ` Lucy Mielke
2023-10-13 16:13       ` Sean Christopherson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZSQqfr96SfZM_OEk@google.com \
    --to=seanjc@google.com \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=irogers@google.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=lucymielke@icloud.com \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).