From 12a2379e13684ab40dbd4d757ffecd723364b2b8 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Mon, 20 May 2019 14:58:03 -0300 Subject: perf trace: Beautify 'move_mount' arguments Use existing beautifiers for the first 4 args (to/from fds, pathnames) and wire up the recently introduced move_mount flags table generator. Now it should be possible to just use: perf trace -e move_mount As root and see all move_mount syscalls with its args beautified, either using the vfs_getname perf probe methor or using the augmented_raw_syscalls.c eBPF helper to get the pathnames, the other args should work in all cases, i.e. all that is needed can be obtained directly from the raw_syscalls:sys_enter tracepoint args. Cc: Adrian Hunter Cc: Al Viro Cc: Brendan Gregg Cc: David Howells Cc: Jiri Olsa Cc: Namhyung Kim Link: https://lkml.kernel.org/n/tip-96jqjxzlue9k5aveciqccb09@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/Makefile.perf | 8 ++++++++ tools/perf/builtin-trace.c | 6 ++++++ tools/perf/trace/beauty/Build | 1 + tools/perf/trace/beauty/beauty.h | 3 +++ tools/perf/trace/beauty/move_mount.c | 24 ++++++++++++++++++++++++ 5 files changed, 42 insertions(+) create mode 100644 tools/perf/trace/beauty/move_mount.c diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index c706548d5b10..20448d8cc162 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf @@ -493,6 +493,12 @@ mount_flags_tbl := $(srctree)/tools/perf/trace/beauty/mount_flags.sh $(mount_flags_array): $(linux_uapi_dir)/fs.h $(mount_flags_tbl) $(Q)$(SHELL) '$(mount_flags_tbl)' $(linux_uapi_dir) > $@ +move_mount_flags_array := $(beauty_outdir)/move_mount_flags_array.c +move_mount_flags_tbl := $(srctree)/tools/perf/trace/beauty/move_mount_flags.sh + +$(move_mount_flags_array): $(linux_uapi_dir)/fs.h $(move_mount_flags_tbl) + $(Q)$(SHELL) '$(move_mount_flags_tbl)' $(linux_uapi_dir) > $@ + prctl_option_array := $(beauty_outdir)/prctl_option_array.c prctl_hdr_dir := $(srctree)/tools/include/uapi/linux/ prctl_option_tbl := $(srctree)/tools/perf/trace/beauty/prctl_option.sh @@ -638,6 +644,7 @@ prepare: $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)common-cmds.h archheaders $(drm_ioc $(madvise_behavior_array) \ $(mmap_flags_array) \ $(mount_flags_array) \ + $(move_mount_flags_array) \ $(perf_ioctl_array) \ $(prctl_option_array) \ $(usbdevfs_ioctl_array) \ @@ -925,6 +932,7 @@ clean:: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clea $(OUTPUT)$(madvise_behavior_array) \ $(OUTPUT)$(mmap_flags_array) \ $(OUTPUT)$(mount_flags_array) \ + $(OUTPUT)$(move_mount_flags_array) \ $(OUTPUT)$(drm_ioctl_array) \ $(OUTPUT)$(pkey_alloc_access_rights_array) \ $(OUTPUT)$(sndrv_ctl_ioctl_array) \ diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index f5b3a1e9c1dd..b76c950e4393 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -775,6 +775,12 @@ static struct syscall_fmt { .arg = { [0] = { .scnprintf = SCA_FILENAME, /* dev_name */ }, [3] = { .scnprintf = SCA_MOUNT_FLAGS, /* flags */ .mask_val = SCAMV_MOUNT_FLAGS, /* flags */ }, }, }, + { .name = "move_mount", + .arg = { [0] = { .scnprintf = SCA_FDAT, /* from_dfd */ }, + [1] = { .scnprintf = SCA_FILENAME, /* from_pathname */ }, + [2] = { .scnprintf = SCA_FDAT, /* to_dfd */ }, + [3] = { .scnprintf = SCA_FILENAME, /* to_pathname */ }, + [4] = { .scnprintf = SCA_MOVE_MOUNT_FLAGS, /* flags */ }, }, }, { .name = "mprotect", .arg = { [0] = { .scnprintf = SCA_HEX, /* start */ }, [2] = { .scnprintf = SCA_MMAP_PROT, /* prot */ }, }, }, diff --git a/tools/perf/trace/beauty/Build b/tools/perf/trace/beauty/Build index 85f328ddf897..d84812c094ba 100644 --- a/tools/perf/trace/beauty/Build +++ b/tools/perf/trace/beauty/Build @@ -6,6 +6,7 @@ perf-y += ioctl.o endif perf-y += kcmp.o perf-y += mount_flags.o +perf-y += move_mount.o perf-y += pkey_alloc.o perf-y += arch_prctl.o perf-y += prctl.o diff --git a/tools/perf/trace/beauty/beauty.h b/tools/perf/trace/beauty/beauty.h index 139d485a6f16..dfb84032d8eb 100644 --- a/tools/perf/trace/beauty/beauty.h +++ b/tools/perf/trace/beauty/beauty.h @@ -156,6 +156,9 @@ unsigned long syscall_arg__mask_val_mount_flags(struct syscall_arg *arg, unsigne size_t syscall_arg__scnprintf_mount_flags(char *bf, size_t size, struct syscall_arg *arg); #define SCA_MOUNT_FLAGS syscall_arg__scnprintf_mount_flags +size_t syscall_arg__scnprintf_move_mount_flags(char *bf, size_t size, struct syscall_arg *arg); +#define SCA_MOVE_MOUNT_FLAGS syscall_arg__scnprintf_move_mount_flags + size_t syscall_arg__scnprintf_pkey_alloc_access_rights(char *bf, size_t size, struct syscall_arg *arg); #define SCA_PKEY_ALLOC_ACCESS_RIGHTS syscall_arg__scnprintf_pkey_alloc_access_rights diff --git a/tools/perf/trace/beauty/move_mount.c b/tools/perf/trace/beauty/move_mount.c new file mode 100644 index 000000000000..78ed80395406 --- /dev/null +++ b/tools/perf/trace/beauty/move_mount.c @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: LGPL-2.1 +/* + * trace/beauty/move_mount.c + * + * Copyright (C) 2019, Red Hat Inc, Arnaldo Carvalho de Melo + */ + +#include "trace/beauty/beauty.h" +#include + +static size_t move_mount__scnprintf_flags(unsigned long flags, char *bf, size_t size, bool show_prefix) +{ +#include "trace/beauty/generated/move_mount_flags_array.c" + static DEFINE_STRARRAY(move_mount_flags, "MOVE_MOUNT_"); + + return strarray__scnprintf_flags(&strarray__move_mount_flags, bf, size, show_prefix, flags); +} + +size_t syscall_arg__scnprintf_move_mount_flags(char *bf, size_t size, struct syscall_arg *arg) +{ + unsigned long flags = arg->val; + + return move_mount__scnprintf_flags(flags, bf, size, arg->show_string_prefix); +} -- cgit v1.2.3