Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1238756

[tip:perf/core] perf record: Allocate area for sample_id_hdr in a synthesized comm event

From tip-bot for Namhyung Kim <tipbot@zytor.com>
Newsgroups linux.kernel
Subject [tip:perf/core] perf record: Allocate area for sample_id_hdr in a synthesized comm event
Date 2015-10-03 09:50 +0200
Message-ID <qfpJU-3Pm-17@gated-at.bofh.it> (permalink)
References <qeeQx-7rT-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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);
 	}
--
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/

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH 1/3] perf record: Allocate area for sample_id_hdr in a synthesized comm event Namhyung Kim <namhyung@kernel.org> - 2015-09-30 04:00 +0200
  [PATCH 3/3] perf top: Register idle thread Namhyung Kim <namhyung@kernel.org> - 2015-09-30 04:00 +0200
    [tip:perf/core] perf top: Register idle thread tip-bot for Namhyung Kim <tipbot@zytor.com> - 2015-10-03 09:50 +0200
  Re: [PATCH 1/3] perf record: Allocate area for sample_id_hdr in a  synthesized comm event Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-10-01 00:10 +0200
  [tip:perf/core] perf record:   Allocate area for sample_id_hdr in a synthesized comm event tip-bot for Namhyung Kim <tipbot@zytor.com> - 2015-10-03 09:50 +0200

csiph-web