Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932773AbbDKGhT (ORCPT ); Sat, 11 Apr 2015 02:37:19 -0400 Received: from terminus.zytor.com ([198.137.202.10]:51081 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752052AbbDKGhQ (ORCPT ); Sat, 11 Apr 2015 02:37:16 -0400 Date: Fri, 10 Apr 2015 23:36:42 -0700 From: tip-bot for David Ahern Message-ID: Cc: arnaldo.melo@gmail.com, mingo@kernel.org, david.ahern@oracle.com, linux-kernel@vger.kernel.org, acme@redhat.com, hpa@zytor.com, dzickus@redhat.com, tglx@linutronix.de Reply-To: arnaldo.melo@gmail.com, david.ahern@oracle.com, mingo@kernel.org, linux-kernel@vger.kernel.org, hpa@zytor.com, dzickus@redhat.com, acme@redhat.com, tglx@linutronix.de In-Reply-To: <1428598107-178999-1-git-send-email-david.ahern@oracle.com> References: <1428598107-178999-1-git-send-email-david.ahern@oracle.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf tools: Fix synthesizing fork_event.ppid for non-main thread Git-Commit-ID: 7764a385f60bd200304a33124bdb4e684caeabdf X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2223 Lines: 58 Commit-ID: 7764a385f60bd200304a33124bdb4e684caeabdf Gitweb: http://git.kernel.org/tip/7764a385f60bd200304a33124bdb4e684caeabdf Author: David Ahern AuthorDate: Thu, 9 Apr 2015 12:48:27 -0400 Committer: Arnaldo Carvalho de Melo CommitDate: Fri, 10 Apr 2015 10:10:55 -0300 perf tools: Fix synthesizing fork_event.ppid for non-main thread 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 Signed-off-by: David Ahern Tested-by: Arnaldo Carvalho de Melo Acked-by: Don Zickus Link: http://lkml.kernel.org/r/1428598107-178999-1-git-send-email-david.ahern@oracle.com Signed-off-by: Arnaldo Carvalho de Melo --- 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 5516236..9d09851 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; -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/