Skip to content

Commit 8b70c74

Browse files
sohilmehIngo Molnar
authored andcommitted
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
1 parent 24a295e commit 8b70c74

File tree

2 files changed

+13
-27
lines changed

2 files changed

+13
-27
lines changed

arch/x86/events/intel/core.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6541,15 +6541,21 @@ __init int intel_pmu_init(void)
65416541
char *name;
65426542
struct x86_hybrid_pmu *pmu;
65436543

6544+
/* Architectural Perfmon was introduced starting with Core "Yonah" */
65446545
if (!cpu_has(&boot_cpu_data, X86_FEATURE_ARCH_PERFMON)) {
65456546
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:
65496552
return knc_pmu_init();
6550-
case 0xf:
6553+
case 15:
65516554
return p4_pmu_init();
65526555
}
6556+
6557+
pr_cont("unsupported CPU family %d model %d ",
6558+
boot_cpu_data.x86, boot_cpu_data.x86_model);
65536559
return -ENODEV;
65546560
}
65556561

arch/x86/events/intel/p6.c

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
#include <linux/perf_event.h>
33
#include <linux/types.h>
44

5+
#include <asm/cpu_device_id.h>
6+
57
#include "../perf_event.h"
68

79
/*
@@ -248,30 +250,8 @@ __init int p6_pmu_init(void)
248250
{
249251
x86_pmu = p6_pmu;
250252

251-
switch (boot_cpu_data.x86_model) {
252-
case 1: /* Pentium Pro */
253+
if (boot_cpu_data.x86_vfm == INTEL_PENTIUM_PRO)
253254
x86_add_quirk(p6_pmu_rdpmc_quirk);
254-
break;
255-
256-
case 3: /* Pentium II - Klamath */
257-
case 5: /* Pentium II - Deschutes */
258-
case 6: /* Pentium II - Mendocino */
259-
break;
260-
261-
case 7: /* Pentium III - Katmai */
262-
case 8: /* Pentium III - Coppermine */
263-
case 10: /* Pentium III Xeon */
264-
case 11: /* Pentium III - Tualatin */
265-
break;
266-
267-
case 9: /* Pentium M - Banias */
268-
case 13: /* Pentium M - Dothan */
269-
break;
270-
271-
default:
272-
pr_cont("unsupported p6 CPU model %d ", boot_cpu_data.x86_model);
273-
return -ENODEV;
274-
}
275255

276256
memcpy(hw_cache_event_ids, p6_hw_cache_event_ids,
277257
sizeof(hw_cache_event_ids));

0 commit comments

Comments
 (0)