arch/x86/events/intel/p4.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
Build the kernel with make W=1 generates the following warning:
arch/x86/events/intel/p4.c: In function ‘p4_pmu_init’:
arch/x86/events/intel/p4.c:1370:27: error: variable ‘high’ set but not used [-Werror=unused-but-set-variable]
1370 | unsigned int low, high;
| ^~~~
This happens because, although both variables are declared and
initialized by rdmsr, only `low` is used in the subsequent if statement.
This patch uses the rdmsrq() macro instead of the rdmsr() macro.
The rdmsrq() macro avoids the use of high and low variables
because it reads the msr value in a single u64 variable.
Also, replace (1 << 7) with the proper macro.
Running `make W=1` again resolves the error.
I was unable to test the patch because
i do not have the hardware.
Suggested-by: Dave Hansen <dave.hansen@linux.intel.com>
Signed-off-by: Aldo Conte <aldocontelk@gmail.com>
---
v2:
- Use of rdmsrq() instead of rdmsr() to read the full 64-bit MSR
in one single read avoiding the use of high and low.
- Replace (1 << 7) with the MSR_IA32_MISC_ENABLE_EMON
- Remove pr_cont() with MSR printout added in the previous patch
v1: https://lore.kernel.org/all/20260319152210.210854-1-aldocontelk@gmail.com/
arch/x86/events/intel/p4.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/x86/events/intel/p4.c b/arch/x86/events/intel/p4.c
index e5fd7367e45d..02bfdb77158b 100644
--- a/arch/x86/events/intel/p4.c
+++ b/arch/x86/events/intel/p4.c
@@ -1367,14 +1367,14 @@ static __initconst const struct x86_pmu p4_pmu = {
__init int p4_pmu_init(void)
{
- unsigned int low, high;
+ unsigned int misc;
int i, reg;
/* If we get stripped -- indexing fails */
BUILD_BUG_ON(ARCH_P4_MAX_CCCR > INTEL_PMC_MAX_GENERIC);
- rdmsr(MSR_IA32_MISC_ENABLE, low, high);
- if (!(low & (1 << 7))) {
+ rdmsrq(MSR_IA32_MISC_ENABLE, misc);
+ if (!(misc & MSR_IA32_MISC_ENABLE_EMON)) {
pr_cont("unsupported Netburst CPU model %d ",
boot_cpu_data.x86_model);
return -ENODEV;
--
2.53.0
On Fri, Mar 20, 2026 at 12:23:02PM +0100, Aldo Conte wrote: > Build the kernel with make W=1 generates the following warning: > > arch/x86/events/intel/p4.c: In function ‘p4_pmu_init’: > arch/x86/events/intel/p4.c:1370:27: error: variable ‘high’ set but not used [-Werror=unused-but-set-variable] > 1370 | unsigned int low, high; > | ^~~~ > > This happens because, although both variables are declared and > initialized by rdmsr, only `low` is used in the subsequent if statement. > > This patch uses the rdmsrq() macro instead of the rdmsr() macro. > The rdmsrq() macro avoids the use of high and low variables > because it reads the msr value in a single u64 variable. > Also, replace (1 << 7) with the proper macro. > > Running `make W=1` again resolves the error. > I was unable to test the patch because > i do not have the hardware. > > Suggested-by: Dave Hansen <dave.hansen@linux.intel.com> > Signed-off-by: Aldo Conte <aldocontelk@gmail.com> > --- > v2: > - Use of rdmsrq() instead of rdmsr() to read the full 64-bit MSR > in one single read avoiding the use of high and low. > - Replace (1 << 7) with the MSR_IA32_MISC_ENABLE_EMON > - Remove pr_cont() with MSR printout added in the previous patch > > v1: https://lore.kernel.org/all/20260319152210.210854-1-aldocontelk@gmail.com/ > arch/x86/events/intel/p4.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > In general I figure people using W=1 can keep the pieces, but the split msr interface is a relic, so yeah, lets clean this up. Thanks!
The following commit has been merged into the perf/core branch of tip:
Commit-ID: 6ee26b7a224b27aa7e8e1ee8a845a31664d2e97c
Gitweb: https://git.kernel.org/tip/6ee26b7a224b27aa7e8e1ee8a845a31664d2e97c
Author: Aldo Conte <aldocontelk@gmail.com>
AuthorDate: Fri, 20 Mar 2026 12:23:02 +01:00
Committer: Peter Zijlstra <peterz@infradead.org>
CommitterDate: Tue, 24 Mar 2026 15:11:42 +01:00
perf/x86/intel/p4: Fix unused variable warning in p4_pmu_init()
Build the kernel with make W=1 generates the following warning:
arch/x86/events/intel/p4.c: In function ‘p4_pmu_init’:
arch/x86/events/intel/p4.c:1370:27: error: variable ‘high’ set but not used [-Werror=unused-but-set-variable]
1370 | unsigned int low, high;
| ^~~~
This happens because, although both variables are declared and
initialized by rdmsr, only `low` is used in the subsequent if statement.
This patch uses the rdmsrq() macro instead of the rdmsr() macro.
The rdmsrq() macro avoids the use of high and low variables
because it reads the msr value in a single u64 variable.
Also, replace (1 << 7) with the proper macro.
Running `make W=1` again resolves the error.
I was unable to test the patch because
i do not have the hardware.
Suggested-by: Dave Hansen <dave.hansen@linux.intel.com>
Signed-off-by: Aldo Conte <aldocontelk@gmail.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://patch.msgid.link/20260320112302.281549-1-aldocontelk@gmail.com
---
arch/x86/events/intel/p4.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/x86/events/intel/p4.c b/arch/x86/events/intel/p4.c
index e5fd736..02bfdb7 100644
--- a/arch/x86/events/intel/p4.c
+++ b/arch/x86/events/intel/p4.c
@@ -1367,14 +1367,14 @@ static __initconst const struct x86_pmu p4_pmu = {
__init int p4_pmu_init(void)
{
- unsigned int low, high;
+ unsigned int misc;
int i, reg;
/* If we get stripped -- indexing fails */
BUILD_BUG_ON(ARCH_P4_MAX_CCCR > INTEL_PMC_MAX_GENERIC);
- rdmsr(MSR_IA32_MISC_ENABLE, low, high);
- if (!(low & (1 << 7))) {
+ rdmsrq(MSR_IA32_MISC_ENABLE, misc);
+ if (!(misc & MSR_IA32_MISC_ENABLE_EMON)) {
pr_cont("unsupported Netburst CPU model %d ",
boot_cpu_data.x86_model);
return -ENODEV;
© 2016 - 2026 Red Hat, Inc.