All of lore.kernel.org
 help / color / mirror / Atom feed
From: tip-bot for Namhyung Kim <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
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
Subject: [tip:perf/core] perf record: Allocate area for sample_id_hdr in a synthesized comm event
Date: Sat, 3 Oct 2015 00:48:39 -0700	[thread overview]
Message-ID: <tip-e5bed564485b340d87f2d8945643a393e55b8225@git.kernel.org> (raw)
In-Reply-To: <1443577526-3240-1-git-send-email-namhyung@kernel.org>

Commit-ID:  e5bed564485b340d87f2d8945643a393e55b8225
Gitweb:     http://git.kernel.org/tip/e5bed564485b340d87f2d8945643a393e55b8225
Author:     Namhyung Kim <namhyung@kernel.org>
AuthorDate: Wed, 30 Sep 2015 10:45:24 +0900
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
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 <acme@kernel.org>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1443577526-3240-1-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 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);
 	}

      parent reply	other threads:[~2015-10-03  7:49 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-30  1:45 [PATCH 1/3] perf record: Allocate area for sample_id_hdr in a synthesized comm event Namhyung Kim
2015-09-30  1:45 ` [PATCH 2/3] perf top: Fix unresolved comm when -s comm is used Namhyung Kim
2015-10-03  7:48   ` [tip:perf/core] " tip-bot for Namhyung Kim
2015-09-30  1:45 ` [PATCH 3/3] perf top: Register idle thread Namhyung Kim
2015-10-03  7:49   ` [tip:perf/core] " tip-bot for Namhyung Kim
2015-09-30 22:02 ` [PATCH 1/3] perf record: Allocate area for sample_id_hdr in a synthesized comm event Arnaldo Carvalho de Melo
2015-10-03  7:48 ` tip-bot for Namhyung Kim [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=tip-e5bed564485b340d87f2d8945643a393e55b8225@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=dsahern@gmail.com \
    --cc=hpa@zytor.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.