aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2017-08-01 10:46:36 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2017-08-01 12:04:52 -0400
commit8ff69577075e0321ef25d3afcb293db39a31342a (patch)
tree2f481595b6b6731d2682cbdcbb88671fd05f3580
parent45717b7fb7e59285927170cf7fff233e0bbeeaca (diff)
perf trace beauty ioctl: Pass _IOC_DIR to the per _IOC_TYPE scnprintf
Not all subsystems use the fact that we may have the same _IOC_NR for different _IOC_DIR, as in the end it'll result in a different ioctl number. So, for instance, vhost virtio has: #define VHOST_GET_FEATURES _IOR(VHOST_VIRTIO, 0x00, __u64) #define VHOST_SET_FEATURES _IOW(VHOST_VIRTIO, 0x00, __u64) So same _IOC_NR (0x00) but different _IOC_DIR (R versus W), but it also have: #define VHOST_SET_VRING_ENDIAN _IOW(VHOST_VIRTIO, 0x13, struct vhost_vring_state) #define VHOST_GET_VRING_ENDIAN _IOW(VHOST_VIRTIO, 0x14, struct vhost_vring_state) A "get" operation that uses a "W" _IOC_DIR, and its implementation, uses copy_to_user, it should've probably been _IOR(). Then: /* Base value where queue looks for available descriptors */ #define VHOST_SET_VRING_BASE _IOW(VHOST_VIRTIO, 0x12, struct vhost_vring_state) /* Get accessor: reads index, writes value in num */ #define VHOST_GET_VRING_BASE _IOWR(VHOST_VIRTIO, 0x12, struct vhost_vring_state) So we'll need to use _IOC_DIR() to disambiguate the VHOST_VIRTIO ioctl bautifier. 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: Paolo Bonzini <pbonzini@redhat.com> Cc: Radim Krčmář <rkrcmar@redhat.com> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/n/tip-rq6q717ql7j2z7kuccafgq84@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/trace/beauty/ioctl.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/tools/perf/trace/beauty/ioctl.c b/tools/perf/trace/beauty/ioctl.c
index 89fa4eb68247..8633d96ed131 100644
--- a/tools/perf/trace/beauty/ioctl.c
+++ b/tools/perf/trace/beauty/ioctl.c
@@ -19,7 +19,7 @@
19 */ 19 */
20#include <uapi/asm-generic/ioctls.h> 20#include <uapi/asm-generic/ioctls.h>
21 21
22static size_t ioctl__scnprintf_tty_cmd(int nr, char *bf, size_t size) 22static size_t ioctl__scnprintf_tty_cmd(int nr, int dir, char *bf, size_t size)
23{ 23{
24 static const char *ioctl_tty_cmd[] = { 24 static const char *ioctl_tty_cmd[] = {
25 "TCGETS", "TCSETS", "TCSETSW", "TCSETSF", "TCGETA", "TCSETA", "TCSETAW", 25 "TCGETS", "TCSETS", "TCSETSW", "TCSETSF", "TCGETA", "TCSETA", "TCSETAW",
@@ -41,10 +41,10 @@ static size_t ioctl__scnprintf_tty_cmd(int nr, char *bf, size_t size)
41 if (nr < strarray__ioctl_tty_cmd.nr_entries && strarray__ioctl_tty_cmd.entries[nr] != NULL) 41 if (nr < strarray__ioctl_tty_cmd.nr_entries && strarray__ioctl_tty_cmd.entries[nr] != NULL)
42 return scnprintf(bf, size, "%s", strarray__ioctl_tty_cmd.entries[nr]); 42 return scnprintf(bf, size, "%s", strarray__ioctl_tty_cmd.entries[nr]);
43 43
44 return scnprintf(bf, size, "(%#x, %#x)", 'T', nr); 44 return scnprintf(bf, size, "(%#x, %#x, %#x)", 'T', nr, dir);
45} 45}
46 46
47static size_t ioctl__scnprintf_drm_cmd(int nr, char *bf, size_t size) 47static size_t ioctl__scnprintf_drm_cmd(int nr, int dir, char *bf, size_t size)
48{ 48{
49#include "trace/beauty/generated/ioctl/drm_ioctl_array.c" 49#include "trace/beauty/generated/ioctl/drm_ioctl_array.c"
50 static DEFINE_STRARRAY(drm_ioctl_cmds); 50 static DEFINE_STRARRAY(drm_ioctl_cmds);
@@ -52,10 +52,10 @@ static size_t ioctl__scnprintf_drm_cmd(int nr, char *bf, size_t size)
52 if (nr < strarray__drm_ioctl_cmds.nr_entries && strarray__drm_ioctl_cmds.entries[nr] != NULL) 52 if (nr < strarray__drm_ioctl_cmds.nr_entries && strarray__drm_ioctl_cmds.entries[nr] != NULL)
53 return scnprintf(bf, size, "DRM_%s", strarray__drm_ioctl_cmds.entries[nr]); 53 return scnprintf(bf, size, "DRM_%s", strarray__drm_ioctl_cmds.entries[nr]);
54 54
55 return scnprintf(bf, size, "(%#x, %#x)", 'd', nr); 55 return scnprintf(bf, size, "(%#x, %#x, %#x)", 'd', nr, dir);
56} 56}
57 57
58static size_t ioctl__scnprintf_sndrv_pcm_cmd(int nr, char *bf, size_t size) 58static size_t ioctl__scnprintf_sndrv_pcm_cmd(int nr, int dir, char *bf, size_t size)
59{ 59{
60#include "trace/beauty/generated/ioctl/sndrv_pcm_ioctl_array.c" 60#include "trace/beauty/generated/ioctl/sndrv_pcm_ioctl_array.c"
61 static DEFINE_STRARRAY(sndrv_pcm_ioctl_cmds); 61 static DEFINE_STRARRAY(sndrv_pcm_ioctl_cmds);
@@ -63,10 +63,10 @@ static size_t ioctl__scnprintf_sndrv_pcm_cmd(int nr, char *bf, size_t size)
63 if (nr < strarray__sndrv_pcm_ioctl_cmds.nr_entries && strarray__sndrv_pcm_ioctl_cmds.entries[nr] != NULL) 63 if (nr < strarray__sndrv_pcm_ioctl_cmds.nr_entries && strarray__sndrv_pcm_ioctl_cmds.entries[nr] != NULL)
64 return scnprintf(bf, size, "SNDRV_PCM_%s", strarray__sndrv_pcm_ioctl_cmds.entries[nr]); 64 return scnprintf(bf, size, "SNDRV_PCM_%s", strarray__sndrv_pcm_ioctl_cmds.entries[nr]);
65 65
66 return scnprintf(bf, size, "(%#x, %#x)", 'A', nr); 66 return scnprintf(bf, size, "(%#x, %#x, %#x)", 'A', nr, dir);
67} 67}
68 68
69static size_t ioctl__scnprintf_sndrv_ctl_cmd(int nr, char *bf, size_t size) 69static size_t ioctl__scnprintf_sndrv_ctl_cmd(int nr, int dir, char *bf, size_t size)
70{ 70{
71#include "trace/beauty/generated/ioctl/sndrv_ctl_ioctl_array.c" 71#include "trace/beauty/generated/ioctl/sndrv_ctl_ioctl_array.c"
72 static DEFINE_STRARRAY(sndrv_ctl_ioctl_cmds); 72 static DEFINE_STRARRAY(sndrv_ctl_ioctl_cmds);
@@ -74,10 +74,10 @@ static size_t ioctl__scnprintf_sndrv_ctl_cmd(int nr, char *bf, size_t size)
74 if (nr < strarray__sndrv_ctl_ioctl_cmds.nr_entries && strarray__sndrv_ctl_ioctl_cmds.entries[nr] != NULL) 74 if (nr < strarray__sndrv_ctl_ioctl_cmds.nr_entries && strarray__sndrv_ctl_ioctl_cmds.entries[nr] != NULL)
75 return scnprintf(bf, size, "SNDRV_CTL_%s", strarray__sndrv_ctl_ioctl_cmds.entries[nr]); 75 return scnprintf(bf, size, "SNDRV_CTL_%s", strarray__sndrv_ctl_ioctl_cmds.entries[nr]);
76 76
77 return scnprintf(bf, size, "(%#x, %#x)", 'U', nr); 77 return scnprintf(bf, size, "(%#x, %#x, %#x)", 'U', nr, dir);
78} 78}
79 79
80static size_t ioctl__scnprintf_kvm_cmd(int nr, char *bf, size_t size) 80static size_t ioctl__scnprintf_kvm_cmd(int nr, int dir, char *bf, size_t size)
81{ 81{
82#include "trace/beauty/generated/ioctl/kvm_ioctl_array.c" 82#include "trace/beauty/generated/ioctl/kvm_ioctl_array.c"
83 static DEFINE_STRARRAY(kvm_ioctl_cmds); 83 static DEFINE_STRARRAY(kvm_ioctl_cmds);
@@ -85,7 +85,7 @@ static size_t ioctl__scnprintf_kvm_cmd(int nr, char *bf, size_t size)
85 if (nr < strarray__kvm_ioctl_cmds.nr_entries && strarray__kvm_ioctl_cmds.entries[nr] != NULL) 85 if (nr < strarray__kvm_ioctl_cmds.nr_entries && strarray__kvm_ioctl_cmds.entries[nr] != NULL)
86 return scnprintf(bf, size, "KVM_%s", strarray__kvm_ioctl_cmds.entries[nr]); 86 return scnprintf(bf, size, "KVM_%s", strarray__kvm_ioctl_cmds.entries[nr]);
87 87
88 return scnprintf(bf, size, "(%#x, %#x)", 0xAE, nr); 88 return scnprintf(bf, size, "(%#x, %#x, %#x)", 0xAE, nr, dir);
89} 89}
90 90
91static size_t ioctl__scnprintf_cmd(unsigned long cmd, char *bf, size_t size) 91static size_t ioctl__scnprintf_cmd(unsigned long cmd, char *bf, size_t size)
@@ -97,7 +97,7 @@ static size_t ioctl__scnprintf_cmd(unsigned long cmd, char *bf, size_t size)
97 int printed = 0; 97 int printed = 0;
98 static const struct ioctl_type { 98 static const struct ioctl_type {
99 int type; 99 int type;
100 size_t (*scnprintf)(int nr, char *bf, size_t size); 100 size_t (*scnprintf)(int nr, int dir, char *bf, size_t size);
101 } ioctl_types[] = { /* Must be ordered by type */ 101 } ioctl_types[] = { /* Must be ordered by type */
102 { .type = 'A', .scnprintf = ioctl__scnprintf_sndrv_pcm_cmd, }, 102 { .type = 'A', .scnprintf = ioctl__scnprintf_sndrv_pcm_cmd, },
103 ['T' - 'A']= { .type = 'T', .scnprintf = ioctl__scnprintf_tty_cmd, }, 103 ['T' - 'A']= { .type = 'T', .scnprintf = ioctl__scnprintf_tty_cmd, },
@@ -111,7 +111,7 @@ static size_t ioctl__scnprintf_cmd(unsigned long cmd, char *bf, size_t size)
111 const int index = type - ioctl_types[0].type; 111 const int index = type - ioctl_types[0].type;
112 112
113 if (ioctl_types[index].scnprintf != NULL) 113 if (ioctl_types[index].scnprintf != NULL)
114 return ioctl_types[index].scnprintf(nr, bf, size); 114 return ioctl_types[index].scnprintf(nr, dir, bf, size);
115 } 115 }
116 116
117 printed += scnprintf(bf + printed, size - printed, "%c", '('); 117 printed += scnprintf(bf + printed, size - printed, "%c", '(');