From ec6dd85f6e39bf516f4420d62270380b96bbee57 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Mon, 31 Jul 2017 17:34:47 -0300 Subject: perf trace beautify ioctl: Beautify vhost virtio ioctl's 'cmd' arg Also trying a new approach, using a copy of uapi/linux/vhost.h we auto generate the string tables, then include it in the ioctl cmd beautifier. This way either the KVM developers will add the new commands to the tools/ copy, like is happening with other areas of tools/include/ (bpf.h comes to mind), or we'll be notified when building perf that our copy drifted. E.g., doing syswide tracing grepping for the newly beautified VHOST ioctls: # perf trace -e ioctl 2>&1 | grep VHOST 3873.064 ( 0.099 ms): qemu-system-x8/21238 ioctl(fd: 27, cmd: VHOST_NET_SET_BACKEND, arg: 0x7fff053dffe0) = 0 3873.168 ( 0.019 ms): qemu-system-x8/21238 ioctl(fd: 27, cmd: VHOST_NET_SET_BACKEND, arg: 0x7fff053dffe0) = 0 3873.226 ( 0.006 ms): qemu-system-x8/21238 ioctl(fd: 27, cmd: VHOST_GET_VRING_BASE, arg: 0x7fff053dff60) = 0 3873.244 ( 0.002 ms): qemu-system-x8/21238 ioctl(fd: 27, cmd: VHOST_GET_VRING_BASE, arg: 0x7fff053dff60) = 0 3873.817 ( 0.014 ms): qemu-system-x8/21238 ioctl(fd: 27, cmd: VHOST_SET_VRING_CALL, arg: 0x7fff053dff20) = 0 3873.838 ( 0.004 ms): qemu-system-x8/21238 ioctl(fd: 27, cmd: VHOST_SET_VRING_CALL, arg: 0x7fff053dff20) = 0 4701.372 ( 0.006 ms): qemu-system-x8/21238 ioctl(fd: 27, cmd: VHOST_SET_VRING_CALL, arg: 0x7fff053dfe20) = 0 4701.417 ( 0.007 ms): qemu-system-x8/21238 ioctl(fd: 27, cmd: VHOST_SET_VRING_CALL, arg: 0x7fff053dfe20) = 0 4701.563 ( 0.004 ms): qemu-system-x8/21238 ioctl(fd: 27, cmd: VHOST_SET_FEATURES, arg: 0x7fff053dfe88) = 0 4701.571 ( 0.028 ms): qemu-system-x8/21238 ioctl(fd: 27, cmd: VHOST_SET_MEM_TABLE, arg: 0x563c7c906870) = 0 4701.604 ( 0.003 ms): qemu-system-x8/21238 ioctl(fd: 27, cmd: VHOST_SET_VRING_NUM, arg: 0x7fff053dff00) = 0 4701.609 ( 0.002 ms): qemu-system-x8/21238 ioctl(fd: 27, cmd: VHOST_SET_VRING_BASE, arg: 0x7fff053dff00) = 0 4701.615 ( 0.002 ms): qemu-system-x8/21238 ioctl(fd: 27, cmd: VHOST_SET_VRING_ADDR, arg: 0x7fff053dfe70) = 0 4701.619 ( 0.008 ms): qemu-system-x8/21238 ioctl(fd: 27, cmd: VHOST_SET_VRING_KICK, arg: 0x7fff053dfef0) = 0 4701.634 ( 0.004 ms): qemu-system-x8/21238 ioctl(fd: 27, cmd: VHOST_SET_VRING_NUM, arg: 0x7fff053dff00) = 0 4701.640 ( 0.002 ms): qemu-system-x8/21238 ioctl(fd: 27, cmd: VHOST_SET_VRING_BASE, arg: 0x7fff053dff00) = 0 4701.644 ( 0.002 ms): qemu-system-x8/21238 ioctl(fd: 27, cmd: VHOST_SET_VRING_ADDR, arg: 0x7fff053dfe70) = 0 4701.648 ( 0.009 ms): qemu-system-x8/21238 ioctl(fd: 27, cmd: VHOST_SET_VRING_KICK, arg: 0x7fff053dfef0) = 0 4701.665 ( 0.005 ms): qemu-system-x8/21238 ioctl(fd: 27, cmd: VHOST_NET_SET_BACKEND, arg: 0x7fff053dff80) = 0 4701.672 ( 0.004 ms): qemu-system-x8/21238 ioctl(fd: 27, cmd: VHOST_NET_SET_BACKEND, arg: 0x7fff053dff80) = 0 ^C '-e ioctl' uses tracepoint filters, in time this will be replaces by eBPF filters hooked at the syscall tracepoints and that "grep VHOST" will also be done with eBPF, right at the kernel, to reduce overhead. Cc: Adrian Hunter Cc: David Ahern Cc: Jason Wang Cc: Jiri Olsa Cc: "Michael S. Tsirkin" Cc: Namhyung Kim Cc: Paolo Bonzini Cc: Radim Krčmář Cc: Wang Nan Link: http://lkml.kernel.org/n/tip-2gthnhpliunvakywjterrzz3@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/trace/beauty/vhost_virtio_ioctl.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100755 tools/perf/trace/beauty/vhost_virtio_ioctl.sh (limited to 'tools/perf/trace/beauty/vhost_virtio_ioctl.sh') diff --git a/tools/perf/trace/beauty/vhost_virtio_ioctl.sh b/tools/perf/trace/beauty/vhost_virtio_ioctl.sh new file mode 100755 index 000000000000..76f1de697787 --- /dev/null +++ b/tools/perf/trace/beauty/vhost_virtio_ioctl.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +vhost_virtio_header_dir=$1 + +printf "static const char *vhost_virtio_ioctl_cmds[] = {\n" +regex='^#[[:space:]]*define[[:space:]]+VHOST_(\w+)[[:space:]]+_IOW?\([[:space:]]*VHOST_VIRTIO[[:space:]]*,[[:space:]]*(0x[[:xdigit:]]+).*' +egrep $regex ${vhost_virtio_header_dir}/vhost.h | \ + sed -r "s/$regex/\2 \1/g" | \ + sort | xargs printf "\t[%s] = \"%s\",\n" +printf "};\n" + +printf "static const char *vhost_virtio_ioctl_read_cmds[] = {\n" +regex='^#[[:space:]]*define[[:space:]]+VHOST_(\w+)[[:space:]]+_IOW?R\([[:space:]]*VHOST_VIRTIO[[:space:]]*,[[:space:]]*(0x[[:xdigit:]]+).*' +egrep $regex ${vhost_virtio_header_dir}/vhost.h | \ + sed -r "s/$regex/\2 \1/g" | \ + sort | xargs printf "\t[%s] = \"%s\",\n" +printf "};\n" -- cgit v1.2.3-55-g7522