[PATCH] perf/x86/intel/p4: Fix unused variable warning in p4_pmu_init()
From: Aldo Conte
Date: Thu Mar 19 2026 - 11:22:42 EST
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 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.
Running `make W=1` again resolves the error.
I was unable to test the patch because
i do not have the hardware.
Signed-off-by: Aldo Conte <aldocontelk@xxxxxxxxx>
---
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 e5fd7367e45d..dc2866ed2495 100644
--- a/arch/x86/events/intel/p4.c
+++ b/arch/x86/events/intel/p4.c
@@ -1383,7 +1383,7 @@ __init int p4_pmu_init(void)
memcpy(hw_cache_event_ids, p4_hw_cache_event_ids,
sizeof(hw_cache_event_ids));
- pr_cont("Netburst events, ");
+ pr_cont("Netburst events, (misc_enable: %08x:%08x), ", high, low);
x86_pmu = p4_pmu;
--
2.53.0