Skip to contentSkip to conversation

perf trace: Use a constant for the syscall formatting buffer

tip:perf/core tip-bot for Arnaldo Carvalho de Melo 1 participant 1 message Aug 6, 2015 perf events

lore
Share & tools
lore
#0 lore raw
Commit-ID:  e4d44e830a4bbeb0cf6fdd24c24794a2e599e26d
Gitweb:     http://git.kernel.org/tip/e4d44e830a4bbeb0cf6fdd24c24794a2e599e26d
Author:     Arnaldo Carvalho de Melo <[email protected]>
AuthorDate: Tue, 4 Aug 2015 22:17:29 -0300
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Wed, 5 Aug 2015 10:52:40 -0300

perf trace: Use a constant for the syscall formatting buffer

We were using it as a magic number, 1024, fix that.

Eventually we need to stop doing it per line, and do it per arg, traversing the args at output time, to avoid the memmove() calls that will be used in the next cset to replace pointers present at raw_syscalls:sys_enter time with its contents that appear at probe:vfs_getname time, before raw_syscalls:sys_exit time.

Cc Adrian Hunter <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc David Ahern <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Milian Wolff <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Stephane Eranian <[email protected]>
---
 tools/perf/builtin-trace.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
tools/perf/builtin-trace.c +5 -3
index aa1e288..12d6fc0 100644
@@ -1262,6 +1262,8 @@ fail:
 #define TRACE_PFMAJ		(1 << 0)
 #define TRACE_PFMIN		(1 << 1)
 
+static const size_t trace__entry_str_size = 2048;
+
 struct trace {
 	struct perf_tool	tool;
 	struct {
@@ -1822,7 +1824,7 @@ static int trace__sys_enter(struct trace *trace, struct perf_evsel *evsel,
 	args = perf_evsel__sc_tp_ptr(evsel, args, sample);
 
 	if (ttrace->entry_str == NULL) {
-		ttrace->entry_str = malloc(1024);
+		ttrace->entry_str = malloc(trace__entry_str_size);
 		if (!ttrace->entry_str)
 			goto out_put;
 	}
@@ -1832,9 +1834,9 @@ static int trace__sys_enter(struct trace *trace, struct perf_evsel *evsel,
 
 	ttrace->entry_time = sample->time;
 	msg = ttrace->entry_str;
-	printed += scnprintf(msg + printed, 1024 - printed, "%s(", sc->name);
+	printed += scnprintf(msg + printed, trace__entry_str_size - printed, "%s(", sc->name);
 
-	printed += syscall__scnprintf_args(sc, msg + printed, 1024 - printed,
+	printed += syscall__scnprintf_args(sc, msg + printed, trace__entry_str_size - printed,
 					   args, trace, thread);
 
 	if (sc->is_exit) {