perf sched map: re-annotate shortname if thread comm changed
PATCH 1/1 perf sched map: re-annotate shortname if thread comm changed
From: Changbin Du <[email protected]>
This is to show the real name of thread that created via fork-exec. See below example for shortname *A0*.
$ sudo ./perf sched map
*A0 80393.050639 secs A0 => perf:22368
*. A0 80393.050748 secs . => swapper:0
. *. 80393.050887 secs
*B0 . . 80393.052735 secs B0 => rcu_sched:8
*. . . 80393.052743 secs
. *C0 . 80393.056264 secs C0 => kworker/2:1H:287
. *A0 . 80393.056270 secs
. *D0 . 80393.056769 secs D0 => ksoftirqd/2:22
. *A0 . 80393.056804 secs A0 => pi:22368
. *. . 80393.056854 secs
*B0 . . 80393.060727 secs
...Signed-off-by Changbin Du <[email protected]>
--- tools/perf/builtin-sched.c | 4 +++- tools/perf/util/thread.c | 1 + tools/perf/util/thread.h | 1 + 3 files changed, 5 insertions(+), 1 deletion(-)
tools/perf/builtin-sched.c +3 -1
@@ -1580,7 +1580,7 @@ static int map_switch_event(struct perf_sched *sched, struct perf_evsel *evsel,timestamp__scnprintf_usec (timestamp, stimestamp,sizeof (stimestamp));color_fprintf (stdout, color," %12s secs " , stimestamp); -if (new_shortname || (verbose >0 && sched_in->tid)) { +if (new_shortname || sched_in->comm_changed || (verbose >0 && sched_in->tid)) {const char *pid_color = color;if (thread__has_color (sched_in))
@@ -1588,6 +1588,8 @@ static int map_switch_event(struct perf_sched *sched, struct perf_evsel *evsel,color_fprintf (stdout, pid_color,"%s => %s:%d" , sched_in->shortname,thread__comm_str (sched_in), sched_in->tid); + + sched_in->comm_changed = false; }if (sched->map.comp && new_cpu)
tools/perf/util/thread.c +1 -0
@@ -212,6 +212,7 @@ static int ____thread__set_comm(struct thread *thread, const char *str,unwind__flush_access (thread); } + thread->comm_changed = true; thread->comm_set = true;return 0 ;
tools/perf/util/thread.h +1 -0
@@ -27,6 +27,7 @@ struct thread {int cpu;refcount_t refcnt;char shortname[3 ]; +bool comm_changed;bool comm_set;int comm_len;bool dead;/* if set thread has exited */
Signature · 1 line
2.7.4