aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-trace.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2013-09-02 12:46:44 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2013-09-02 13:58:19 -0400
commitf9da0b0c74af25a68b9ac43a2c81f2eea970de5a (patch)
tree1857cf63c6886c1c87c3e747e3e7cd0c829fb16d /tools/perf/builtin-trace.c
parent6e7eeb51106d2e9ef7975214747e76d23c5d01af (diff)
perf trace: Add beautifier for futex 'operation' parm
That uses the arg mask mechanism just introduced to suppress ignored arguments according to the futex operation. Based on an initial patch from David Ahern that showed the need for some way to allow args to tell how many further args should be shown. Initial-patch-by: David Ahern <dsahern@gmail.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/n/tip-0k30it46r4hv5eanefbdmj5t@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/builtin-trace.c')
-rw-r--r--tools/perf/builtin-trace.c47
1 files changed, 46 insertions, 1 deletions
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index c29692ab1891..1a6cb7436952 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -14,6 +14,7 @@
14#include <libaudit.h> 14#include <libaudit.h>
15#include <stdlib.h> 15#include <stdlib.h>
16#include <sys/mman.h> 16#include <sys/mman.h>
17#include <linux/futex.h>
17 18
18static size_t syscall_arg__scnprintf_hex(char *bf, size_t size, 19static size_t syscall_arg__scnprintf_hex(char *bf, size_t size,
19 unsigned long arg, u8 *arg_mask __maybe_unused) 20 unsigned long arg, u8 *arg_mask __maybe_unused)
@@ -137,6 +138,49 @@ static size_t syscall_arg__scnprintf_madvise_behavior(char *bf, size_t size,
137 138
138#define SCA_MADV_BHV syscall_arg__scnprintf_madvise_behavior 139#define SCA_MADV_BHV syscall_arg__scnprintf_madvise_behavior
139 140
141static size_t syscall_arg__scnprintf_futex_op(char *bf, size_t size, unsigned long arg, u8 *arg_mask)
142{
143 enum syscall_futex_args {
144 SCF_UADDR = (1 << 0),
145 SCF_OP = (1 << 1),
146 SCF_VAL = (1 << 2),
147 SCF_TIMEOUT = (1 << 3),
148 SCF_UADDR2 = (1 << 4),
149 SCF_VAL3 = (1 << 5),
150 };
151 int op = arg;
152 int cmd = op & FUTEX_CMD_MASK;
153 size_t printed = 0;
154
155 switch (cmd) {
156#define P_FUTEX_OP(n) case FUTEX_##n: printed = scnprintf(bf, size, #n);
157 P_FUTEX_OP(WAIT); *arg_mask |= SCF_VAL3|SCF_UADDR2; break;
158 P_FUTEX_OP(WAKE); *arg_mask |= SCF_VAL3|SCF_UADDR2|SCF_TIMEOUT; break;
159 P_FUTEX_OP(FD); *arg_mask |= SCF_VAL3|SCF_UADDR2|SCF_TIMEOUT; break;
160 P_FUTEX_OP(REQUEUE); *arg_mask |= SCF_VAL3|SCF_TIMEOUT; break;
161 P_FUTEX_OP(CMP_REQUEUE); *arg_mask |= SCF_TIMEOUT; break;
162 P_FUTEX_OP(CMP_REQUEUE_PI); *arg_mask |= SCF_TIMEOUT; break;
163 P_FUTEX_OP(WAKE_OP); break;
164 P_FUTEX_OP(LOCK_PI); *arg_mask |= SCF_VAL3|SCF_UADDR2|SCF_TIMEOUT; break;
165 P_FUTEX_OP(UNLOCK_PI); *arg_mask |= SCF_VAL3|SCF_UADDR2|SCF_TIMEOUT; break;
166 P_FUTEX_OP(TRYLOCK_PI); *arg_mask |= SCF_VAL3|SCF_UADDR2; break;
167 P_FUTEX_OP(WAIT_BITSET); *arg_mask |= SCF_UADDR2; break;
168 P_FUTEX_OP(WAKE_BITSET); *arg_mask |= SCF_UADDR2; break;
169 P_FUTEX_OP(WAIT_REQUEUE_PI); break;
170 default: printed = scnprintf(bf, size, "%#x", cmd); break;
171 }
172
173 if (op & FUTEX_PRIVATE_FLAG)
174 printed += scnprintf(bf + printed, size - printed, "|PRIV");
175
176 if (op & FUTEX_CLOCK_REALTIME)
177 printed += scnprintf(bf + printed, size - printed, "|CLKRT");
178
179 return printed;
180}
181
182#define SCA_FUTEX_OP syscall_arg__scnprintf_futex_op
183
140static struct syscall_fmt { 184static struct syscall_fmt {
141 const char *name; 185 const char *name;
142 const char *alias; 186 const char *alias;
@@ -153,7 +197,8 @@ static struct syscall_fmt {
153 { .name = "connect", .errmsg = true, }, 197 { .name = "connect", .errmsg = true, },
154 { .name = "fstat", .errmsg = true, .alias = "newfstat", }, 198 { .name = "fstat", .errmsg = true, .alias = "newfstat", },
155 { .name = "fstatat", .errmsg = true, .alias = "newfstatat", }, 199 { .name = "fstatat", .errmsg = true, .alias = "newfstatat", },
156 { .name = "futex", .errmsg = true, }, 200 { .name = "futex", .errmsg = true,
201 .arg_scnprintf = { [1] = SCA_FUTEX_OP, /* op */ }, },
157 { .name = "ioctl", .errmsg = true, 202 { .name = "ioctl", .errmsg = true,
158 .arg_scnprintf = { [2] = SCA_HEX, /* arg */ }, }, 203 .arg_scnprintf = { [2] = SCA_HEX, /* arg */ }, },
159 { .name = "lstat", .errmsg = true, .alias = "newlstat", }, 204 { .name = "lstat", .errmsg = true, .alias = "newlstat", },