diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index ae033ffd1079..6e0d8f4d270e 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c @@ -2270,12 +2270,6 @@ static void timehist_print_sample(struct perf_sched *sched, printf(" "); } - if (!thread__comm_set(thread)) { - const char *prev_comm = perf_sample__strval(sample, "prev_comm"); - - thread__set_comm(thread, prev_comm, sample->time); - } - printf(" %-*s ", comm_width, timehist_get_commstr(thread)); if (sched->show_prio) @@ -2981,6 +2975,16 @@ static int timehist_sched_change_event(const struct perf_tool *tool, thread__zput(itr->last_thread); } + /* + * If the process name is not set for the thread, use "prev_comm" + * to set it. Otherwise the sched summary will have just pid information + */ + if (!thread__comm_set(thread)) { + const char *prev_comm = perf_sample__strval(sample, "prev_comm"); + + thread__set_comm(thread, prev_comm, sample->time); + } + if (!sched->summary_only) timehist_print_sample(sched, sample, &al, thread, t, state); }