perf tools: Add new COMM infrastructure
tip-bot for Frederic Weisbecker
merge botCommit-ID: 1902efe7f626fdebe1520f5ff11f1309ec506708 Gitweb: http://git.kernel.org/tip/1902efe7f626fdebe1520f5ff11f1309ec506708 Author: Frederic Weisbecker <[email protected]> AuthorDate: Wed, 11 Sep 2013 16:56:44 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 4 Nov 2013 12:13:53 -0300
perf tools: Add new COMM infrastructure
This new COMM infrastructure provides two features:
1) It keeps track of all comms lifecycle for a given thread. This way we can associate a timeframe to any thread COMM, as long as PERF_SAMPLE_TIME samples are joined to COMM and fork events.
As a result we should have more precise COMM sorted hists with seperated entries for pre and post exec time after a fork.
2) It also makes sure that a given COMM string is not duplicated but rather shared among the threads that refer to it. This way the threads COMM can be compared against pointer values from the sort infrastructure.
Signed-off-by Frederic Weisbecker <[email protected]>
Tested-by Jiri Olsa <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc David Ahern <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Stephane Eranian <[email protected]>
[ Rename some accessor functions ]
Signed-off-by Namhyung Kim <[email protected]>
[ Use __ as separator for class__method for private comm_str methods ]
Signed-off-by Arnaldo Carvalho de Melo <[email protected]>
--- tools/perf/Makefile.perf | 2 + tools/perf/builtin-trace.c | 4 +- tools/perf/util/comm.c | 106 +++++++++++++++++++++++++++++++++++++++++++++ tools/perf/util/comm.h | 20 +++++++++ tools/perf/util/thread.c | 92 +++++++++++++++++++++++++++++---------- tools/perf/util/thread.h | 3 +- 6 files changed, 200 insertions(+), 27 deletions(-)
tools/perf/Makefile.perf +2 -0
@@ -273,6 +273,7 @@ LIB_H += util/color.h LIB_H += util/values.h LIB_H += util/sort.h LIB_H += util/hist.h +LIB_H += util/comm.h LIB_H += util/thread.h LIB_H += util/thread_map.h LIB_H += util/trace-event.h
@@ -341,6 +342,7 @@ LIB_OBJS += $(OUTPUT)util/machine.o LIB_OBJS += $(OUTPUT)util/map.o LIB_OBJS += $(OUTPUT)util/pstack.o LIB_OBJS += $(OUTPUT)util/session.o +LIB_OBJS += $(OUTPUT)util/comm.o LIB_OBJS += $(OUTPUT)util/thread.o LIB_OBJS += $(OUTPUT)util/thread_map.o LIB_OBJS += $(OUTPUT)util/trace-event-parse.o
tools/perf/builtin-trace.c +2 -2
@@ -1114,7 +1114,7 @@ static size_t trace__fprintf_entry_head(struct trace *trace, struct thread *threif (trace->multiple_threads) {if (trace->show_comm) - printed +=fprintf (fp,"%.14s/" , thread->comm); + printed +=fprintf (fp,"%.14s/" ,thread__comm_str (thread)); printed +=fprintf (fp,"%d " , thread->tid); }
@@ -1986,7 +1986,7 @@ static int trace__fprintf_one_thread(struct thread *thread, void *priv)else if (ratio >5.0 ) color =PERF_COLOR_YELLOW ; - printed +=color_fprintf (fp, color,"%20s" , thread->comm); + printed +=color_fprintf (fp, color,"%20s" ,thread__comm_str (thread)); printed +=fprintf (fp," - %-5d :%11lu [" , thread->tid, ttrace->nr_events); printed +=color_fprintf (fp, color,"%5.1f%%" , ratio); printed +=fprintf (fp," ] %10.3f ms\n" , ttrace->runtime_ms);
tools/perf/util/comm.c new file +106 -0
106 lines not on this page · raw message
tools/perf/util/comm.h new file +20 -0
@@ -0,0 +1,20 @@ +#ifndef __PERF_COMM_H +#define __PERF_COMM_H + +#include "../perf.h" +#include <linux/rbtree.h> +#include <linux/list.h> + +struct comm_str ; + +struct comm { +struct comm_str *comm_str; +u64 start; +struct list_head list; +}; + +void comm__free (struct comm *comm); +struct comm *comm__new (const char *str,u64 timestamp); +const char *comm__str (const struct comm *comm); + +#endif /* __PERF_COMM_H */
tools/perf/util/thread.c +68 -24
141 lines not on this page · raw message
tools/perf/util/thread.h +2 -1
@@ -2,6 +2,7 @@#define __PERF_THREAD_H#include <linux/rbtree.h> +#include <linux/list.h> #include <unistd.h> #include <sys/types.h> #include "symbol.h"
@@ -18,7 +19,7 @@ struct thread {char shortname[3 ];bool comm_set;bool dead;/* if set thread has exited */ -char *comm; +struct list_head comm_list;int comm_len;void *priv;