[tip:perf/core] perf trace beauty ioctl: Pass _IOC_DIR to the per _IOC_TYPE scnprintf

2017-08-10 Thread tip-bot for Arnaldo Carvalho de Melo
Commit-ID:  8ff69577075e0321ef25d3afcb293db39a31342a
Gitweb: http://git.kernel.org/tip/8ff69577075e0321ef25d3afcb293db39a31342a
Author: Arnaldo Carvalho de Melo 
AuthorDate: Tue, 1 Aug 2017 11:46:36 -0300
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Tue, 1 Aug 2017 13:04:52 -0300

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 
Cc: David Ahern 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Paolo Bonzini 
Cc: Radim Krčmář 
Cc: Wang Nan 
Link: http://lkml.kernel.org/n/tip-rq6q717ql7j2z7kuccafg...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/trace/beauty/ioctl.c | 24 
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/tools/perf/trace/beauty/ioctl.c b/tools/perf/trace/beauty/ioctl.c
index 89fa4eb..8633d96 100644
--- a/tools/perf/trace/beauty/ioctl.c
+++ b/tools/perf/trace/beauty/ioctl.c
@@ -19,7 +19,7 @@
  */
 #include 
 
-static size_t ioctl__scnprintf_tty_cmd(int nr, char *bf, size_t size)
+static size_t ioctl__scnprintf_tty_cmd(int nr, int dir, char *bf, size_t size)
 {
static const char *ioctl_tty_cmd[] = {
"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)
if (nr < strarray__ioctl_tty_cmd.nr_entries && 
strarray__ioctl_tty_cmd.entries[nr] != NULL)
return scnprintf(bf, size, "%s", 
strarray__ioctl_tty_cmd.entries[nr]);
 
-   return scnprintf(bf, size, "(%#x, %#x)", 'T', nr);
+   return scnprintf(bf, size, "(%#x, %#x, %#x)", 'T', nr, dir);
 }
 
-static size_t ioctl__scnprintf_drm_cmd(int nr, char *bf, size_t size)
+static size_t ioctl__scnprintf_drm_cmd(int nr, int dir, char *bf, size_t size)
 {
 #include "trace/beauty/generated/ioctl/drm_ioctl_array.c"
static DEFINE_STRARRAY(drm_ioctl_cmds);
@@ -52,10 +52,10 @@ static size_t ioctl__scnprintf_drm_cmd(int nr, char *bf, 
size_t size)
if (nr < strarray__drm_ioctl_cmds.nr_entries && 
strarray__drm_ioctl_cmds.entries[nr] != NULL)
return scnprintf(bf, size, "DRM_%s", 
strarray__drm_ioctl_cmds.entries[nr]);
 
-   return scnprintf(bf, size, "(%#x, %#x)", 'd', nr);
+   return scnprintf(bf, size, "(%#x, %#x, %#x)", 'd', nr, dir);
 }
 
-static size_t ioctl__scnprintf_sndrv_pcm_cmd(int nr, char *bf, size_t size)
+static size_t ioctl__scnprintf_sndrv_pcm_cmd(int nr, int dir, char *bf, size_t 
size)
 {
 #include "trace/beauty/generated/ioctl/sndrv_pcm_ioctl_array.c"
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)
if (nr < strarray__sndrv_pcm_ioctl_cmds.nr_entries && 
strarray__sndrv_pcm_ioctl_cmds.entries[nr] != NULL)
return scnprintf(bf, size, "SNDRV_PCM_%s", 
strarray__sndrv_pcm_ioctl_cmds.entries[nr]);
 
-   return scnprintf(bf, size, "(%#x, %#x)", 'A', nr);
+   return scnprintf(bf, size, "(%#x, %#x, %#x)", 'A', nr, dir);
 }
 
-static size_t ioctl__scnprintf_sndrv_ctl_cmd(int nr, char *bf, size_t size)
+static size_t ioctl__scnprintf_sndrv_ctl_cmd(int nr, int dir, char *bf, size_t 
size)
 {
 #include "trace/beauty/generated/ioctl/sndrv_ctl_ioctl_array.c"
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)
if (nr < strarray__sndrv_ctl_ioctl_cmds.nr_entries && 
strarray__sndrv_ctl_ioctl_cmds.entries[nr] != NULL)
return scnprintf(bf, size, "SNDRV_CTL_%s", 
strarray__sndrv_ctl_ioctl_cmds.entries[nr]);
 
-   return scnprintf(bf, size, "(%#x, %#x)", 'U', nr);
+   

[tip:perf/core] perf trace beauty ioctl: Pass _IOC_DIR to the per _IOC_TYPE scnprintf

