Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 42e4a52d authored by Arnaldo Carvalho de Melo's avatar Arnaldo Carvalho de Melo
Browse files

perf trace: Allow configuring if the syscall duration should be printed

  # perf config trace.show_duration=no
  # perf config -l | grep trace
  trace.default_events=/home/acme/git/perf/tools/perf/examples/bpf/augmented_raw_syscalls.o
  trace.show_zeros=true
  trace.show_duration=no
  # trace -e *sleep sleep 1
     0.000 sleep/8729 nanosleep(rqtp: 0x7ffcb0b4c940, rmtp: 0) = 0
  # perf config trace.show_duration=yes
  # trace -e *sleep sleep 1
     0.000 (1000.212 ms): sleep/8735 nanosleep(rqtp: 0x7ffca15fa770, rmtp: 0) = 0
  #

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: https://lkml.kernel.org/n/tip-2c7h1m8fhzb9puxtj9nlevi8@git.kernel.org


Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent e7c634fc
Loading
Loading
Loading
Loading
+4 −0
Original line number Original line Diff line number Diff line
@@ -528,6 +528,10 @@ trace.*::
		The initial use case is to add augmented_raw_syscalls.o to
		The initial use case is to add augmented_raw_syscalls.o to
		activate the 'perf trace' logic that looks for syscall
		activate the 'perf trace' logic that looks for syscall
		pointer contents after the normal tracepoint payload.
		pointer contents after the normal tracepoint payload.

	trace.show_duration::
		Show syscall duration.

	trace.show_zeros::
	trace.show_zeros::
		Do not suppress syscall arguments that are equal to zero.
		Do not suppress syscall arguments that are equal to zero.


+7 −2
Original line number Original line Diff line number Diff line
@@ -127,6 +127,7 @@ struct trace {
	bool			show_tool_stats;
	bool			show_tool_stats;
	bool			trace_syscalls;
	bool			trace_syscalls;
	bool			kernel_syscallchains;
	bool			kernel_syscallchains;
	bool			show_duration;
	bool			show_zeros;
	bool			show_zeros;
	bool			force;
	bool			force;
	bool			vfs_getname;
	bool			vfs_getname;
@@ -1215,6 +1216,7 @@ static size_t trace__fprintf_entry_head(struct trace *trace, struct thread *thre
					u64 duration, bool duration_calculated, u64 tstamp, FILE *fp)
					u64 duration, bool duration_calculated, u64 tstamp, FILE *fp)
{
{
	size_t printed = trace__fprintf_tstamp(trace, tstamp, fp);
	size_t printed = trace__fprintf_tstamp(trace, tstamp, fp);
	if (trace->show_duration)
		printed += fprintf_duration(duration, duration_calculated, fp);
		printed += fprintf_duration(duration, duration_calculated, fp);
	return printed + trace__fprintf_comm_tid(trace, thread, fp);
	return printed + trace__fprintf_comm_tid(trace, thread, fp);
}
}
@@ -2190,7 +2192,7 @@ static int trace__event_handler(struct trace *trace, struct perf_evsel *evsel,
	trace__printf_interrupted_entry(trace);
	trace__printf_interrupted_entry(trace);
	trace__fprintf_tstamp(trace, sample->time, trace->output);
	trace__fprintf_tstamp(trace, sample->time, trace->output);


	if (trace->trace_syscalls)
	if (trace->trace_syscalls && trace->show_duration)
		fprintf(trace->output, "(         ): ");
		fprintf(trace->output, "(         ): ");


	if (thread)
	if (thread)
@@ -3536,6 +3538,8 @@ static int trace__config(const char *var, const char *value, void *arg)
					       "event selector. use 'perf list' to list available events",
					       "event selector. use 'perf list' to list available events",
					       parse_events_option);
					       parse_events_option);
		err = parse_events_option(&o, value, 0);
		err = parse_events_option(&o, value, 0);
	} else if (!strcmp(var, "trace.show_duration")) {
		trace->show_duration = perf_config_bool(var, value);
	} else if (!strcmp(var, "trace.show_zeros")) {
	} else if (!strcmp(var, "trace.show_zeros")) {
		trace->show_zeros = perf_config_bool(var, value);
		trace->show_zeros = perf_config_bool(var, value);
	}
	}
@@ -3568,6 +3572,7 @@ int cmd_trace(int argc, const char **argv)
		},
		},
		.output = stderr,
		.output = stderr,
		.show_comm = true,
		.show_comm = true,
		.show_duration = true,
		.trace_syscalls = false,
		.trace_syscalls = false,
		.kernel_syscallchains = false,
		.kernel_syscallchains = false,
		.max_stack = UINT_MAX,
		.max_stack = UINT_MAX,