Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932999AbbDIRFe (ORCPT ); Thu, 9 Apr 2015 13:05:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46300 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932903AbbDIRFX (ORCPT ); Thu, 9 Apr 2015 13:05:23 -0400 Date: Thu, 9 Apr 2015 13:05:19 -0400 From: Don Zickus To: David Ahern Cc: acme@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] perf tools: Fix ppid for non-main thread Message-ID: <20150409170519.GK175361@redhat.com> References: <1428598107-178999-1-git-send-email-david.ahern@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1428598107-178999-1-git-send-email-david.ahern@oracle.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1906 Lines: 53 On Thu, Apr 09, 2015 at 12:48:27PM -0400, David Ahern wrote: > 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). That sounds right. :-) Sorry I should have noticed that a couple of weeks ago. Acked-by: Don Zickus > > Reported-by: Arnaldo Carvalho de Melo > Signed-off-by: David Ahern > Cc: Don Zickus > --- > tools/perf/util/event.c | 14 ++++++++++++-- > 1 files changed, 12 insertions(+), 2 deletions(-) > > diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c > index 186929a..ff866c4 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.7.1 > -- 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/