From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932202AbbCaOKe (ORCPT ); Tue, 31 Mar 2015 10:10:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39045 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753548AbbCaOKd (ORCPT ); Tue, 31 Mar 2015 10:10:33 -0400 Date: Tue, 31 Mar 2015 16:10:26 +0200 From: Jiri Olsa To: David Ahern Cc: acme@kernel.org, linux-kernel@vger.kernel.org, Don Zickus , Joe Mario Subject: Re: [PATCH v3 2/2] perf tool: Fix ppid for synthesized fork events Message-ID: <20150331141026.GC3777@krava.brq.redhat.com> References: <1427747758-18510-1-git-send-email-dsahern@gmail.com> <1427747758-18510-2-git-send-email-dsahern@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1427747758-18510-2-git-send-email-dsahern@gmail.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 30, 2015 at 02:35:58PM -0600, David Ahern wrote: > 363b785f38 added synthesized fork events and set a thread's parent id > to itself. Since we are already processing /proc//status the ppid > can be determined properly. Make it so. > > Signed-off-by: David Ahern > Cc: Don Zickus > Cc: Joe Mario > Cc: Jiri Olsa > --- > v3 > - removed isspace and newline checks; added brackets per Arnaldo's comments > > v2: > - removed changes to function signature for perf_event__synthesize_comm as > noted by Jiri > > tools/perf/util/event.c | 83 +++++++++++++++++++++++++++++-------------------- > 1 file changed, 50 insertions(+), 33 deletions(-) > > diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c > index 023dd3548a94..5516236df6ab 100644 > --- a/tools/perf/util/event.c > +++ b/tools/perf/util/event.c > @@ -51,29 +51,32 @@ static struct perf_sample synth_sample = { > > /* > * Assumes that the first 4095 bytes of /proc/pid/stat contains > - * the comm and tgid. > + * the comm, tgid and ppid. > */ > -static pid_t perf_event__get_comm_tgid(pid_t pid, char *comm, size_t len) > +static int perf_event__get_comm_ids(pid_t pid, char *comm, size_t len, > + pid_t *tgid, pid_t *ppid) > { > char filename[PATH_MAX]; > char bf[4096]; > int fd; > size_t size = 0, n; > - pid_t tgid = -1; > - char *nl, *name, *tgids; > + char *nl, *name, *tgids, *ppids; > + > + *tgid = -1; > + *ppid = -1; > > snprintf(filename, sizeof(filename), "/proc/%d/status", pid); > > fd = open(filename, O_RDONLY); > if (fd < 0) { > pr_debug("couldn't open %s\n", filename); > - return 0; > + return -1; hum, missed this one in previous version.. why did not we fail before? jirka