From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752517AbbETHIz (ORCPT ); Wed, 20 May 2015 03:08:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42916 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750819AbbETHIw (ORCPT ); Wed, 20 May 2015 03:08:52 -0400 Date: Wed, 20 May 2015 09:08:35 +0200 From: Jiri Olsa To: Namhyung Kim Cc: Arnaldo Carvalho de Melo , Ingo Molnar , Peter Zijlstra , LKML , David Ahern Subject: Re: [PATCH 3/3] perf record: Synthesize COMM event for a command line workload Message-ID: <20150520070835.GC26714@krava.redhat.com> References: <1432090115-902-1-git-send-email-namhyung@kernel.org> <1432090115-902-3-git-send-email-namhyung@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1432090115-902-3-git-send-email-namhyung@kernel.org> 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 Wed, May 20, 2015 at 11:48:35AM +0900, Namhyung Kim wrote: > When perf creates a new child to profile, the events are enabled on > exec(). And in this case, it doesn't synthesize any event for the > child since they'll be generated during exec(). But there's an window > between the enabling and the event generation. > > It used to be overcome since samples are only in kernel (so we always > have the map) and the comm is overridden by a later COMM event. > However it won't work if events are processed and displayed before the > COMM event overrides like in 'perf script'. This leads to those early > samples (like native_write_msr_safe) not having a comm but pid (like > ':15328'). > > So it needs to synthesize COMM event for the child explicitly before > enabling so that it can have a correct comm. But at this time, the > comm will be "perf" since it's not exec-ed yet. > > Signed-off-by: Namhyung Kim > --- > tools/perf/builtin-record.c | 41 ++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 40 insertions(+), 1 deletion(-) > > diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c > index 5dfe91395617..a0821ee92e27 100644 > --- a/tools/perf/builtin-record.c > +++ b/tools/perf/builtin-record.c > @@ -469,6 +469,43 @@ static void workload_exec_failed_signal(int signo __maybe_unused, > child_finished = 1; > } > > +static int synthesize_workload_comm_event(struct perf_evlist *evlist, void *arg) > +{ > + union perf_event *event; > + struct record *rec = arg; > + struct machine *machine = &rec->session->machines.host; > + int pid = evlist->workload.pid; > + const char *comm_str = program_invocation_short_name; never heard of program_invocation_short_name ;-) nice.. for the patchset: Acked-by: Jiri Olsa I tested the record/script use case.. works ok thanks, jirka