Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1691701

[PATCH 08/86] perf trace beauty: Mask ignored fcntl 'arg' parameter

From Arnaldo Carvalho de Melo <acme@kernel.org>
Newsgroups linux.kernel
Subject [PATCH 08/86] perf trace beauty: Mask ignored fcntl 'arg' parameter
Date 2017-07-19 16:10 +0200
Message-ID <u4XPQ-1bD-15@gated-at.bofh.it> (permalink)
References <u4XG9-SU-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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

A series of fcntl cmds ignore the third argument, so mask it.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-6vtl3zq1tauamrhm8o380ptn@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-trace.c       |  2 +-
 tools/perf/trace/beauty/Build    |  1 +
 tools/perf/trace/beauty/beauty.h |  3 +++
 tools/perf/trace/beauty/fcntl.c  | 23 +++++++++++++++++++++++
 4 files changed, 28 insertions(+), 1 deletion(-)
 create mode 100644 tools/perf/trace/beauty/fcntl.c

diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index ef1b1d4ea007..b7f79dea3c44 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -661,7 +661,7 @@ static struct syscall_fmt {
 	{ .name	    = "fchownat",   .errmsg = true,
 	  .arg_scnprintf = { [0] = SCA_FDAT, /* fd */ }, },
 	{ .name	    = "fcntl",	    .errmsg = true,
-	  .arg_scnprintf = { [1] = SCA_STRARRAYS, /* cmd */ },
+	  .arg_scnprintf = { [1] = SCA_FCNTL_CMD, /* cmd */ },
 	  .arg_parm	 = { [1] = &strarrays__fcntl_cmds_arrays, /* cmd */ }, },
 	{ .name	    = "fdatasync",  .errmsg = true, },
 	{ .name	    = "flock",	    .errmsg = true,
diff --git a/tools/perf/trace/beauty/Build b/tools/perf/trace/beauty/Build
index be95ac6ce845..c9e215b806f1 100644
--- a/tools/perf/trace/beauty/Build
+++ b/tools/perf/trace/beauty/Build
@@ -1 +1,2 @@
+libperf-y += fcntl.o
 libperf-y += statx.o
diff --git a/tools/perf/trace/beauty/beauty.h b/tools/perf/trace/beauty/beauty.h
index a6348073a6e9..ce01079d8422 100644
--- a/tools/perf/trace/beauty/beauty.h
+++ b/tools/perf/trace/beauty/beauty.h
@@ -18,6 +18,9 @@ struct syscall_arg {
 size_t syscall_arg__scnprintf_strarrays(char *bf, size_t size, struct syscall_arg *arg);
 #define SCA_STRARRAYS syscall_arg__scnprintf_strarrays
 
+size_t syscall_arg__scnprintf_fcntl_cmd(char *bf, size_t size, struct syscall_arg *arg);
+#define SCA_FCNTL_CMD syscall_arg__scnprintf_fcntl_cmd
+
 size_t syscall_arg__scnprintf_statx_flags(char *bf, size_t size, struct syscall_arg *arg);
 #define SCA_STATX_FLAGS syscall_arg__scnprintf_statx_flags
 
diff --git a/tools/perf/trace/beauty/fcntl.c b/tools/perf/trace/beauty/fcntl.c
new file mode 100644
index 000000000000..7e4582c9308e
--- /dev/null
+++ b/tools/perf/trace/beauty/fcntl.c
@@ -0,0 +1,23 @@
+/*
+ * trace/beauty/fcntl.c
+ *
+ *  Copyright (C) 2017, Red Hat Inc, Arnaldo Carvalho de Melo <acme@redhat.com>
+ *
+ * Released under the GPL v2. (and only v2, not any later version)
+ */
+
+#include "trace/beauty/beauty.h"
+#include <uapi/linux/fcntl.h>
+
+size_t syscall_arg__scnprintf_fcntl_cmd(char *bf, size_t size, struct syscall_arg *arg)
+{
+	/*
+	 * Some commands ignore the third fcntl argument, "arg", so mask it
+	 */
+	if (arg->val == F_GETFD	   || arg->val == F_GETFL     ||
+	    arg->val == F_GETOWN   || arg->val == F_GET_SEALS ||
+	    arg->val == F_GETLEASE || arg->val == F_GETSIG)
+		arg->mask |= (1 << 2);
+
+	return syscall_arg__scnprintf_strarrays(bf, size, arg);
+}
-- 
2.9.4

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[GIT PULL 00/86] perf/core improvements and fixes Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-19 16:00 +0200
  [PATCH 02/86] perf annotate: Implement visual marker for macro fusion Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-19 16:00 +0200
  [PATCH 09/86] perf trace beauty: Allow accessing syscall args values in a syscall arg formatter Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-19 16:10 +0200
  [PATCH 08/86] perf trace beauty: Mask ignored fcntl 'arg' parameter Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-19 16:10 +0200
  [PATCH 07/86] perf trace: Only build tools/perf/trace/beauty/ when building 'perf trace' Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-19 16:10 +0200
  [PATCH 06/86] perf trace beauty: Export the strarrays scnprintf method Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-07-19 16:10 +0200

csiph-web