Skip to contentSkip to conversation

perf trace: Cache the is_exit syscall test

tip:perf/core tip-bot for Arnaldo Carvalho de Melo 1 participant 1 message Jun 25, 2014 perf events

lore
Share & tools
lore
#0 lore raw
Commit-ID:  5089f20ee7104bd219cafefa62d83f53e75cc44c
Gitweb:     http://git.kernel.org/tip/5089f20ee7104bd219cafefa62d83f53e75cc44c
Author:     Arnaldo Carvalho de Melo <[email protected]>
AuthorDate: Tue, 17 Jun 2014 14:29:24 -0300
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Thu, 19 Jun 2014 16:13:13 -0300

perf trace: Cache the is_exit syscall test

No need to use two strcmp calls per syscall entry, do it just once, when reading the per syscall info.

Cc Adrian Hunter <[email protected]>
Cc David Ahern <[email protected]>
Cc Don Zickus <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Mike Galbraith <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Stephane Eranian <[email protected]>
---
 tools/perf/builtin-trace.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
tools/perf/builtin-trace.c +4 -1
index 28c86e2..5549cee 100644
@@ -1108,6 +1108,7 @@ struct syscall {
 	struct event_format *tp_format;
 	const char	    *name;
 	bool		    filtered;
+	bool		    is_exit;
 	struct syscall_fmt  *fmt;
 	size_t		    (**arg_scnprintf)(char *bf, size_t size, struct syscall_arg *arg);
 	void		    **arg_parm;
@@ -1473,6 +1474,8 @@ static int trace__read_syscall_info(struct trace *trace, int id)
 	if (sc->tp_format == NULL)
 		return -1;
 
+	sc->is_exit = !strcmp(name, "exit_group") || !strcmp(name, "exit");
+
 	return syscall__set_arg_fmts(sc);
 }
 
@@ -1643,7 +1646,7 @@ static int trace__sys_enter(struct trace *trace, struct perf_evsel *evsel,
 	printed += syscall__scnprintf_args(sc, msg + printed, 1024 - printed,
 					   args, trace, thread);
 
-	if (!strcmp(sc->name, "exit_group") || !strcmp(sc->name, "exit")) {
+	if (sc->is_exit) {
 		if (!trace->duration_filter && !trace->summary_only) {
 			trace__fprintf_entry_head(trace, thread, 1, sample->time, trace->output);
 			fprintf(trace->output, "%-70s\n", ttrace->entry_str);