diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2013-09-02 15:22:31 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2013-09-02 15:22:31 -0400 |
commit | be65a89a0b558cb5b6863be71861f29b36feb88e (patch) | |
tree | e440f1e136f2b0692964dc98613d104c2daa2206 /tools | |
parent | 579e7865b2d431bb7d380a1b4ea0aa8eb8a10fd4 (diff) |
perf trace: Add beautifier for open's flags arg
Suppressing the mode when O_CREAT not present, needs improvements on the
arg masking mechanism to be reused in openat, open_by_handle_at,
mq_open:
[root@zoo ~]# perf trace -a -e open | grep -v 'flags: RDONLY' | head -5
147.541 ( 0.028 ms): 1188 open(filename: 0x33c17782fb, flags: CLOEXEC ) = 23
229.898 ( 0.020 ms): 2071 open(filename: 0x3d93c80, flags: NOATIME ) = -1 EPERM Operation not permitted
[root@zoo ~]# perf trace -a -e open | grep CREAT
1406.697 ( 0.024 ms): 616 open(filename: 0x7fffc3a0f910, flags: CREAT|TRUNC|WRONLY, mode: 438 ) = -1 ENOENT No such file or directory
2032.770 ( 0.804 ms): 4354 open(filename: 0x7f33ac814368, flags: CREAT|EXCL|RDWR, mode: 384 ) = 115
^C[root@zoo ~]#
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-c7vm6klaf995qw1vqdih5t7q@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/builtin-trace.c | 59 |
1 files changed, 58 insertions, 1 deletions
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 02aaea6273ff..5b6b2871d85f 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c | |||
@@ -206,6 +206,62 @@ static size_t syscall_arg__scnprintf_futex_op(char *bf, size_t size, unsigned lo | |||
206 | 206 | ||
207 | #define SCA_FUTEX_OP syscall_arg__scnprintf_futex_op | 207 | #define SCA_FUTEX_OP syscall_arg__scnprintf_futex_op |
208 | 208 | ||
209 | static size_t syscall_arg__scnprintf_open_flags(char *bf, size_t size, | ||
210 | unsigned long arg, u8 *arg_mask) | ||
211 | { | ||
212 | int printed = 0, flags = arg; | ||
213 | |||
214 | if (!(flags & O_CREAT)) | ||
215 | *arg_mask |= 1 << 2; /* Mask the mode parm */ | ||
216 | |||
217 | if (flags == 0) | ||
218 | return scnprintf(bf, size, "RDONLY"); | ||
219 | #define P_FLAG(n) \ | ||
220 | if (flags & O_##n) { \ | ||
221 | printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #n); \ | ||
222 | flags &= ~O_##n; \ | ||
223 | } | ||
224 | |||
225 | P_FLAG(APPEND); | ||
226 | P_FLAG(ASYNC); | ||
227 | P_FLAG(CLOEXEC); | ||
228 | P_FLAG(CREAT); | ||
229 | P_FLAG(DIRECT); | ||
230 | P_FLAG(DIRECTORY); | ||
231 | P_FLAG(EXCL); | ||
232 | P_FLAG(LARGEFILE); | ||
233 | P_FLAG(NOATIME); | ||
234 | P_FLAG(NOCTTY); | ||
235 | #ifdef O_NONBLOCK | ||
236 | P_FLAG(NONBLOCK); | ||
237 | #elif O_NDELAY | ||
238 | P_FLAG(NDELAY); | ||
239 | #endif | ||
240 | #ifdef O_PATH | ||
241 | P_FLAG(PATH); | ||
242 | #endif | ||
243 | P_FLAG(RDWR); | ||
244 | #ifdef O_DSYNC | ||
245 | if ((flags & O_SYNC) == O_SYNC) | ||
246 | printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", "SYNC"); | ||
247 | else { | ||
248 | P_FLAG(DSYNC); | ||
249 | } | ||
250 | #else | ||
251 | P_FLAG(SYNC); | ||
252 | #endif | ||
253 | P_FLAG(TRUNC); | ||
254 | P_FLAG(WRONLY); | ||
255 | #undef P_FLAG | ||
256 | |||
257 | if (flags) | ||
258 | printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", flags); | ||
259 | |||
260 | return printed; | ||
261 | } | ||
262 | |||
263 | #define SCA_OPEN_FLAGS syscall_arg__scnprintf_open_flags | ||
264 | |||
209 | static struct syscall_fmt { | 265 | static struct syscall_fmt { |
210 | const char *name; | 266 | const char *name; |
211 | const char *alias; | 267 | const char *alias; |
@@ -244,7 +300,8 @@ static struct syscall_fmt { | |||
244 | [4] = SCA_HEX, /* new_addr */ }, }, | 300 | [4] = SCA_HEX, /* new_addr */ }, }, |
245 | { .name = "munmap", .errmsg = true, | 301 | { .name = "munmap", .errmsg = true, |
246 | .arg_scnprintf = { [0] = SCA_HEX, /* addr */ }, }, | 302 | .arg_scnprintf = { [0] = SCA_HEX, /* addr */ }, }, |
247 | { .name = "open", .errmsg = true, }, | 303 | { .name = "open", .errmsg = true, |
304 | .arg_scnprintf = { [1] = SCA_OPEN_FLAGS, /* flags */ }, }, | ||
248 | { .name = "poll", .errmsg = true, .timeout = true, }, | 305 | { .name = "poll", .errmsg = true, .timeout = true, }, |
249 | { .name = "ppoll", .errmsg = true, .timeout = true, }, | 306 | { .name = "ppoll", .errmsg = true, .timeout = true, }, |
250 | { .name = "pread", .errmsg = true, .alias = "pread64", }, | 307 | { .name = "pread", .errmsg = true, .alias = "pread64", }, |