From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751978AbbJCHtI (ORCPT ); Sat, 3 Oct 2015 03:49:08 -0400 Received: from terminus.zytor.com ([198.137.202.10]:59094 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751848AbbJCHtG (ORCPT ); Sat, 3 Oct 2015 03:49:06 -0400 Date: Sat, 3 Oct 2015 00:48:39 -0700 From: tip-bot for Namhyung Kim Message-ID: Cc: tglx@linutronix.de, linux-kernel@vger.kernel.org, mingo@kernel.org, namhyung@kernel.org, a.p.zijlstra@chello.nl, jolsa@redhat.com, dsahern@gmail.com, acme@redhat.com, hpa@zytor.com, acme@kernel.org Reply-To: mingo@kernel.org, namhyung@kernel.org, acme@redhat.com, acme@kernel.org, hpa@zytor.com, dsahern@gmail.com, jolsa@redhat.com, a.p.zijlstra@chello.nl, linux-kernel@vger.kernel.org, tglx@linutronix.de In-Reply-To: <1443577526-3240-1-git-send-email-namhyung@kernel.org> References: <1443577526-3240-1-git-send-email-namhyung@kernel.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf record: Allocate area for sample_id_hdr in a synthesized comm event Git-Commit-ID: e5bed564485b340d87f2d8945643a393e55b8225 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 Commit-ID: e5bed564485b340d87f2d8945643a393e55b8225 Gitweb: http://git.kernel.org/tip/e5bed564485b340d87f2d8945643a393e55b8225 Author: Namhyung Kim AuthorDate: Wed, 30 Sep 2015 10:45:24 +0900 Committer: Arnaldo Carvalho de Melo CommitDate: Thu, 1 Oct 2015 09:54:33 -0300 perf record: Allocate area for sample_id_hdr in a synthesized comm event A previous patch added a synthesized comm event for forked child process but it missed that the event should contain area for sample_id_hdr at the end. It worked by accident since the perf_event union contains bigger event structs like mmap_events. This patch fixes it by dynamically allocating event struct including those area like in perf_event__synthesize_thread_map(). Reported-by: Arnaldo Carvalho de Melo Signed-off-by: Namhyung Kim Cc: David Ahern Cc: Jiri Olsa Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/1443577526-3240-1-git-send-email-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-record.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index a01c8ae..5e01c07 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -637,17 +637,25 @@ static int __cmd_record(struct record *rec, int argc, const char **argv) * Let the child rip */ if (forks) { - union perf_event event; + union perf_event *event; + + event = malloc(sizeof(event->comm) + machine->id_hdr_size); + if (event == NULL) { + err = -ENOMEM; + goto out_child; + } + /* * Some H/W events are generated before COMM event * which is emitted during exec(), so perf script * cannot see a correct process name for those events. * Synthesize COMM event to prevent it. */ - perf_event__synthesize_comm(tool, &event, + perf_event__synthesize_comm(tool, event, rec->evlist->workload.pid, process_synthesized_event, machine); + free(event); perf_evlist__start_workload(rec->evlist); }