All of lore.kernel.org
 help / color / mirror / Atom feed
From: Frederic Weisbecker <fweisbec@gmail.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@elte.hu>, LKML <linux-kernel@vger.kernel.org>,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	Paul Mackerras <paulus@samba.org>,
	David Miller <davem@davemloft.net>
Subject: Re: [PATCH 2/2] perf: Use hot regs with software sched switch/migrate events
Date: Tue, 30 Mar 2010 00:43:54 +0200	[thread overview]
Message-ID: <20100329224352.GC12254@nowhere> (raw)
In-Reply-To: <1269885938.12097.367.camel@laptop>

On Mon, Mar 29, 2010 at 08:05:38PM +0200, Peter Zijlstra wrote:
> On Mon, 2010-03-29 at 19:47 +0200, Frederic Weisbecker wrote:
> > 
> > 
> > I'm going to make a quick fix for perf_fetch_caller_regs() that
> > passes task_pt_regs if exclude_kernel for perf/urgent,
> > and I'll do the above cleanups/invasive fixes on perf/core.
> > 
> > 
> ok, sounds sensible, thanks!


Actually I have doubts about what should be the strict sense
of exclude_kernel.

Does that mean we exclude any event that happened in the kernel?
Or does that mean we exclude the part that happened in the kernel?

Depending on the case, we do either.

In perf_swevent_hrtimer(), we simply go back to task_pt_regs()
if exclude_kernel.

But in other software events, we don't such fix, we actually
filter out the event if it is not user_mode().

So, I'm a bit confused on what to do.
I'm tempted to adopt the meaning from perf_swevent_hrtimer()
for software events too, I'm not sure...

diff --git a/kernel/perf_event.c b/kernel/perf_event.c
index b0feb47..3cb5de8 100644
--- a/kernel/perf_event.c
+++ b/kernel/perf_event.c
@@ -3986,14 +3986,17 @@ static int perf_tp_event_match(struct perf_event *event,
 				struct perf_sample_data *data);
 
 static int perf_exclude_event(struct perf_event *event,
-			      struct pt_regs *regs)
+			      struct pt_regs **regs)
 {
-	if (regs) {
-		if (event->attr.exclude_user && user_mode(regs))
+	if (*regs) {
+		if (event->attr.exclude_user && user_mode(*regs))
 			return 1;
 
-		if (event->attr.exclude_kernel && !user_mode(regs))
-			return 1;
+		if (event->attr.exclude_kernel && !user_mode(*regs))
+			if (current->mm)
+				*regs = task_pt_regs();
+			else
+				return 1;
 	}
 
 	return 0;
@@ -4017,7 +4020,7 @@ static int perf_swevent_match(struct perf_event *event,
 	if (event->attr.config != event_id)
 		return 0;
 
-	if (perf_exclude_event(event, regs))
+	if (perf_exclude_event(event, &regs))
 		return 0;
 
 	if (event->attr.type == PERF_TYPE_TRACEPOINT &&
@@ -4442,7 +4445,7 @@ void perf_bp_event(struct perf_event *bp, void *data)
 
 	perf_sample_data_init(&sample, bp->attr.bp_addr);
 
-	if (!perf_exclude_event(bp, regs))
+	if (!perf_exclude_event(bp, &regs))
 		perf_swevent_add(bp, 1, 1, &sample, regs);
 }
 #else



  reply	other threads:[~2010-03-29 22:43 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-28  5:11 [GIT PULL] perf fixes Frederic Weisbecker
2010-03-28  5:11 ` [PATCH 1/2] perf: Correctly align perf event tracing buffer Frederic Weisbecker
2010-03-29  8:51   ` Peter Zijlstra
2010-03-29 17:16     ` Frederic Weisbecker
2010-03-29 17:20       ` Peter Zijlstra
2010-03-29 17:51         ` Frederic Weisbecker
2010-03-28  5:11 ` [PATCH 2/2] perf: Use hot regs with software sched switch/migrate events Frederic Weisbecker
2010-03-29  8:49   ` Peter Zijlstra
2010-03-29 17:47     ` Frederic Weisbecker
2010-03-29 18:05       ` Peter Zijlstra
2010-03-29 22:43         ` Frederic Weisbecker [this message]
2010-03-29 22:53           ` Frederic Weisbecker
2010-03-30 18:54           ` Peter Zijlstra
2010-03-30 19:14             ` Frederic Weisbecker
2010-03-29  3:33 ` [GIT PULL] perf fixes Ingo Molnar

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=20100329224352.GC12254@nowhere \
    --to=fweisbec@gmail.com \
    --cc=acme@redhat.com \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=paulus@samba.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.