Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf trace: Make the alignment of the syscall args be configurable

Since the start 'perf trace' aligns the parens enclosing the list of
syscall args to align the syscall results, allow this to be
configurable, keeping the default of 70. Using:

# perf config
llvm.dump-obj=true
trace.add_events=/home/acme/git/perf/tools/perf/examples/bpf/augmented_raw_syscalls.o
trace.show_zeros=yes
trace.show_duration=no
trace.no_inherit=yes
trace.show_timestamp=no
trace.show_arg_names=no
trace.args_alignment=0
# trace -e open*,close,*sleep sleep 1
openat(CWD, /etc/ld.so.cache, CLOEXEC) = 3
close(3) = 0
openat(CWD, /lib64/libc.so.6, CLOEXEC) = 3
close(3) = 0
openat(CWD, /usr/lib/locale/locale-archive, CLOEXEC) = 3
close(3) = 0
nanosleep(0x7ffc00de66f0, 0) = 0
close(1) = 0
close(2) = 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-r8cbhoz1lr5npq9tutpvoigr@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

+13 -3
+4
tools/perf/Documentation/perf-config.txt
··· 529 529 activate the 'perf trace' logic that looks for syscall 530 530 pointer contents after the normal tracepoint payload. 531 531 532 + trace.args_alignment:: 533 + Number of columns to align the argument list, default is 70, 534 + use 40 for the strace default, zero to no alignment. 535 + 532 536 trace.no_inherit:: 533 537 Do not follow children threads. 534 538
+9 -3
tools/perf/builtin-trace.c
··· 127 127 bool show_tool_stats; 128 128 bool trace_syscalls; 129 129 bool kernel_syscallchains; 130 + s16 args_alignment; 130 131 bool show_tstamp; 131 132 bool show_duration; 132 133 bool show_zeros; ··· 1732 1731 return 0; 1733 1732 1734 1733 printed = trace__fprintf_entry_head(trace, trace->current, 0, false, ttrace->entry_time, trace->output); 1735 - printed += fprintf(trace->output, "%-70s) ...\n", ttrace->entry_str); 1734 + printed += fprintf(trace->output, "%-*s) ...\n", trace->args_alignment, ttrace->entry_str); 1736 1735 ttrace->entry_pending = false; 1737 1736 1738 1737 ++trace->nr_events_printed; ··· 1839 1838 if (sc->is_exit) { 1840 1839 if (!(trace->duration_filter || trace->summary_only || trace->failure_only || trace->min_stack)) { 1841 1840 trace__fprintf_entry_head(trace, thread, 0, false, ttrace->entry_time, trace->output); 1842 - fprintf(trace->output, "%-70s)\n", ttrace->entry_str); 1841 + fprintf(trace->output, "%-*s)\n", trace->args_alignment, ttrace->entry_str); 1843 1842 } 1844 1843 } else { 1845 1844 ttrace->entry_pending = true; ··· 1982 1981 trace__fprintf_entry_head(trace, thread, duration, duration_calculated, ttrace->entry_time, trace->output); 1983 1982 1984 1983 if (ttrace->entry_pending) { 1985 - fprintf(trace->output, "%-70s", ttrace->entry_str); 1984 + fprintf(trace->output, "%-*s", trace->args_alignment, ttrace->entry_str); 1986 1985 } else { 1987 1986 fprintf(trace->output, " ... ["); 1988 1987 color_fprintf(trace->output, PERF_COLOR_YELLOW, "continued"); ··· 3564 3563 trace->show_zeros = new_show_zeros; 3565 3564 } else if (!strcmp(var, "trace.no_inherit")) { 3566 3565 trace->opts.no_inherit = perf_config_bool(var, value); 3566 + } else if (!strcmp(var, "trace.args_alignment")) { 3567 + int args_alignment = 0; 3568 + if (perf_config_int(&args_alignment, var, value) == 0) 3569 + trace->args_alignment = args_alignment; 3567 3570 } 3568 3571 out: 3569 3572 return err; ··· 3601 3596 .show_tstamp = true, 3602 3597 .show_duration = true, 3603 3598 .show_arg_names = true, 3599 + .args_alignment = 70, 3604 3600 .trace_syscalls = false, 3605 3601 .kernel_syscallchains = false, 3606 3602 .max_stack = UINT_MAX,