perf trace: Use macro RAW_SYSCALL_ARGS_NUM to replace number

This patch defines a macro RAW_SYSCALL_ARGS_NUM to replace the open
coded number '6'.

Signed-off-by: Leo Yan <leo.yan@linaro.org>
Acked-by: Ian Rogers <irogers@google.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: bpf@vger.kernel.org
Link: https://lore.kernel.org/r/20221121075237.127706-2-leo.yan@linaro.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Leo Yan 2022-11-21 07:52:33 +00:00 committed by Arnaldo Carvalho de Melo
parent 6ed249441a
commit eadcab4c7a

View File

@ -88,6 +88,8 @@
# define F_LINUX_SPECIFIC_BASE 1024 # define F_LINUX_SPECIFIC_BASE 1024
#endif #endif
#define RAW_SYSCALL_ARGS_NUM 6
/* /*
* strtoul: Go from a string to a value, i.e. for msr: MSR_FS_BASE to 0xc0000100 * strtoul: Go from a string to a value, i.e. for msr: MSR_FS_BASE to 0xc0000100
*/ */
@ -108,7 +110,7 @@ struct syscall_fmt {
const char *sys_enter, const char *sys_enter,
*sys_exit; *sys_exit;
} bpf_prog_name; } bpf_prog_name;
struct syscall_arg_fmt arg[6]; struct syscall_arg_fmt arg[RAW_SYSCALL_ARGS_NUM];
u8 nr_args; u8 nr_args;
bool errpid; bool errpid;
bool timeout; bool timeout;
@ -1229,7 +1231,7 @@ struct syscall {
*/ */
struct bpf_map_syscall_entry { struct bpf_map_syscall_entry {
bool enabled; bool enabled;
u16 string_args_len[6]; u16 string_args_len[RAW_SYSCALL_ARGS_NUM];
}; };
/* /*
@ -1661,7 +1663,7 @@ static int syscall__alloc_arg_fmts(struct syscall *sc, int nr_args)
{ {
int idx; int idx;
if (nr_args == 6 && sc->fmt && sc->fmt->nr_args != 0) if (nr_args == RAW_SYSCALL_ARGS_NUM && sc->fmt && sc->fmt->nr_args != 0)
nr_args = sc->fmt->nr_args; nr_args = sc->fmt->nr_args;
sc->arg_fmt = calloc(nr_args, sizeof(*sc->arg_fmt)); sc->arg_fmt = calloc(nr_args, sizeof(*sc->arg_fmt));
@ -1812,7 +1814,8 @@ static int trace__read_syscall_info(struct trace *trace, int id)
sc->tp_format = trace_event__tp_format("syscalls", tp_name); sc->tp_format = trace_event__tp_format("syscalls", tp_name);
} }
if (syscall__alloc_arg_fmts(sc, IS_ERR(sc->tp_format) ? 6 : sc->tp_format->format.nr_fields)) if (syscall__alloc_arg_fmts(sc, IS_ERR(sc->tp_format) ?
RAW_SYSCALL_ARGS_NUM : sc->tp_format->format.nr_fields))
return -ENOMEM; return -ENOMEM;
if (IS_ERR(sc->tp_format)) if (IS_ERR(sc->tp_format))