Skip to content

Commit 3df9427

Browse files
committed
Merge tag 'perf-urgent-2024-09-01' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull perf fix from Thomas Gleixner: "A single fix for x86 performance monitoring. Haswell PMUs suffer from several errata and require a limit the minimal period for counter events, otherwise they suffer from endless loops in the PMU interrupt" * tag 'perf-urgent-2024-09-01' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: perf/x86/intel: Limit the period on Haswell
2 parents 51859c5 + 25dfc9e commit 3df9427

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

arch/x86/events/intel/core.c

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4589,6 +4589,25 @@ static enum hybrid_cpu_type adl_get_hybrid_cpu_type(void)
45894589
return HYBRID_INTEL_CORE;
45904590
}
45914591

4592+
static inline bool erratum_hsw11(struct perf_event *event)
4593+
{
4594+
return (event->hw.config & INTEL_ARCH_EVENT_MASK) ==
4595+
X86_CONFIG(.event=0xc0, .umask=0x01);
4596+
}
4597+
4598+
/*
4599+
* The HSW11 requires a period larger than 100 which is the same as the BDM11.
4600+
* A minimum period of 128 is enforced as well for the INST_RETIRED.ALL.
4601+
*
4602+
* The message 'interrupt took too long' can be observed on any counter which
4603+
* was armed with a period < 32 and two events expired in the same NMI.
4604+
* A minimum period of 32 is enforced for the rest of the events.
4605+
*/
4606+
static void hsw_limit_period(struct perf_event *event, s64 *left)
4607+
{
4608+
*left = max(*left, erratum_hsw11(event) ? 128 : 32);
4609+
}
4610+
45924611
/*
45934612
* Broadwell:
45944613
*
@@ -4606,8 +4625,7 @@ static enum hybrid_cpu_type adl_get_hybrid_cpu_type(void)
46064625
*/
46074626
static void bdw_limit_period(struct perf_event *event, s64 *left)
46084627
{
4609-
if ((event->hw.config & INTEL_ARCH_EVENT_MASK) ==
4610-
X86_CONFIG(.event=0xc0, .umask=0x01)) {
4628+
if (erratum_hsw11(event)) {
46114629
if (*left < 128)
46124630
*left = 128;
46134631
*left &= ~0x3fULL;
@@ -6766,6 +6784,7 @@ __init int intel_pmu_init(void)
67666784

67676785
x86_pmu.hw_config = hsw_hw_config;
67686786
x86_pmu.get_event_constraints = hsw_get_event_constraints;
6787+
x86_pmu.limit_period = hsw_limit_period;
67696788
x86_pmu.lbr_double_abort = true;
67706789
extra_attr = boot_cpu_has(X86_FEATURE_RTM) ?
67716790
hsw_format_attr : nhm_format_attr;

0 commit comments

Comments
 (0)