Skip to contentSkip to conversation

perf events fixes

GIT PULL Merged Ingo Molnar 2 participants 2 messages May 9

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Linus,

Please pull the latest perf/urgent Git tree from:

git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git perf-urgent-2026-05-09

for you to fetch changes up to aa4384bc8f4360167f3c3d5322121fe892289ea2:

Miscellaneous perf events fixes:

- Fix deadlock in the perf_mmap() failure path (Peter Zijlstra)

- Intel ACR (Auto Counter Reload) fixes (Dapeng Mi):

- Fix validation and configuration of ACR masks
- Fix ACR rescheduling bug causing stale masks
- Disable the PMI on ACR-enabled hardware
- Enable ACR on Panther Cover uarch too

Thanks,

Ingo

------------------>
Dapeng Mi (4):
perf/x86/intel: Improve validation and configuration of ACR masks perf/x86/intel: Always reprogram ACR events to prevent stale masks perf/x86/intel: Disable PMI for self-reloaded ACR events perf/x86/intel: Enable auto counter reload for DMR

Peter Zijlstra (1):
perf/core: Fix deadlock in perf_mmap() failure path

 arch/x86/events/core.c       | 13 ++++----
 arch/x86/events/intel/core.c | 50 ++++++++++++++++++++++++-------
 arch/x86/events/perf_event.h | 10 +++++++
 kernel/events/core.c         | 70 ++++++++++++++++++++++++++++++++++----------
 kernel/events/internal.h     |  1 +
 kernel/events/ring_buffer.c  |  2 ++
 6 files changed, 115 insertions(+), 31 deletions(-)
arch/x86/events/core.c +8 -5
index 810ab21ffd99..4b9e105309c6 100644
@@ -1294,13 +1294,16 @@ int x86_perf_rdpmc_index(struct perf_event *event)
 	return event->hw.event_base_rdpmc;
 }
 
-static inline int match_prev_assignment(struct hw_perf_event *hwc,
+static inline int match_prev_assignment(struct perf_event *event,
 					struct cpu_hw_events *cpuc,
 					int i)
 {
+	struct hw_perf_event *hwc = &event->hw;
+
 	return hwc->idx == cpuc->assign[i] &&
-		hwc->last_cpu == smp_processor_id() &&
-		hwc->last_tag == cpuc->tags[i];
+	       hwc->last_cpu == smp_processor_id() &&
+	       hwc->last_tag == cpuc->tags[i] &&
+	       !is_acr_event_group(event);
 }
 
 static void x86_pmu_start(struct perf_event *event, int flags);
@@ -1346,7 +1349,7 @@ static void x86_pmu_enable(struct pmu *pmu)
 			 * - no other event has used the counter since
 			 */
 			if (hwc->idx == -1 ||
-			    match_prev_assignment(hwc, cpuc, i))
+			    match_prev_assignment(event, cpuc, i))
 				continue;
 
 			/*
@@ -1367,7 +1370,7 @@ static void x86_pmu_enable(struct pmu *pmu)
 			event = cpuc->event_list[i];
 			hwc = &event->hw;
 
-			if (!match_prev_assignment(hwc, cpuc, i))
+			if (!match_prev_assignment(event, cpuc, i))
 				x86_assign_hw_event(event, cpuc, i);
 			else if (i < n_running)
 				continue;
arch/x86/events/intel/core.c +39 -11

85 lines not on this page · raw message

arch/x86/events/perf_event.h +10 -0
index fad87d3c8b2c..524668dcf4cc 100644
@@ -137,6 +137,16 @@ static inline bool is_acr_event_group(struct perf_event *event)
 	return check_leader_group(event->group_leader, PERF_X86_EVENT_ACR);
 }
 
+static inline bool is_acr_self_reload_event(struct perf_event *event)
+{
+	struct hw_perf_event *hwc = &event->hw;
+
+	if (hwc->idx < 0)
+		return false;
+
+	return test_bit(hwc->idx, (unsigned long *)&hwc->config1);
+}
+
 struct amd_nb {
 	int nb_id;  /* NorthBridge id */
 	int refcnt; /* reference count */
kernel/events/core.c +55 -15

110 lines not on this page · raw message

kernel/events/internal.h +1 -0
index d9cc57083091..c03c4f2eea57 100644
@@ -67,6 +67,7 @@ static inline void rb_free_rcu(struct rcu_head *rcu_head)
 	struct perf_buffer *rb;
 
 	rb = container_of(rcu_head, struct perf_buffer, rcu_head);
+	free_uid(rb->mmap_user);
 	rb_free(rb);
 }
 
kernel/events/ring_buffer.c +2 -0
index 3e7de2661417..9fe92161715e 100644
@@ -340,6 +340,8 @@ ring_buffer_init(struct perf_buffer *rb, long watermark, int flags)
 		rb->paused = 1;
 
 	mutex_init(&rb->aux_mutex);
+	rb->mmap_user = get_current_user();
+	refcount_set(&rb->mmap_count, 1);
 }
 
 void perf_aux_output_flag(struct perf_output_handle *handle, u64 flags)