linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>, Thomas Gleixner <tglx@linutronix.de>
Cc: "Jiri Olsa" <jolsa@kernel.org>,
	"Namhyung Kim" <namhyung@kernel.org>,
	"Clark Williams" <williams@redhat.com>,
	linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
	"Arnaldo Carvalho de Melo" <acme@redhat.com>,
	"Adrian Hunter" <adrian.hunter@intel.com>,
	"Al Viro" <viro@zeniv.linux.org.uk>,
	"Brendan Gregg" <brendan.d.gregg@gmail.com>,
	"Luis Cláudio Gonçalves" <lclaudio@redhat.com>
Subject: [PATCH 14/44] perf trace: Beautify 'fsconfig' arguments
Date: Mon, 27 May 2019 19:37:00 -0300	[thread overview]
Message-ID: <20190527223730.11474-15-acme@kernel.org> (raw)
In-Reply-To: <20190527223730.11474-1-acme@kernel.org>

From: Arnaldo Carvalho de Melo <acme@redhat.com>

Use existing beautifiers for the first arg, fd, assigned using the
heuristic that looks for syscall arg names and associates SCA_FD with
'fd' named argumes, and wire up the recently introduced fsconfig cmd
table generator.

Now it should be possible to just use:

   perf trace -e fsconfig

As root and see all fsconfig syscalls with its args beautified, more
work needed to look at the command and according to it handle the 'key',
'value' and 'aux' args, using the 'fcntl' and 'futex' beautifiers as a
starting point to see how to suppress sets of these last three args that
may not be used by the 'cmd' arg, etc.

  # cat sys_fsconfig.c
  #define _GNU_SOURCE         /* See feature_test_macros(7) */
  #include <unistd.h>
  #include <sys/syscall.h>   /* For SYS_xxx definitions */
  #include <fcntl.h>

  #define __NR_fsconfig 431

  enum fsconfig_command {
  	FSCONFIG_SET_FLAG	= 0,	/* Set parameter, supplying no value */
  	FSCONFIG_SET_STRING	= 1,	/* Set parameter, supplying a string value */
  	FSCONFIG_SET_BINARY	= 2,	/* Set parameter, supplying a binary blob value */
  	FSCONFIG_SET_PATH	= 3,	/* Set parameter, supplying an object by path */
  	FSCONFIG_SET_PATH_EMPTY	= 4,	/* Set parameter, supplying an object by (empty) path */
  	FSCONFIG_SET_FD		= 5,	/* Set parameter, supplying an object by fd */
  	FSCONFIG_CMD_CREATE	= 6,	/* Invoke superblock creation */
  	FSCONFIG_CMD_RECONFIGURE = 7,	/* Invoke superblock reconfiguration */
  };

  static inline int sys_fsconfig(int fd, int cmd, const char *key, const void *value, int aux)
  {
  	syscall(__NR_fsconfig, fd, cmd, key, value, aux);
  }

  int main(int argc, char *argv[])
  {
  	int fd = 0, aux = 0;

  	open("/foo", 0);
  	sys_fsconfig(fd++, FSCONFIG_SET_FLAG,	     "/foo1", "/bar1", aux++);
  	sys_fsconfig(fd++, FSCONFIG_SET_STRING,	     "/foo2", "/bar2", aux++);
  	sys_fsconfig(fd++, FSCONFIG_SET_BINARY,	     "/foo3", "/bar3", aux++);
  	sys_fsconfig(fd++, FSCONFIG_SET_PATH,	     "/foo4", "/bar4", aux++);
  	sys_fsconfig(fd++, FSCONFIG_SET_PATH_EMPTY,  "/foo5", "/bar5", aux++);
  	sys_fsconfig(fd++, FSCONFIG_SET_FD,	     "/foo6", "/bar6", aux++);
  	sys_fsconfig(fd++, FSCONFIG_CMD_CREATE,	     "/foo7", "/bar7", aux++);
  	sys_fsconfig(fd++, FSCONFIG_CMD_RECONFIGURE, "/foo8", "/bar8", aux++);
  	return 0;
  }
  # trace -e fsconfig ./sys_fsconfig
  fsconfig(0, FSCONFIG_SET_FLAG, 0x40201b, 0x402015, 0) = -1 EINVAL (Invalid argument)
  fsconfig(1, FSCONFIG_SET_STRING, 0x402027, 0x402021, 1) = -1 EINVAL (Invalid argument)
  fsconfig(2, FSCONFIG_SET_BINARY, 0x402033, 0x40202d, 2) = -1 EINVAL (Invalid argument)
  fsconfig(3, FSCONFIG_SET_PATH, 0x40203f, 0x402039, 3) = -1 EBADF (Bad file descriptor)
  fsconfig(4, FSCONFIG_SET_PATH_EMPTY, 0x40204b, 0x402045, 4) = -1 EBADF (Bad file descriptor)
  fsconfig(5, FSCONFIG_SET_FD, 0x402057, 0x402051, 5) = -1 EINVAL (Invalid argument)
  fsconfig(6, FSCONFIG_CMD_CREATE, 0x402063, 0x40205d, 6) = -1 EINVAL (Invalid argument)
  fsconfig(7, FSCONFIG_CMD_RECONFIGURE, 0x40206f, 0x402069, 7) = -1 EINVAL (Invalid argument)
  #

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lkml.kernel.org/n/tip-fb04b76cm59zfuv1wzu40uxy@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/Makefile.perf   | 8 ++++++++
 tools/perf/builtin-trace.c | 6 ++++++
 2 files changed, 14 insertions(+)

diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index fe93f8c46080..22e92a9ee871 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -425,6 +425,12 @@ fspick_tbls := $(srctree)/tools/perf/trace/beauty/fspick.sh
 $(fspick_arrays): $(linux_uapi_dir)/fs.h $(fspick_tbls)
 	$(Q)$(SHELL) '$(fspick_tbls)' $(linux_uapi_dir) > $@
 
+fsconfig_arrays := $(beauty_outdir)/fsconfig_arrays.c
+fsconfig_tbls := $(srctree)/tools/perf/trace/beauty/fsconfig.sh
+
+$(fsconfig_arrays): $(linux_uapi_dir)/fs.h $(fsconfig_tbls)
+	$(Q)$(SHELL) '$(fsconfig_tbls)' $(linux_uapi_dir) > $@
+
 pkey_alloc_access_rights_array := $(beauty_outdir)/pkey_alloc_access_rights_array.c
 asm_generic_hdr_dir := $(srctree)/tools/include/uapi/asm-generic/
 pkey_alloc_access_rights_tbl := $(srctree)/tools/perf/trace/beauty/pkey_alloc_access_rights.sh
@@ -640,6 +646,7 @@ build-dir   = $(if $(__build-dir),$(__build-dir),.)
 
 prepare: $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)common-cmds.h archheaders $(drm_ioctl_array) \
 	$(fadvise_advice_array) \
+	$(fsconfig_arrays) \
 	$(fspick_arrays) \
 	$(pkey_alloc_access_rights_array) \
 	$(sndrv_pcm_ioctl_array) \
@@ -936,6 +943,7 @@ clean:: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clea
 		$(OUTPUT)tests/llvm-src-{base,kbuild,prologue,relocation}.c \
 		$(OUTPUT)pmu-events/pmu-events.c \
 		$(OUTPUT)$(fadvise_advice_array) \
+		$(OUTPUT)$(fsconfig_arrays) \
 		$(OUTPUT)$(fspick_arrays) \
 		$(OUTPUT)$(madvise_behavior_array) \
 		$(OUTPUT)$(mmap_flags_array) \
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 1643da631699..87b6dd3c33f5 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -482,6 +482,10 @@ static const char *bpf_cmd[] = {
 };
 static DEFINE_STRARRAY(bpf_cmd, "BPF_");
 
+#include "trace/beauty/generated/fsconfig_arrays.c"
+
+static DEFINE_STRARRAY(fsconfig_cmds, "FSCONFIG_");
+
 static const char *epoll_ctl_ops[] = { "ADD", "DEL", "MOD", };
 static DEFINE_STRARRAY_OFFSET(epoll_ctl_ops, "EPOLL_CTL_", 1);
 
@@ -713,6 +717,8 @@ static struct syscall_fmt {
 		   [2] = { .scnprintf =  SCA_FCNTL_ARG, /* arg */ }, }, },
 	{ .name	    = "flock",
 	  .arg = { [1] = { .scnprintf = SCA_FLOCK, /* cmd */ }, }, },
+	{ .name     = "fsconfig",
+	  .arg = { [1] = STRARRAY(cmd, fsconfig_cmds), }, },
 	{ .name     = "fspick",
 	  .arg = { [0] = { .scnprintf = SCA_FDAT,	  /* dfd */ },
 		   [1] = { .scnprintf = SCA_FILENAME,	  /* path */ },
-- 
2.20.1


  parent reply	other threads:[~2019-05-27 22:38 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-27 22:36 [GIT PULL] perf/urgent improvements and fixes Arnaldo Carvalho de Melo
2019-05-27 22:36 ` [PATCH 01/44] perf-with-kcore.sh: Always allow fix_buildid_cache_permissions Arnaldo Carvalho de Melo
2019-05-27 22:36 ` [PATCH 02/44] perf intel-pt: Fix itrace defaults for perf script Arnaldo Carvalho de Melo
2019-05-27 22:36 ` [PATCH 03/44] perf auxtrace: " Arnaldo Carvalho de Melo
2019-05-27 22:36 ` [PATCH 04/44] perf intel-pt: Fix itrace defaults for perf script intel-pt documentation Arnaldo Carvalho de Melo
2019-05-27 22:36 ` [PATCH 05/44] perf data: Fix 'strncat may truncate' build failure with recent gcc Arnaldo Carvalho de Melo
2019-05-27 22:46   ` Shawn Landden
2019-05-28 13:04     ` Arnaldo Carvalho de Melo
2019-05-28 16:59       ` Shawn Landden
2019-05-28 17:39         ` Arnaldo Carvalho de Melo
2019-05-27 22:36 ` [PATCH 06/44] perf arm64: Fix mksyscalltbl when system kernel headers are ahead of the kernel Arnaldo Carvalho de Melo
2019-05-27 22:36 ` [PATCH 07/44] tools include UAPI: Update copy of files related to new fspick, fsmount, fsconfig, fsopen, move_mount and open_tree syscalls Arnaldo Carvalho de Melo
2019-05-27 22:36 ` [PATCH 08/44] perf augmented_raw_syscalls: Fix up comment Arnaldo Carvalho de Melo
2019-05-27 22:36 ` [PATCH 09/44] perf beauty: Add generator for 'move_mount' flags argument Arnaldo Carvalho de Melo
2019-05-27 22:36 ` [PATCH 10/44] perf trace: Beautify 'move_mount' arguments Arnaldo Carvalho de Melo
2019-05-27 22:36 ` [PATCH 11/44] perf beauty: Add generator for fspick's 'flags' arg values Arnaldo Carvalho de Melo
2019-05-27 22:36 ` [PATCH 12/44] perf trace: Beautify 'fspick' arguments Arnaldo Carvalho de Melo
2019-05-27 22:36 ` [PATCH 13/44] perf beauty: Add generator for fsconfig's 'cmd' arg values Arnaldo Carvalho de Melo
2019-05-27 22:37 ` Arnaldo Carvalho de Melo [this message]
2019-05-27 22:37 ` [PATCH 15/44] perf beauty: Add generator for fsmount's 'attr_flags' " Arnaldo Carvalho de Melo
2019-05-27 22:37 ` [PATCH 16/44] perf trace: Introduce syscall_arg__scnprintf_strarray_flags Arnaldo Carvalho de Melo
2019-05-27 22:37 ` [PATCH 17/44] perf trace: Beautify 'fsmount' arguments Arnaldo Carvalho de Melo
2019-05-27 22:37 ` [PATCH 18/44] tools arch x86: Sync asm/cpufeatures.h with the with the kernel Arnaldo Carvalho de Melo
2019-05-27 22:37 ` [PATCH 19/44] tools headers UAPI: Sync linux/sched.h " Arnaldo Carvalho de Melo
2019-05-27 22:37 ` [PATCH 20/44] perf trace beauty clone: Handle CLONE_PIDFD Arnaldo Carvalho de Melo
2019-05-27 22:37 ` [PATCH 21/44] tools headers UAPI: Sync linux/fs.h with the kernel Arnaldo Carvalho de Melo
2019-05-27 22:37 ` [PATCH 22/44] perf beauty: Add generator for sync_file_range's 'flags' arg values Arnaldo Carvalho de Melo
2019-05-27 22:37 ` [PATCH 23/44] perf trace: Beautify 'sync_file_range' arguments Arnaldo Carvalho de Melo
2019-05-27 22:37 ` [PATCH 24/44] tools headers UAPI: Sync drm/i915_drm.h with the kernel Arnaldo Carvalho de Melo
2019-05-27 22:37 ` [PATCH 25/44] tools headers UAPI: Sync drm/drm.h " Arnaldo Carvalho de Melo
2019-05-28  3:17   ` Zhou, David(ChunMing)
2019-05-28  8:07   ` Lionel Landwerlin
2019-05-28 12:53     ` Arnaldo Carvalho de Melo
2019-05-27 22:37 ` [PATCH 26/44] perf namespace: Protect reading thread's namespace Arnaldo Carvalho de Melo
2019-05-27 22:37 ` [PATCH 27/44] perf session: Add missing swap ops for namespace events Arnaldo Carvalho de Melo
2019-05-27 22:37 ` [PATCH 28/44] perf top: Add --namespaces option Arnaldo Carvalho de Melo
2019-05-27 22:37 ` [PATCH 29/44] perf tools: Remove const from thread read accessors Arnaldo Carvalho de Melo
2019-05-27 22:37 ` [PATCH 30/44] perf dso: Separate generic code in dso__data_file_size() Arnaldo Carvalho de Melo
2019-05-27 22:37 ` [PATCH 31/44] perf dso: Separate generic code in dso_cache__read Arnaldo Carvalho de Melo
2019-05-27 22:37 ` [PATCH 32/44] perf dso: Simplify dso_cache__read function Arnaldo Carvalho de Melo
2019-05-27 22:37 ` [PATCH 33/44] perf dso: Add BPF DSO read and size hooks Arnaldo Carvalho de Melo
2019-05-27 22:37 ` [PATCH 34/44] perf test vmlinux-kallsyms: Ignore aliases to _etext when searching on kallsyms Arnaldo Carvalho de Melo
2019-05-27 22:37 ` [PATCH 35/44] perf machine: Read also the end of the kernel Arnaldo Carvalho de Melo
2019-05-27 22:37 ` [PATCH 36/44] perf machine: Keep zero in pgoff BPF map Arnaldo Carvalho de Melo
2019-05-27 22:37 ` [PATCH 37/44] perf tools: Preserve eBPF maps when loading kcore Arnaldo Carvalho de Melo
2019-05-27 22:37 ` [PATCH 38/44] perf script: Pad DSO name for --call-trace Arnaldo Carvalho de Melo
2019-05-27 22:37 ` [PATCH 39/44] perf tests: Add map_groups__merge_in test Arnaldo Carvalho de Melo
2019-05-27 22:37 ` [PATCH 40/44] perf script: Add --show-bpf-events to show eBPF related events Arnaldo Carvalho de Melo
2019-05-27 22:37 ` [PATCH 41/44] perf script: Remove superfluous BPF event titles Arnaldo Carvalho de Melo
2019-05-27 22:37 ` [PATCH 42/44] perf version: Append 12 git SHA chars to the version string Arnaldo Carvalho de Melo
2019-05-27 22:37 ` [PATCH 43/44] perf record: Fix s390 missing module symbol and warning for non-root users Arnaldo Carvalho de Melo
2019-05-27 22:37 ` [PATCH 44/44] tools headers UAPI: Sync kvm.h headers with the kernel sources Arnaldo Carvalho de Melo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190527223730.11474-15-acme@kernel.org \
    --to=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=adrian.hunter@intel.com \
    --cc=brendan.d.gregg@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=lclaudio@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=viro@zeniv.linux.org.uk \
    --cc=williams@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).