Skip to content

Commit a3c44e7

Browse files
Dapeng Migregkh
authored andcommitted
perf/x86/intel: Disable PMI for self-reloaded ACR events
[ Upstream commit 1271aeccc307066315b2d3b0d5af2510e27018b5 ] On platforms with Auto Counter Reload (ACR) support, such as NVL, a "NMI received for unknown reason 30" warning is observed when running multiple events in a group with ACR enabled: $ perf record -e '{instructions/period=20000,acr_mask=0x2/u,\ cycles/period=40000,acr_mask=0x3/u}' ./test The warning occurs because the Performance Monitoring Interrupt (PMI) is enabled for the self-reloaded event (the cycles event in this case). According to the Intel SDM, the overflow bit (IA32_PERF_GLOBAL_STATUS.PMCn_OVF) is never set for self-reloaded events. Since the bit is not set, the perf NMI handler cannot identify the source of the interrupt, leading to the "unknown reason" message. Furthermore, enabling PMI for self-reloaded events is unnecessary and can lead to extraneous records that pollute the user's requested data. Disable the interrupt bit for all events configured with ACR self-reload. Fixes: ec980e4 ("perf/x86/intel: Support auto counter reload") Reported-by: Andi Kleen <ak@linux.intel.com> Signed-off-by: Dapeng Mi <dapeng1.mi@linux.intel.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: stable@vger.kernel.org Link: https://patch.msgid.link/20260430002558.712334-4-dapeng1.mi@linux.intel.com Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent b6437e6 commit a3c44e7

2 files changed

Lines changed: 23 additions & 4 deletions

File tree

arch/x86/events/intel/core.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2866,11 +2866,11 @@ static void intel_pmu_enable_fixed(struct perf_event *event)
28662866
intel_set_masks(event, idx);
28672867

28682868
/*
2869-
* Enable IRQ generation (0x8), if not PEBS,
2870-
* and enable ring-3 counting (0x2) and ring-0 counting (0x1)
2871-
* if requested:
2869+
* Enable IRQ generation (0x8), if not PEBS or self-reloaded
2870+
* ACR event, and enable ring-3 counting (0x2) and ring-0
2871+
* counting (0x1) if requested:
28722872
*/
2873-
if (!event->attr.precise_ip)
2873+
if (!event->attr.precise_ip && !is_acr_self_reload_event(event))
28742874
bits |= INTEL_FIXED_0_ENABLE_PMI;
28752875
if (hwc->config & ARCH_PERFMON_EVENTSEL_USR)
28762876
bits |= INTEL_FIXED_0_USER;
@@ -2955,6 +2955,15 @@ static void intel_pmu_enable_event(struct perf_event *event)
29552955
enable_mask |= ARCH_PERFMON_EVENTSEL_BR_CNTR;
29562956
intel_set_masks(event, idx);
29572957
static_call_cond(intel_pmu_enable_acr_event)(event);
2958+
/*
2959+
* For self-reloaded ACR event, don't enable PMI since
2960+
* HW won't set overflow bit in GLOBAL_STATUS. Otherwise,
2961+
* the PMI would be recognized as a suspicious NMI.
2962+
*/
2963+
if (is_acr_self_reload_event(event))
2964+
hwc->config &= ~ARCH_PERFMON_EVENTSEL_INT;
2965+
else if (!event->attr.precise_ip)
2966+
hwc->config |= ARCH_PERFMON_EVENTSEL_INT;
29582967
__x86_pmu_enable_event(hwc, enable_mask);
29592968
break;
29602969
case INTEL_PMC_IDX_FIXED ... INTEL_PMC_IDX_FIXED_BTS - 1:

arch/x86/events/perf_event.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,16 @@ static inline bool is_acr_event_group(struct perf_event *event)
133133
return check_leader_group(event->group_leader, PERF_X86_EVENT_ACR);
134134
}
135135

136+
static inline bool is_acr_self_reload_event(struct perf_event *event)
137+
{
138+
struct hw_perf_event *hwc = &event->hw;
139+
140+
if (hwc->idx < 0)
141+
return false;
142+
143+
return test_bit(hwc->idx, (unsigned long *)&hwc->config1);
144+
}
145+
136146
struct amd_nb {
137147
int nb_id; /* NorthBridge id */
138148
int refcnt; /* reference count */

0 commit comments

Comments
 (0)