Messages in this thread Patch in this message | | | From | Namhyung Kim <> | Subject | [PATCH 2/3] perf trace: Create struct thread for command line workload | Date | Wed, 20 May 2015 11:48:34 +0900 |
| |
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. This leads to some early event not having a comm but pid (like ':15328').
Fix it by using perf_evlist__start_workload_ex() to create corresponding thread at the same time.
Signed-off-by: Namhyung Kim <namhyung@kernel.org> --- tools/perf/builtin-trace.c | 4 +++- tools/perf/util/evlist.c | 14 ++++++++++++++ tools/perf/util/evlist.h | 2 ++ 3 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index a05490d06374..e30d0ed1e60f 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -2282,7 +2282,9 @@ static int trace__run(struct trace *trace, int argc, const char **argv) perf_evlist__enable(evlist); if (forks) - perf_evlist__start_workload(evlist); + perf_evlist__start_workload_ex(evlist, + perf_evlist__create_workload_thread, + trace->host); trace->multiple_threads = evlist->threads->map[0] == -1 || evlist->threads->nr > 1 || diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index bfe455ec673b..f84305915e47 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -1516,6 +1516,20 @@ int perf_evlist__start_workload_ex(struct perf_evlist *evlist, return ret; } +int perf_evlist__create_workload_thread(struct perf_evlist *evlist, void *arg) +{ + struct machine *machine = arg; + int pid = evlist->workload.pid; + struct thread *thread; + + thread = machine__findnew_thread(machine, pid, pid); + if (thread == NULL) + return -1; + + thread__set_comm(thread, program_invocation_short_name, 0); + return 0; +} + int perf_evlist__parse_sample(struct perf_evlist *evlist, union perf_event *event, struct perf_sample *sample) { diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h index 6212f036c134..a02b0f4ba4f9 100644 --- a/tools/perf/util/evlist.h +++ b/tools/perf/util/evlist.h @@ -126,6 +126,8 @@ int perf_evlist__start_workload(struct perf_evlist *evlist); typedef int (*workload_callback_t)(struct perf_evlist *evlist, void *arg); int perf_evlist__start_workload_ex(struct perf_evlist *evlist, workload_callback_t callback, void *arg); +/* workload_callbacks */ +int perf_evlist__create_workload_thread(struct perf_evlist *evlist, void *arg); struct option; -- 2.4.0
| |