public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Stephane Eranian <eranian@google.com>
To: linux-kernel@vger.kernel.org
Cc: peterz@infradead.org, mingo@elte.hu, paulus@samba.org,
	perfmon2-devel@lists.sourceforge.net, eranian@google.com,
	eranian@gmail.com
Subject: [PATCH] perf_events: fix validate_event bug
Date: Tue, 24 Nov 2009 05:27:18 -0800 (PST)	[thread overview]
Message-ID: <4b0bdf36.1818d00a.07cc.25ae@mx.google.com> (raw)
In-Reply-To: <1256223091-6002-1-git-send-email-eranian@gmail.com>

	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_event_init().
	
	Signed-off-by: Stephane Eranian <eranian@google.com>
--
 arch/x86/kernel/cpu/perf_event.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
index bd87430..c1bbed1 100644
--- a/arch/x86/kernel/cpu/perf_event.c
+++ b/arch/x86/kernel/cpu/perf_event.c
@@ -2229,10 +2229,10 @@ validate_event(struct cpu_hw_events *cpuc, struct perf_event *event)
 {
 	struct hw_perf_event fake_event = event->hw;
 
-	if (event->pmu != &pmu)
+	if (event->pmu && 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)

  parent reply	other threads:[~2009-11-24 13:27 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2009-11-24 19:03   ` [tip:perf/core] perf_events, x86: Fix " tip-bot for Stephane Eranian

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4b0bdf36.1818d00a.07cc.25ae@mx.google.com \
    --to=eranian@google.com \
    --cc=eranian@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=paulus@samba.org \
    --cc=perfmon2-devel@lists.sourceforge.net \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox