public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf_events: fix validate_event bug
@ 2009-10-22 14:51 Stephane Eranian
  2009-11-18 16:46 ` Peter Zijlstra
  2009-11-24 13:27 ` Stephane Eranian
  0 siblings, 2 replies; 10+ messages in thread
From: Stephane Eranian @ 2009-10-22 14:51 UTC (permalink / raw)
  To: linux-kernel
  Cc: mingo, paulus, a.p.zijlstra, perfmon2-devel, Stephane Eranian

	The validate_event() was failing on valid event
	combinations. The function was assuming that if
	x86_schedule_event() returned 0, it meant error.
	But x86_schedule_event() returns the counter index
	and 0 is a perfectly valid value. An error is returned
	if the function returns a negative value.

	Furthermore, validate_event() was also failing for
	event groups because the event->pmu was not set until
	after hw_perf_pmu_init().
	
	Signed-off-by: Stephane Eranian <eranian@gmail.com>
--
 arch/x86/kernel/cpu/perf_event.c |    5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
index 2e20bca..d321ff7 100644
--- a/arch/x86/kernel/cpu/perf_event.c
+++ b/arch/x86/kernel/cpu/perf_event.c
@@ -2229,10 +2229,7 @@ validate_event(struct cpu_hw_events *cpuc, struct perf_event *event)
 {
 	struct hw_perf_event fake_event = event->hw;
 
-	if (event->pmu != &pmu)
-		return 0;
-
-	return x86_schedule_event(cpuc, &fake_event);
+	return x86_schedule_event(cpuc, &fake_event) >= 0;
 }
 
 static int validate_group(struct perf_event *event)

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2009-11-25  7:56 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-22 14:51 [PATCH] perf_events: fix validate_event bug Stephane Eranian
2009-11-18 16:46 ` Peter Zijlstra
2009-11-23 13:34   ` stephane eranian
2009-11-23 13:45     ` Peter Zijlstra
2009-11-24 13:18       ` stephane eranian
2009-11-24 22:00         ` Paul Mackerras
2009-11-25  5:47           ` stephane eranian
2009-11-25  7:55             ` Peter Zijlstra
2009-11-24 13:27 ` Stephane Eranian
2009-11-24 19:03   ` [tip:perf/core] perf_events, x86: Fix " tip-bot for Stephane Eranian

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox