linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org,
	David Ahern <david.ahern@oracle.com>,
	Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 1/7] perf tools: Fix synthesizing fork_event.ppid for non-main thread
Date: Fri, 10 Apr 2015 18:40:11 -0300	[thread overview]
Message-ID: <1428702017-19224-2-git-send-email-acme@kernel.org> (raw)
In-Reply-To: <1428702017-19224-1-git-send-email-acme@kernel.org>

From: David Ahern <david.ahern@oracle.com>

Commit ca6c41c59b9 sets the ppid based on what is read from the
/proc/pid/status file when synthesizing fork events.

This is correct thing to do for new processes but not threads of a
process.

Fix ppid for threads to be the main thread when synthesizing fork events
(ie., assume main thread spawned all sub-threads in a process).

Reported-by: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>
Signed-off-by: David Ahern <david.ahern@oracle.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Acked-by: Don Zickus <dzickus@redhat.com>
Link: http://lkml.kernel.org/r/1428598107-178999-1-git-send-email-david.ahern@oracle.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/event.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index 5516236df6ab..9d0985131252 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -183,8 +183,18 @@ static int perf_event__synthesize_fork(struct perf_tool *tool,
 {
 	memset(&event->fork, 0, sizeof(event->fork) + machine->id_hdr_size);
 
-	event->fork.ppid = ppid;
-	event->fork.ptid = ppid;
+	/*
+	 * for main thread set parent to ppid from status file. For other
+	 * threads set parent pid to main thread. ie., assume main thread
+	 * spawns all threads in a process
+	*/
+	if (tgid == pid) {
+		event->fork.ppid = ppid;
+		event->fork.ptid = ppid;
+	} else {
+		event->fork.ppid = tgid;
+		event->fork.ptid = tgid;
+	}
 	event->fork.pid  = tgid;
 	event->fork.tid  = pid;
 	event->fork.header.type = PERF_RECORD_FORK;
-- 
1.9.3


  reply	other threads:[~2015-04-10 21:40 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-10 21:40 [GIT PULL 0/7] perf/core improvements and fixes Arnaldo Carvalho de Melo
2015-04-10 21:40 ` Arnaldo Carvalho de Melo [this message]
2015-04-10 21:40 ` [PATCH 2/7] perf tools: Fix error path to do closedir() when synthesizing threads Arnaldo Carvalho de Melo
2015-04-10 21:40 ` [PATCH 3/7] perf tools: Fix cross-endian analysis Arnaldo Carvalho de Melo
2015-04-10 21:40 ` [PATCH 4/7] perf buildid-list: Fix segfault when show DSOs with hits Arnaldo Carvalho de Melo
2015-04-10 21:40 ` [PATCH 5/7] perf probe: Support multiple probes on different binaries Arnaldo Carvalho de Melo
2015-04-10 21:40 ` [PATCH 6/7] perf probe: Check the orphaned -x option Arnaldo Carvalho de Melo
2015-04-10 21:40 ` [PATCH 7/7] perf evlist: Fix type for references to data_head/tail Arnaldo Carvalho de Melo
2015-04-11  6:33 ` [GIT PULL 0/7] perf/core improvements and 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=1428702017-19224-2-git-send-email-acme@kernel.org \
    --to=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=david.ahern@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.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;
as well as URLs for NNTP newsgroup(s).