public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: linux-kernel@vger.kernel.org
Cc: mingo@elte.hu, Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Paul Mackerras <paulus@samba.org>
Subject: [PATCH 03/13] perf record: Update for the new FORK/EXIT events
Date: Thu, 23 Jul 2009 21:16:45 +0200	[thread overview]
Message-ID: <20090723191956.847364023@chello.nl> (raw)
In-Reply-To: 20090723191642.780643661@chello.nl

[-- Attachment #1: perf-counter-tools-exit.patch --]
[-- Type: text/plain, Size: 2081 bytes --]

Since FORK is now also issued for threads, detect those by comparing
the parent and child PID.

Teach it about EXIT events and ignore them.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
---
 tools/perf/builtin-report.c |   22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

Index: linux-2.6/tools/perf/builtin-report.c
===================================================================
--- linux-2.6.orig/tools/perf/builtin-report.c
+++ linux-2.6/tools/perf/builtin-report.c
@@ -99,6 +99,7 @@ struct comm_event {
 struct fork_event {
 	struct perf_event_header header;
 	u32 pid, ppid;
+	u32 tid, ptid;
 };
 
 struct lost_event {
@@ -1608,15 +1609,27 @@ process_comm_event(event_t *event, unsig
 }
 
 static int
-process_fork_event(event_t *event, unsigned long offset, unsigned long head)
+process_task_event(event_t *event, unsigned long offset, unsigned long head)
 {
 	struct thread *thread = threads__findnew(event->fork.pid);
 	struct thread *parent = threads__findnew(event->fork.ppid);
 
-	dprintf("%p [%p]: PERF_EVENT_FORK: %d:%d\n",
+	dprintf("%p [%p]: PERF_EVENT_%s: (%d:%d):(%d:%d)\n",
 		(void *)(offset + head),
 		(void *)(long)(event->header.size),
-		event->fork.pid, event->fork.ppid);
+		event->header.type == PERF_EVENT_FORK ? "FORK" : "EXIT",
+		event->fork.pid, event->fork.tid,
+		event->fork.ppid, event->fork.ptid);
+
+	/*
+	 * A thread clone will have the same PID for both
+	 * parent and child.
+	 */
+	if (thread == parent)
+		return 0;
+
+	if (event->header.type == PERF_EVENT_EXIT)
+		return 0;
 
 	if (!thread || !parent || thread__fork(thread, parent)) {
 		dprintf("problem processing PERF_EVENT_FORK, skipping event.\n");
@@ -1706,7 +1719,8 @@ process_event(event_t *event, unsigned l
 		return process_comm_event(event, offset, head);
 
 	case PERF_EVENT_FORK:
-		return process_fork_event(event, offset, head);
+	case PERF_EVENT_EXIT:
+		return process_task_event(event, offset, head);
 
 	case PERF_EVENT_LOST:
 		return process_lost_event(event, offset, head);

-- 


  parent reply	other threads:[~2009-07-23 19:23 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-23 19:16 [PATCH 00/13] current patch queue Peter Zijlstra
2009-07-23 19:16 ` [PATCH 01/13] perf_counter tools: resurrect perf top annotation in a simple interactive form Peter Zijlstra
2009-07-23 19:16 ` [PATCH 02/13] perf_counter: full task tracing Peter Zijlstra
2009-07-23 19:16 ` Peter Zijlstra [this message]
2009-07-23 19:16 ` [PATCH 04/13] ftrace: perf_counter intergration Peter Zijlstra
2009-07-23 21:41   ` Steven Rostedt
2009-08-02 14:42     ` Ingo Molnar
2009-08-03  9:40       ` Peter Zijlstra
2009-07-23 19:16 ` [PATCH 05/13] perf_counter: Rework software counters Peter Zijlstra
2009-07-23 19:16 ` [PATCH 06/13] lockdep: Fix backtraces Peter Zijlstra
2009-07-23 19:16 ` [PATCH 07/13] lockdep: Style nits Peter Zijlstra
2009-07-23 19:16 ` [PATCH 08/13] lockdep: Introduce lockdep_assert_held() Peter Zijlstra
2009-07-23 19:16 ` [PATCH 09/13] lockdep: Deal with many similar locks Peter Zijlstra
2009-07-23 19:16 ` [PATCH 10/13] sched: Optimize unused cgroup configuration Peter Zijlstra
2009-07-23 19:16 ` [PATCH 11/13] sched: Ensure the migration task doesnt go away during use Peter Zijlstra
2009-07-23 19:16 ` [PATCH 12/13] sched: Provide iowait counters Peter Zijlstra
2009-07-23 19:16 ` [PATCH 13/13] sched: wait, sleep and iowait accounting tracepoints Peter Zijlstra

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=20090723191956.847364023@chello.nl \
    --to=a.p.zijlstra@chello.nl \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=paulus@samba.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