]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - tools/perf/builtin-record.c
perf record: Synthesize COMM event for a command line workload
[linux.git] / tools / perf / builtin-record.c
index 142eeb341b295a722aec214d3346790221031ff1..a01c8ae1ee074437484f1d19b3e77507d217324c 100644 (file)
@@ -636,8 +636,21 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)
        /*
         * Let the child rip
         */
-       if (forks)
+       if (forks) {
+               union perf_event event;
+               /*
+                * 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,
+                                           rec->evlist->workload.pid,
+                                           process_synthesized_event,
+                                           machine);
+
                perf_evlist__start_workload(rec->evlist);
+       }
 
        if (opts->initial_delay) {
                usleep(opts->initial_delay * 1000);