Skip to contentSkip to conversation

perf, x86: Fix double enable calls

tip:perf/urgent tip-bot for Peter Zijlstra 1 participant 1 message Mar 10, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw
Commit-ID:  f3d46b2e6fa57547f9884330798792afc83f4b04
Gitweb:     http://git.kernel.org/tip/f3d46b2e6fa57547f9884330798792afc83f4b04
Author:     Peter Zijlstra <[email protected]>
AuthorDate: Sat, 6 Mar 2010 13:24:58 +0100
Committer:  Ingo Molnar <[email protected]>
CommitDate: Wed, 10 Mar 2010 13:22:35 +0100

perf, x86: Fix double enable calls

hw_perf_enable() would enable already enabled events.

This causes problems with code that assumes that ->enable/->disable calls are balanced (like the LBR code does).

What happens is that events that were already running and left in place would get enabled again.

Avoid this by only enabling new events that match their previous assignment.

LKML-Reference: <new-submission>

---
 arch/x86/kernel/cpu/perf_event.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
arch/x86/kernel/cpu/perf_event.c +4 -0
index 045cc0b..1d665a0 100644
@@ -835,6 +835,10 @@ void hw_perf_enable(void)
 			event = cpuc->event_list[i];
 			hwc = &event->hw;
 
+			if (i < n_running &&
+			    match_prev_assignment(hwc, cpuc, i))
+				continue;
+
 			if (hwc->idx == -1)
 				x86_assign_hw_event(event, cpuc, i);