aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2015-06-11 21:47:54 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-06-11 21:47:54 -0400
commita1c2552dba788c2c5e71c5bf5bcf3971caf3dfa1 (patch)
tree30b2b46d6f6c25f1859ab4eb02031d9f59d9c8a6 /tools/perf
parent6ba29c2fa5adcc33b201faec99057b6a72bd5029 (diff)
trace: Beautify perf_event_open syscall
Syswide tracing and then running 'stat' and 'trace': $ perf trace -e perf_event_open 1034.649 (0.019 ms): perf/6133 perf_event_open(attr_uptr: 0x36f0360, pid: 16134, cpu: -1, group_fd: -1, flags: FD_CLOEXEC) = -1 EINVAL Invalid argument 1034.670 (0.008 ms): perf/6133 perf_event_open(attr_uptr: 0x36f0360, pid: 16134, cpu: -1, group_fd: -1) = -1 EINVAL Invalid argument 1034.681 (0.007 ms): perf/6133 perf_event_open(attr_uptr: 0x36f0360, pid: 16134, cpu: -1, group_fd: -1) = -1 EINVAL Invalid argument 1034.692 (0.007 ms): perf/6133 perf_event_open(attr_uptr: 0x36f0360, pid: 16134, cpu: -1, group_fd: -1) = -1 EINVAL Invalid argument 9986.983 (0.014 ms): trace/6139 perf_event_open(attr_uptr: 0x7ffd9c629320, pid: -1, group_fd: -1, flags: FD_CLOEXEC) = 3 9987.026 (0.016 ms): trace/6139 perf_event_open(attr_uptr: 0x37c7e70, pid: -1, group_fd: -1, flags: FD_CLOEXEC) = 3 9987.041 (0.008 ms): trace/6139 perf_event_open(attr_uptr: 0x37c7e70, pid: -1, group_fd: -1, flags: FD_CLOEXEC) = 3 9987.489 (0.092 ms): trace/6139 perf_event_open(attr_uptr: 0x3795ee0, pid: 16140, group_fd: -1, flags: FD_CLOEXEC) = 3 9987.536 (0.044 ms): trace/6139 perf_event_open(attr_uptr: 0x3795ee0, pid: 16140, cpu: 1, group_fd: -1, flags: FD_CLOEXEC) = 4 9987.580 (0.041 ms): trace/6139 perf_event_open(attr_uptr: 0x3795ee0, pid: 16140, cpu: 2, group_fd: -1, flags: FD_CLOEXEC) = 5 9987.620 (0.037 ms): trace/6139 perf_event_open(attr_uptr: 0x3795ee0, pid: 16140, cpu: 3, group_fd: -1, flags: FD_CLOEXEC) = 7 9987.659 (0.035 ms): trace/6139 perf_event_open(attr_uptr: 0x37975d0, pid: 16140, group_fd: -1, flags: FD_CLOEXEC) = 8 9987.692 (0.031 ms): trace/6139 perf_event_open(attr_uptr: 0x37975d0, pid: 16140, cpu: 1, group_fd: -1, flags: FD_CLOEXEC) = 9 9987.727 (0.032 ms): trace/6139 perf_event_open(attr_uptr: 0x37975d0, pid: 16140, cpu: 2, group_fd: -1, flags: FD_CLOEXEC) = 10 9987.761 (0.031 ms): trace/6139 perf_event_open(attr_uptr: 0x37975d0, pid: 16140, cpu: 3, group_fd: -1, flags: FD_CLOEXEC) = 11 Need to intercept perf_copy_attr() with a kprobe or with eBPF... Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Borislav Petkov <bp@suse.de> Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Namhyung Kim <namhyung@kernel.org> Link: http://lkml.kernel.org/n/tip-njb105hab2i3t5dexym9lskl@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/builtin-trace.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index a05490d06374..4bf805b2fbf6 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -68,6 +68,23 @@
68# define MSG_CMSG_CLOEXEC 0x40000000 68# define MSG_CMSG_CLOEXEC 0x40000000
69#endif 69#endif
70 70
71#ifndef PERF_FLAG_FD_NO_GROUP
72# define PERF_FLAG_FD_NO_GROUP (1UL << 0)
73#endif
74
75#ifndef PERF_FLAG_FD_OUTPUT
76# define PERF_FLAG_FD_OUTPUT (1UL << 1)
77#endif
78
79#ifndef PERF_FLAG_PID_CGROUP
80# define PERF_FLAG_PID_CGROUP (1UL << 2) /* pid=cgroup id, per-cpu mode only */
81#endif
82
83#ifndef PERF_FLAG_FD_CLOEXEC
84# define PERF_FLAG_FD_CLOEXEC (1UL << 3) /* O_CLOEXEC */
85#endif
86
87
71struct tp_field { 88struct tp_field {
72 int offset; 89 int offset;
73 union { 90 union {
@@ -358,6 +375,14 @@ static size_t syscall_arg__scnprintf_hex(char *bf, size_t size,
358 375
359#define SCA_HEX syscall_arg__scnprintf_hex 376#define SCA_HEX syscall_arg__scnprintf_hex
360 377
378static size_t syscall_arg__scnprintf_int(char *bf, size_t size,
379 struct syscall_arg *arg)
380{
381 return scnprintf(bf, size, "%d", arg->val);
382}
383
384#define SCA_INT syscall_arg__scnprintf_int
385
361static size_t syscall_arg__scnprintf_mmap_prot(char *bf, size_t size, 386static size_t syscall_arg__scnprintf_mmap_prot(char *bf, size_t size,
362 struct syscall_arg *arg) 387 struct syscall_arg *arg)
363{ 388{
@@ -810,6 +835,34 @@ static size_t syscall_arg__scnprintf_open_flags(char *bf, size_t size,
810 835
811#define SCA_OPEN_FLAGS syscall_arg__scnprintf_open_flags 836#define SCA_OPEN_FLAGS syscall_arg__scnprintf_open_flags
812 837
838static size_t syscall_arg__scnprintf_perf_flags(char *bf, size_t size,
839 struct syscall_arg *arg)
840{
841 int printed = 0, flags = arg->val;
842
843 if (flags == 0)
844 return 0;
845
846#define P_FLAG(n) \
847 if (flags & PERF_FLAG_##n) { \
848 printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #n); \
849 flags &= ~PERF_FLAG_##n; \
850 }
851
852 P_FLAG(FD_NO_GROUP);
853 P_FLAG(FD_OUTPUT);
854 P_FLAG(PID_CGROUP);
855 P_FLAG(FD_CLOEXEC);
856#undef P_FLAG
857
858 if (flags)
859 printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", flags);
860
861 return printed;
862}
863
864#define SCA_PERF_FLAGS syscall_arg__scnprintf_perf_flags
865
813static size_t syscall_arg__scnprintf_eventfd_flags(char *bf, size_t size, 866static size_t syscall_arg__scnprintf_eventfd_flags(char *bf, size_t size,
814 struct syscall_arg *arg) 867 struct syscall_arg *arg)
815{ 868{
@@ -1077,6 +1130,11 @@ static struct syscall_fmt {
1077 { .name = "openat", .errmsg = true, 1130 { .name = "openat", .errmsg = true,
1078 .arg_scnprintf = { [0] = SCA_FDAT, /* dfd */ 1131 .arg_scnprintf = { [0] = SCA_FDAT, /* dfd */
1079 [2] = SCA_OPEN_FLAGS, /* flags */ }, }, 1132 [2] = SCA_OPEN_FLAGS, /* flags */ }, },
1133 { .name = "perf_event_open", .errmsg = true,
1134 .arg_scnprintf = { [1] = SCA_INT, /* pid */
1135 [2] = SCA_INT, /* cpu */
1136 [3] = SCA_FD, /* group_fd */
1137 [4] = SCA_PERF_FLAGS, /* flags */ }, },
1080 { .name = "pipe2", .errmsg = true, 1138 { .name = "pipe2", .errmsg = true,
1081 .arg_scnprintf = { [1] = SCA_PIPE_FLAGS, /* flags */ }, }, 1139 .arg_scnprintf = { [1] = SCA_PIPE_FLAGS, /* flags */ }, },
1082 { .name = "poll", .errmsg = true, .timeout = true, }, 1140 { .name = "poll", .errmsg = true, .timeout = true, },