From: Aldo Conte <aldocontelk@gmail.com>
To: Dave Hansen <dave.hansen@intel.com>,
peterz@infradead.org, mingo@redhat.com, acme@kernel.org,
namhyung@kernel.org, tglx@kernel.org, bp@alien8.de,
dave.hansen@linux.intel.com
Cc: mark.rutland@arm.com, alexander.shishkin@linux.intel.com,
jolsa@kernel.org, irogers@google.com, adrian.hunter@intel.com,
james.clark@linaro.org, hpa@zytor.com, x86@kernel.org,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
skhan@linuxfoundation.org
Subject: Re: [PATCH] perf/x86/intel/p4: Fix unused variable warning in p4_pmu_init()
Date: Thu, 19 Mar 2026 23:20:59 +0100 [thread overview]
Message-ID: <a8a8ad35-7e92-41ec-b6a5-b471a91811b2@gmail.com> (raw)
In-Reply-To: <cab98c76-9772-46f8-8830-68c7af453aaa@intel.com>
On 3/19/26 4:30 PM, Dave Hansen wrote:
> On 3/19/26 08:22, Aldo Conte wrote:
>> This patch prints the full content of Model-Specific Register
>> via `pr_cont` and so both the low and high part. It is also
>> very useful to have the contents of MSR_IA32_MISC_ENABLE
>> in dmesg for debugging purposes.
>
> I'd probably just switch it over to rdmsrq():
>
> unsigned int misc;
>
> rdmsr(MSR_IA32_MISC_ENABLE, misc);
>
> if (!(misc & MSR_IA32_MISC_ENABLE_EMON)) {
> ...
>
> I'm kinda surprised the compiler is complaining, though. I suspect we've
> got a ton of these around where one of the registers isn't used.
Okay, your comment actually caught my attention. I looked into it
further and noticed that `rdmsr` is defined as a macro in both
`arch/x86/include/asm/msr.h` and `/arch/x86/include/asm/paravirt.h`. In
the first header, however, the expansion shows that high and low are
evaluated as follows:
(void)((low) = (u32)__val); \
(void)((high) = (u32)(__val >> 32)); \
so with a sort of warning suppressor, whereas in the second header, the
(void) is not used.
Now, the file `arch/x86/events/intel/p4.c` includes `msr.h` and thus the
expansion of `rdmsr`, which in theory contains `void`.
However, scrolling through the msr.h file, you can see that if the
CONFIG_PARAVIRT_XXL configuration parameter is defined, then the second
header (paravirt.h) is included, which then causes rdmsr to expand to
#define rdmsr(msr, val1, val2) \
do { \
u64 _l = paravirt_read_msr(msr); \
val1 = (u32)_l; \
val2 = _l >> 32; \
} while (0)
Since there is no (void) in front of val1 and val2, this will trigger a
warning.
I admit I'm a novice in this field, so what do you suggest is the best
fix at this point?
Should I use the “warning suppressor" with something like
(void) val1 = (u32)_l; \
(void) val2 = _l >> 32; \
or implement the solution you suggested?
next prev parent reply other threads:[~2026-03-19 22:21 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-19 15:22 Aldo Conte
2026-03-19 15:30 ` Dave Hansen
2026-03-19 22:20 ` Aldo Conte [this message]
2026-03-19 22:24 ` Dave Hansen
2026-03-20 11:23 ` [PATCH v2] " Aldo Conte
2026-03-24 14:10 ` Peter Zijlstra
2026-03-24 14:15 ` [tip: perf/core] " tip-bot2 for Aldo Conte
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=a8a8ad35-7e92-41ec-b6a5-b471a91811b2@gmail.com \
--to=aldocontelk@gmail.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=bp@alien8.de \
--cc=dave.hansen@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=irogers@google.com \
--cc=james.clark@linaro.org \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=skhan@linuxfoundation.org \
--cc=tglx@kernel.org \
--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
Powered by JetHome