Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

perf/x86/intel, x86/cpu: Simplify Intel PMU initialization

Architectural Perfmon was introduced on the Family 6 "Core" processors
starting with Yonah. Processors before Yonah need their own customized
PMU initialization.

p6_pmu_init() is expected to provide that initialization for early
Family 6 processors. But, currently, it could get called for any Family
6 processor if the architectural perfmon feature is disabled on that
processor. To simplify, restrict the P6 PMU initialization to early
Family 6 processors that do not have architectural perfmon support and
truly need the special handling.

As a result, the "unsupported" console print becomes practically
unreachable because all the released P6 processors are covered by the
switch cases. Move the console print to a common location where it can
cover all modern processors (including Family >15) that may not have
architectural perfmon support enumerated.

Also, use this opportunity to get rid of the unnecessary switch cases in
P6 initialization. Only the Pentium Pro processor needs a quirk, and the
rest of the processors do not need any special handling. The gaps in the
case numbers are only due to no processor with those model numbers being
released.

Use decimal numbers to represent Intel Family numbers. Also, convert one
of the last few Intel x86_model comparisons to a VFM-based one.

Signed-off-by: Sohil Mehta <sohil.mehta@intel.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Reviewed-by: Kan Liang <kan.liang@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20250318223828.2945651-2-sohil.mehta@intel.com

authored by

Sohil Mehta and committed by
Ingo Molnar
8b70c743 24a295e4

+13 -27
+10 -4
arch/x86/events/intel/core.c
··· 6541 6541 char *name; 6542 6542 struct x86_hybrid_pmu *pmu; 6543 6543 6544 + /* Architectural Perfmon was introduced starting with Core "Yonah" */ 6544 6545 if (!cpu_has(&boot_cpu_data, X86_FEATURE_ARCH_PERFMON)) { 6545 6546 switch (boot_cpu_data.x86) { 6546 - case 0x6: 6547 - return p6_pmu_init(); 6548 - case 0xb: 6547 + case 6: 6548 + if (boot_cpu_data.x86_vfm < INTEL_CORE_YONAH) 6549 + return p6_pmu_init(); 6550 + break; 6551 + case 11: 6549 6552 return knc_pmu_init(); 6550 - case 0xf: 6553 + case 15: 6551 6554 return p4_pmu_init(); 6552 6555 } 6556 + 6557 + pr_cont("unsupported CPU family %d model %d ", 6558 + boot_cpu_data.x86, boot_cpu_data.x86_model); 6553 6559 return -ENODEV; 6554 6560 } 6555 6561
+3 -23
arch/x86/events/intel/p6.c
··· 2 2 #include <linux/perf_event.h> 3 3 #include <linux/types.h> 4 4 5 + #include <asm/cpu_device_id.h> 6 + 5 7 #include "../perf_event.h" 6 8 7 9 /* ··· 250 248 { 251 249 x86_pmu = p6_pmu; 252 250 253 - switch (boot_cpu_data.x86_model) { 254 - case 1: /* Pentium Pro */ 251 + if (boot_cpu_data.x86_vfm == INTEL_PENTIUM_PRO) 255 252 x86_add_quirk(p6_pmu_rdpmc_quirk); 256 - break; 257 - 258 - case 3: /* Pentium II - Klamath */ 259 - case 5: /* Pentium II - Deschutes */ 260 - case 6: /* Pentium II - Mendocino */ 261 - break; 262 - 263 - case 7: /* Pentium III - Katmai */ 264 - case 8: /* Pentium III - Coppermine */ 265 - case 10: /* Pentium III Xeon */ 266 - case 11: /* Pentium III - Tualatin */ 267 - break; 268 - 269 - case 9: /* Pentium M - Banias */ 270 - case 13: /* Pentium M - Dothan */ 271 - break; 272 - 273 - default: 274 - pr_cont("unsupported p6 CPU model %d ", boot_cpu_data.x86_model); 275 - return -ENODEV; 276 - } 277 253 278 254 memcpy(hw_cache_event_ids, p6_hw_cache_event_ids, 279 255 sizeof(hw_cache_event_ids));