2017-08-10 Thread tip-bot for Arnaldo Carvalho de Melo
Commit-ID:  8ff69577075e0321ef25d3afcb293db39a31342a
Gitweb: http://git.kernel.org/tip/8ff69577075e0321ef25d3afcb293db39a31342a
Author: Arnaldo Carvalho de Melo 
AuthorDate: Tue, 1 Aug 2017 11:46:36 -0300
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Tue, 1 Aug 2017 13:04:52 -0300

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 
Cc: David Ahern 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Paolo Bonzini 
Cc: Radim Krčmář 
Cc: Wang Nan 
Link: http://lkml.kernel.org/n/tip-rq6q717ql7j2z7kuccafg...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/trace/beauty/ioctl.c | 24 
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/tools/perf/trace/beauty/ioctl.c b/tools/perf/trace/beauty/ioctl.c
index 89fa4eb..8633d96 100644
--- a/tools/perf/trace/beauty/ioctl.c
+++ b/tools/perf/trace/beauty/ioctl.c
@@ -19,7 +19,7 @@
  */
 #include 
 
-static size_t ioctl__scnprintf_tty_cmd(int nr, char *bf, size_t size)
+static size_t ioctl__scnprintf_tty_cmd(int nr, int dir, char *bf, size_t size)
 {
static const char *ioctl_tty_cmd[] = {
"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)
if (nr < strarray__ioctl_tty_cmd.nr_entries && 
strarray__ioctl_tty_cmd.entries[nr] != NULL)
return scnprintf(bf, size, "%s", 
strarray__ioctl_tty_cmd.entries[nr]);
 
-   return scnprintf(bf, size, "(%#x, %#x)", 'T', nr);
+   return scnprintf(bf, size, "(%#x, %#x, %#x)", 'T', nr, dir);
 }
 
-static size_t ioctl__scnprintf_drm_cmd(int nr, char *bf, size_t size)
+static size_t ioctl__scnprintf_drm_cmd(int nr, int dir, char *bf, size_t size)
 {
 #include "trace/beauty/generated/ioctl/drm_ioctl_array.c"
static DEFINE_STRARRAY(drm_ioctl_cmds);
@@ -52,10 +52,10 @@ static size_t ioctl__scnprintf_drm_cmd(int nr, char *bf, 
size_t size)
if (nr < strarray__drm_ioctl_cmds.nr_entries && 
strarray__drm_ioctl_cmds.entries[nr] != NULL)
return scnprintf(bf, size, "DRM_%s", 
strarray__drm_ioctl_cmds.entries[nr]);
 
-   return scnprintf(bf, size, "(%#x, %#x)", 'd', nr);
+   return scnprintf(bf, size, "(%#x, %#x, %#x)", 'd', nr, dir);
 }
 
-static size_t ioctl__scnprintf_sndrv_pcm_cmd(int nr, char *bf, size_t size)
+static size_t ioctl__scnprintf_sndrv_pcm_cmd(int nr, int dir, char *bf, size_t 
size)
 {
 #include "trace/beauty/generated/ioctl/sndrv_pcm_ioctl_array.c"
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)
if (nr < strarray__sndrv_pcm_ioctl_cmds.nr_entries && 
strarray__sndrv_pcm_ioctl_cmds.entries[nr] != NULL)
return scnprintf(bf, size, "SNDRV_PCM_%s", 
strarray__sndrv_pcm_ioctl_cmds.entries[nr]);
 
-   return scnprintf(bf, size, "(%#x, %#x)", 'A', nr);
+   return scnprintf(bf, size, "(%#x, %#x, %#x)", 'A', nr, dir);
 }
 
-static size_t ioctl__scnprintf_sndrv_ctl_cmd(int nr, char *bf, size_t size)
+static size_t ioctl__scnprintf_sndrv_ctl_cmd(int nr, int dir, char *bf, size_t 
size)
 {
 #include "trace/beauty/generated/ioctl/sndrv_ctl_ioctl_array.c"
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)
if (nr < strarray__sndrv_ctl_ioctl_cmds.nr_entries && 
strarray__sndrv_ctl_ioctl_cmds.entries[nr] != NULL)
return scnprintf(bf, size, "SNDRV_CTL_%s", 
strarray__sndrv_ctl_ioctl_cmds.entries[nr]);
 
-   return scnprintf(bf, size, "(%#x, %#x)", 'U', nr);
+   return scnprintf(bf, size, "(%#x, %#x, %#x)", 'U', nr, dir);
 }
 
-static size_t ioctl__scnprintf_kvm_cmd(int nr, char *bf, size_t size)
+static size_t ioctl__scnprintf_kvm_cmd(int nr, int dir, char