diff options
author | Wang Nan <wangnan0@huawei.com> | 2016-04-20 14:59:54 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-04-28 08:58:59 -0400 |
commit | be7b0c9e376e93a00b6c8631e2721e9dc7c6a1fa (patch) | |
tree | 3e506744da6b6198292515a459de22c47b26db4d | |
parent | 0c1d46a8796e8309f1ca693e5cad6f318e4b8159 (diff) |
perf record: Generate tracking events for process forked by perf
With 'perf record --switch-output' without -a, record__synthesize() in
record__switch_output() won't generate tracking events because there's
no thread_map in evlist. Which causes newly created perf.data doesn't
contain map and comm information.
This patch creates a fake thread_map and directly call
perf_event__synthesize_thread_map() for those events.
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1461178794-40467-8-git-send-email-wangnan0@huawei.com
Signed-off-by: He Kuang <hekuang@huawei.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/perf/builtin-record.c | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 178b49ecd05f..f3679c44d3f3 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c | |||
@@ -500,6 +500,23 @@ record__finish_output(struct record *rec) | |||
500 | return; | 500 | return; |
501 | } | 501 | } |
502 | 502 | ||
503 | static int record__synthesize_workload(struct record *rec) | ||
504 | { | ||
505 | struct { | ||
506 | struct thread_map map; | ||
507 | struct thread_map_data map_data; | ||
508 | } thread_map; | ||
509 | |||
510 | thread_map.map.nr = 1; | ||
511 | thread_map.map.map[0].pid = rec->evlist->workload.pid; | ||
512 | thread_map.map.map[0].comm = NULL; | ||
513 | return perf_event__synthesize_thread_map(&rec->tool, &thread_map.map, | ||
514 | process_synthesized_event, | ||
515 | &rec->session->machines.host, | ||
516 | rec->opts.sample_address, | ||
517 | rec->opts.proc_map_timeout); | ||
518 | } | ||
519 | |||
503 | static int record__synthesize(struct record *rec); | 520 | static int record__synthesize(struct record *rec); |
504 | 521 | ||
505 | static int | 522 | static int |
@@ -532,9 +549,21 @@ record__switch_output(struct record *rec, bool at_exit) | |||
532 | file->path, timestamp); | 549 | file->path, timestamp); |
533 | 550 | ||
534 | /* Output tracking events */ | 551 | /* Output tracking events */ |
535 | if (!at_exit) | 552 | if (!at_exit) { |
536 | record__synthesize(rec); | 553 | record__synthesize(rec); |
537 | 554 | ||
555 | /* | ||
556 | * In 'perf record --switch-output' without -a, | ||
557 | * record__synthesize() in record__switch_output() won't | ||
558 | * generate tracking events because there's no thread_map | ||
559 | * in evlist. Which causes newly created perf.data doesn't | ||
560 | * contain map and comm information. | ||
561 | * Create a fake thread_map and directly call | ||
562 | * perf_event__synthesize_thread_map() for those events. | ||
563 | */ | ||
564 | if (target__none(&rec->opts.target)) | ||
565 | record__synthesize_workload(rec); | ||
566 | } | ||
538 | return fd; | 567 | return fd; |
539 | } | 568 | } |
540 | 569 | ||