1. 01 Aug, 2017 11 commits
    • Arnaldo Carvalho de Melo's avatar
      perf trace beauty ioctl: Pass _IOC_DIR to the per _IOC_TYPE scnprintf · 8ff69577
      Arnaldo Carvalho de Melo authored
      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.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      8ff69577
    • Arnaldo Carvalho de Melo's avatar
      perf trace beautify ioctl: Beautify KVM ioctl's 'cmd' arg · 45717b7f
      Arnaldo Carvalho de Melo authored
      Also trying a new approach, using a copy of uapi/linux/kvm.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., a tracing a process and its threads, but would work for system wide as
      well, just drop that '-p 21238', to see ioctls for DRM, tty, sound, etc:
      
        # perf trace -e ioctl -p 21238 2>&1 | grep -v KVM_RUN
          7801.536 ( 0.003 ms): CPU 0/KVM/21276 ioctl(fd: 13<anon_inode:kvm-vm>, cmd: KVM_IRQ_LINE_STATUS, arg: 0x7f484c6c73c0) = 0
        <SNIP lots of the last one>
          7801.715 ( 0.001 ms): CPU 0/KVM/21276 ioctl(fd: 13<anon_inode:kvm-vm>, cmd: KVM_IRQ_LINE_STATUS, arg: 0x7f484c6c73e0) = 0
         11001.051 ( 0.008 ms): qemu-system-x8/21238 ioctl(fd: 13<anon_inode:kvm-vm>, cmd: KVM_SIGNAL_MSI, arg: 0x563c83379d70) = 1
         11001.225 ( 0.005 ms): qemu-system-x8/21238 ioctl(fd: 13<anon_inode:kvm-vm>, cmd: KVM_SIGNAL_MSI, arg: 0x563c83379d70) = 1
         10750.377 (249.963 ms): CPU 0/KVM/21276  ... [continued]: ioctl()) = 0
         11011.780 ( 0.015 ms): qemu-system-x8/21238 ioctl(fd: 13<anon_inode:kvm-vm>, cmd: KVM_SIGNAL_MSI, arg: 0x563c83379d90) = 1
         11011.929 ( 0.005 ms): qemu-system-x8/21238 ioctl(fd: 13<anon_inode:kvm-vm>, cmd: KVM_SIGNAL_MSI, arg: 0x7fff053e1000) = 1
         11012.090 ( 0.004 ms): qemu-system-x8/21238 ioctl(fd: 13<anon_inode:kvm-vm>, cmd: KVM_SIGNAL_MSI, arg: 0x563c83379d70) = 1
         11023.127 ( 0.020 ms): qemu-system-x8/21238 ioctl(fd: 13<anon_inode:kvm-vm>, cmd: KVM_SIGNAL_MSI, arg: 0x563c83379d90) = 1
         11000.483 (249.807 ms): CPU 0/KVM/21276  ... [continued]: ioctl()) = 0
         25620.877 ( 0.042 ms): qemu-system-x8/21238 ioctl(fd: 13<anon_inode:kvm-vm>, cmd: KVM_IRQ_LINE_STATUS, arg: 0x7fff053e1080) = 0
        <SNIP several of the last one>
         25621.025 ( 0.002 ms): qemu-system-x8/21238 ioctl(fd: 13<anon_inode:kvm-vm>, cmd: KVM_IRQ_LINE_STATUS, arg: 0x7fff053e10a0) = 0
         25500.803 (120.186 ms): CPU 0/KVM/21276  ... [continued]: ioctl()) = 0
         25621.078 ( 0.005 ms): CPU 0/KVM/21276 ioctl(fd: 13<anon_inode:kvm-vm>, cmd: KVM_IRQ_LINE_STATUS, arg: 0x7f484c6c73c0) = 0
        <SNIP lots of the last one>
         25621.346 ( 0.001 ms): CPU 0/KVM/21276 ioctl(fd: 13<anon_inode:kvm-vm>, cmd: KVM_IRQ_LINE_STATUS, arg: 0x7f484c6c73e0) = 0
         40456.997 ( 0.100 ms): qemu-system-x8/21238 ioctl(fd: 27</dev/vhost-net>, cmd: (WRITE, 0xaf, 0x30, 0x8), arg: 0x7fff053dffe0) = 0
         40457.100 ( 0.019 ms): qemu-system-x8/21238 ioctl(fd: 27</dev/vhost-net>, cmd: (WRITE, 0xaf, 0x30, 0x8), arg: 0x7fff053dffe0) = 0
         40457.133 ( 0.002 ms): qemu-system-x8/21238 ioctl(fd: 27</dev/vhost-net>, cmd: (READ|WRITE, 0xaf, 0x12, 0x8), arg: 0x7fff053dff60) = 0
         40457.139 ( 0.001 ms): qemu-system-x8/21238 ioctl(fd: 27</dev/vhost-net>, cmd: (READ|WRITE, 0xaf, 0x12, 0x8), arg: 0x7fff053dff60) = 0
         40458.503 ( 0.027 ms): qemu-system-x8/21238 ioctl(fd: 13<anon_inode:kvm-vm>, cmd: KVM_IOEVENTFD, arg: 0x7fff053dfc80) = 0
         40458.601 ( 0.030 ms): qemu-system-x8/21238 ioctl(fd: 13<anon_inode:kvm-vm>, cmd: KVM_IOEVENTFD, arg: 0x7fff053dfc80) = 0
         40458.649 ( 0.003 ms): qemu-system-x8/21238 ioctl(fd: 27</dev/vhost-net>, cmd: (WRITE, 0xaf, 0x21, 0x8), arg: 0x7fff053dff20) = 0
         40458.654 ( 0.002 ms): qemu-system-x8/21238 ioctl(fd: 27</dev/vhost-net>, cmd: (WRITE, 0xaf, 0x21, 0x8), arg: 0x7fff053dff20) = 0
         40458.657 ( 0.018 ms): qemu-system-x8/21238 ioctl(fd: 13<anon_inode:kvm-vm>, cmd: KVM_IRQFD, arg: 0x7fff053dff00  ) = 0
         40459.077 ( 0.017 ms): qemu-system-x8/21238 ioctl(fd: 13<anon_inode:kvm-vm>, cmd: KVM_IRQFD, arg: 0x7fff053dff00  ) = 0
         40459.123 ( 0.017 ms): qemu-system-x8/21238 ioctl(fd: 13<anon_inode:kvm-vm>, cmd: KVM_IOEVENTFD, arg: 0x7fff053dfd20) = 0
        <SNIP lots of the last one>
         40463.477 ( 0.013 ms): qemu-system-x8/21238 ioctl(fd: 13<anon_inode:kvm-vm>, cmd: KVM_IOEVENTFD, arg: 0x7fff053dfd20) = 0
         40464.874 ( 0.010 ms): qemu-system-x8/21238 ioctl(fd: 13<anon_inode:kvm-vm>, cmd: KVM_GET_VCPU_EVENTS, arg: 0x7fff053e0000) = 0
         40464.892 ( 0.048 ms): qemu-system-x8/21238 ioctl(fd: 12</dev/kvm>, cmd: KVM_CHECK_EXTENSION, arg: 0x4c           ) = 1
         40464.991 ( 0.002 ms): qemu-system-x8/21238 ioctl(fd: 13<anon_inode:kvm-vm>, cmd: KVM_GET_CLOCK, arg: 0x7fff053e0040) = 0
         40464.962 ( 0.013 ms): CPU 0/KVM/21276 ioctl(fd: 20<anon_inode:kvm-vcpu>, cmd: KVM_GET_MSRS, arg: 0x7f484c6c7670) = 1
         44540.437 ( 0.103 ms): qemu-system-x8/21238 ioctl(fd: 13<anon_inode:kvm-vm>, cmd: KVM_SET_GSI_ROUTING, arg: 0x563c7c93c000) = 0
         44540.544 ( 0.008 ms): qemu-system-x8/21238 ioctl(fd: 13<anon_inode:kvm-vm>, cmd: KVM_IRQFD, arg: 0x7fff053dfea0  ) = 0
         44540.555 ( 0.029 ms): qemu-system-x8/21238 ioctl(fd: 13<anon_inode:kvm-vm>, cmd: KVM_SET_GSI_ROUTING, arg: 0x563c7c93c000) = 0
         44540.586 ( 0.003 ms): qemu-system-x8/21238 ioctl(fd: 13<anon_inode:kvm-vm>, cmd: KVM_IRQFD, arg: 0x7fff053dfea0  ) = 0
         44540.592 ( 0.027 ms): qemu-system-x8/21238 ioctl(fd: 13<anon_inode:kvm-vm>, cmd: KVM_SET_GSI_ROUTING, arg: 0x563c7c93c000) = 0
         44540.625 ( 0.005 ms): qemu-system-x8/21238 ioctl(fd: 27</dev/vhost-net>, cmd: (WRITE, 0xaf, 0x21, 0x8), arg: 0x7fff053dfe20) = 0
         44540.639 ( 0.018 ms): qemu-system-x8/21238 ioctl(fd: 13<anon_inode:kvm-vm>, cmd: KVM_SET_GSI_ROUTING, arg: 0x563c7c93c000) = 0
         44540.658 ( 0.003 ms): qemu-system-x8/21238 ioctl(fd: 27</dev/vhost-net>, cmd: (WRITE, 0xaf, 0x21, 0x8), arg: 0x7fff053dfe20) = 0
         44540.686 ( 0.015 ms): qemu-system-x8/21238 ioctl(fd: 13<anon_inode:kvm-vm>, cmd: KVM_IOEVENTFD, arg: 0x7fff053dfbe0) = 0
         44540.727 ( 0.014 ms): qemu-system-x8/21238 ioctl(fd: 13<anon_inode:kvm-vm>, cmd: KVM_IOEVENTFD, arg: 0x7fff053dfbe0) = 0
         44540.748 ( 0.005 ms): qemu-system-x8/21238 ioctl(fd: 27</dev/vhost-net>, cmd: (WRITE, 0xaf, 0, 0x8), arg: 0x7fff053dfe88) = 0
         44540.754 ( 0.026 ms): qemu-system-x8/21238 ioctl(fd: 27</dev/vhost-net>, cmd: (WRITE, 0xaf, 0x3, 0x8), arg: 0x563c7c906870) = 0
         44540.783 ( 0.002 ms): qemu-system-x8/21238 ioctl(fd: 27</dev/vhost-net>, cmd: (WRITE, 0xaf, 0x10, 0x8), arg: 0x7fff053dff00) = 0
         44540.787 ( 0.002 ms): qemu-system-x8/21238 ioctl(fd: 27</dev/vhost-net>, cmd: (WRITE, 0xaf, 0x12, 0x8), arg: 0x7fff053dff00) = 0
         44540.793 ( 0.002 ms): qemu-system-x8/21238 ioctl(fd: 27</dev/vhost-net>, cmd: (WRITE, 0xaf, 0x11, 0x28), arg: 0x7fff053dfe70) = 0
         44540.796 ( 0.010 ms): qemu-system-x8/21238 ioctl(fd: 27</dev/vhost-net>, cmd: (WRITE, 0xaf, 0x20, 0x8), arg: 0x7fff053dfef0) = 0
         44540.811 ( 0.002 ms): qemu-system-x8/21238 ioctl(fd: 27</dev/vhost-net>, cmd: (WRITE, 0xaf, 0x10, 0x8), arg: 0x7fff053dff00) = 0
         44540.814 ( 0.002 ms): qemu-system-x8/21238 ioctl(fd: 27</dev/vhost-net>, cmd: (WRITE, 0xaf, 0x12, 0x8), arg: 0x7fff053dff00) = 0
         44540.819 ( 0.002 ms): qemu-system-x8/21238 ioctl(fd: 27</dev/vhost-net>, cmd: (WRITE, 0xaf, 0x11, 0x28), arg: 0x7fff053dfe70) = 0
         44540.822 ( 0.005 ms): qemu-system-x8/21238 ioctl(fd: 27</dev/vhost-net>, cmd: (WRITE, 0xaf, 0x20, 0x8), arg: 0x7fff053dfef0) = 0
         44540.837 ( 0.006 ms): qemu-system-x8/21238 ioctl(fd: 27</dev/vhost-net>, cmd: (WRITE, 0xaf, 0x30, 0x8), arg: 0x7fff053dff80) = 0
         44540.862 ( 0.004 ms): qemu-system-x8/21238 ioctl(fd: 27</dev/vhost-net>, cmd: (WRITE, 0xaf, 0x30, 0x8), arg: 0x7fff053dff80) = 0
         44540.887 ( 0.014 ms): qemu-system-x8/21238 ioctl(fd: 13<anon_inode:kvm-vm>, cmd: KVM_IOEVENTFD, arg: 0x7fff053dfd00) = 0
        <SNIP lots of the last one>
         44542.756 ( 0.020 ms): qemu-system-x8/21238 ioctl(fd: 13<anon_inode:kvm-vm>, cmd: KVM_IOEVENTFD, arg: 0x7fff053dfd00) = 0
         44542.809 ( 0.007 ms): qemu-system-x8/21238 ioctl(fd: 13<anon_inode:kvm-vm>, cmd: KVM_SET_VCPU_EVENTS, arg: 0x7fff053dffb0) = 0
         44542.819 ( 0.003 ms): qemu-system-x8/21238 ioctl(fd: 12</dev/kvm>, cmd: KVM_CHECK_EXTENSION, arg: 0x4c           ) = 1
         44543.016 ( 0.004 ms): qemu-system-x8/21238 ioctl(fd: 13<anon_inode:kvm-vm>, cmd: KVM_SET_CLOCK, arg: 0x7fff053dfff0) = 0
         44543.022 ( 0.008 ms): qemu-system-x8/21238 ioctl(fd: 20<anon_inode:kvm-vcpu>, cmd: KVM_KVMCLOCK_CTRL             ) = 0
         46952.502 ( 0.010 ms): qemu-system-x8/21238 ioctl(fd: 13<anon_inode:kvm-vm>, cmd: KVM_SIGNAL_MSI, arg: 0x563c83379d70) = 1
         46829.292 (249.860 ms): CPU 0/KVM/21276  ... [continued]: ioctl()) = 0
        ^C
      [root@jouet linux]#
      
      Since there are clashes in _IOC_NR() for some cases, notably ioctls with
      PPC_ and ARM_ in its name and some that depend on some internal state to
      be valid, but use the same number as others, those were removed in the
      shell script that builds the table, tools/perf/trace/beauty/kvm_ioctl.sh.
      
      Since so far we're supporting only x86 in the 'cmd' ioctl arg beautifier
      in perf trace, we can leave fully supporting these ioctls for later.
      
      There are some more to handle here, notably the one for /dev/vhost-net, will
      come later.
      
      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-zxhebe579n338d7qrnjoctes@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      45717b7f
    • Arnaldo Carvalho de Melo's avatar
      tools include uapi: Grab a copy of linux/kvm.h · 3ce97513
      Arnaldo Carvalho de Melo authored
      We will use it to generate tables for beautifying ioctl's 'cmd' arg.
      
      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: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-nxwpq34hu6te1m2ra5m7o8n9@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      3ce97513
    • Arnaldo Carvalho de Melo's avatar
      perf trace beautify ioctl: Beautify sound ioctl's 'cmd' arg · 2c3e9629
      Arnaldo Carvalho de Melo authored
      This time we try a new approach, using a copy of uapi/sound/asound.h we
      auto generate the string tables, then include it in the ioctl cmd
      beautifier.
      
      This way either the sound 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.:
      
        # perf trace -p 22084 -e ioctl 2>&1 | head -5
           0.000 ( 0.068 ms): alsa-sink-ALC3/22084 ioctl(fd: 49</dev/snd/pcmC1D0p>, cmd: SNDRV_PCM_HWSYNC, arg: 0x557f8d7fa0f0) = 0
           0.344 ( 0.041 ms): alsa-sink-ALC3/22084 ioctl(fd: 46</dev/snd/controlC1>, cmd: SNDRV_CTL_ELEM_READ, arg: 0x7fe764018ee0) = 0
           0.403 ( 0.011 ms): alsa-sink-ALC3/22084 ioctl(fd: 49</dev/snd/pcmC1D0p>, cmd: SNDRV_PCM_HWSYNC, arg: 0x557f8d7fa0f0) = 0
           0.427 ( 0.009 ms): alsa-sink-ALC3/22084 ioctl(fd: 49</dev/snd/pcmC1D0p>, cmd: SNDRV_PCM_STATUS_EXT, arg: 0x7fe76c2e0b30) = 0
           2.461 ( 0.042 ms): alsa-sink-ALC3/22084 ioctl(fd: 49</dev/snd/pcmC1D0p>, cmd: SNDRV_PCM_HWSYNC, arg: 0x557f8d7fa0f0) = 0
        #
      
      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: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-8zuyf3e3u6jjcb2xzerw0kdi@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      2c3e9629
    • Arnaldo Carvalho de Melo's avatar
      tools include uapi: Grab a copy of sound/asound.h · a215684e
      Arnaldo Carvalho de Melo authored
      We will use it to generate tables for beautifying ioctl's 'cmd' arg.
      
      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: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-wit4wwmrh9d37dtgtk0glbbj@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      a215684e
    • Arnaldo Carvalho de Melo's avatar
      perf trace beauty ioctl: Beautify DRM ioctl cmds · ef9811f0
      Arnaldo Carvalho de Melo authored
      This time we try a new approach, using uapi/drm/ copies of drm.h and
      i915_drm.h we auto generate the string tables, then include it in the
      ioctl cmd beautifier.
      
      This way either the DRM 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.
      
      Either way the time from a new command being added to when 'perf trace'
      gets to know it is greatly shortened, for instance:
      
        # strace -p 22401 -e ioctl
        ioctl(8, DRM_IOCTL_I915_GEM_BUSY, 0x7ffc934f7600) = 0
        ioctl(8, DRM_IOCTL_I915_GEM_SET_DOMAIN, 0x7ffc934f7550) = 0
        ioctl(8, DRM_IOCTL_I915_GEM_SW_FINISH, 0x7ffc934f76e0) = 0
        ioctl(8, DRM_IOCTL_I915_GEM_SW_FINISH, 0x7ffc934f7780) = 0
        ioctl(8, _IOC(_IOC_READ|_IOC_WRITE, 0x64, 0x69, 0x40), 0x7ffc934f7700) = 0
        ioctl(8, DRM_IOCTL_I915_GEM_SET_DOMAIN, 0x7ffc934f7780) = 0
        ioctl(8, DRM_IOCTL_I915_GEM_MADVISE, 0x7ffc934f76f0) = 0
        ioctl(8, DRM_IOCTL_I915_GEM_BUSY, 0x7ffc934f76c0) = 0
        ioctl(8, DRM_IOCTL_I915_GEM_MADVISE, 0x7ffc934f76b0) = 0
        ioctl(8, DRM_IOCTL_I915_GEM_SET_DOMAIN, 0x7ffc934f76d0) = 0
        ioctl(8, DRM_IOCTL_MODE_ADDFB, 0x7ffc934f7880) = 0
        ioctl(8, DRM_IOCTL_MODE_PAGE_FLIP, 0x7ffc934f77d0) = 0
        ^Cstrace: Process 22401 detached
      
      versus:
      
        # perf trace -p 22401 -e ioctl
        1010.856 (0.006 ms): gnome-shell/22401 ioctl(fd: 8</dev/dri/card0>, cmd: DRM_I915_GEM_BUSY, arg: 0x7ffc934f7600) = 0
        1010.865 (0.003 ms): gnome-shell/22401 ioctl(fd: 8</dev/dri/card0>, cmd: DRM_I915_GEM_SET_DOMAIN, arg: 0x7ffc934f7550) = 0
        1010.872 (0.002 ms): gnome-shell/22401 ioctl(fd: 8</dev/dri/card0>, cmd: DRM_I915_GEM_SW_FINISH, arg: 0x7ffc934f76e0) = 0
        1010.939 (0.015 ms): gnome-shell/22401 ioctl(fd: 8</dev/dri/card0>, cmd: DRM_I915_GEM_SW_FINISH, arg: 0x7ffc934f7780) = 0
        1010.959 (0.085 ms): gnome-shell/22401 ioctl(fd: 8</dev/dri/card0>, cmd: DRM_I915_GEM_EXECBUFFER2, arg: 0x7ffc934f7700) = 0
        1011.048 (0.003 ms): gnome-shell/22401 ioctl(fd: 8</dev/dri/card0>, cmd: DRM_I915_GEM_SET_DOMAIN, arg: 0x7ffc934f7780) = 0
        1011.056 (0.002 ms): gnome-shell/22401 ioctl(fd: 8</dev/dri/card0>, cmd: DRM_I915_GEM_MADVISE, arg: 0x7ffc934f76f0) = 0
        1011.060 (0.002 ms): gnome-shell/22401 ioctl(fd: 8</dev/dri/card0>, cmd: DRM_I915_GEM_BUSY, arg: 0x7ffc934f76c0) = 0
        1011.064 (0.003 ms): gnome-shell/22401 ioctl(fd: 8</dev/dri/card0>, cmd: DRM_I915_GEM_MADVISE, arg: 0x7ffc934f76b0) = 0
        1011.068 (0.002 ms): gnome-shell/22401 ioctl(fd: 8</dev/dri/card0>, cmd: DRM_I915_GEM_SET_DOMAIN, arg: 0x7ffc934f76d0) = 0
        1011.074 (0.009 ms): gnome-shell/22401 ioctl(fd: 8</dev/dri/card0>, cmd: DRM_MODE_ADDFB, arg: 0x7ffc934f7880 ) = 0
        1011.096 (0.072 ms): gnome-shell/22401 ioctl(fd: 8</dev/dri/card0>, cmd: DRM_MODE_PAGE_FLIP, arg: 0x7ffc934f77d0) = 0
      ^C[root@jouet linux]#
      
      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: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-mly2d7v9kf28rso81dijbixq@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      ef9811f0
    • Arnaldo Carvalho de Melo's avatar
      tools include uapi: Grab copies of drm/{drm,i915_drm}.h · c1737f2b
      Arnaldo Carvalho de Melo authored
      We will use it to generate tables for beautifying ioctl's 'cmd' arg.
      
      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: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-bqoq114h917u6ggazn8m1w0t@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      c1737f2b
    • Arnaldo Carvalho de Melo's avatar
      perf trace beauty ioctl: Improve 'cmd' beautifier · 1cc47f2d
      Arnaldo Carvalho de Melo authored
      By using the _IOC_(DIR,NR,TYPE,SIZE) macros to lookup a 'type' keyed
      table that then gets indexed by 'nr', falling back to a notation similar
      to the one used by 'strace', only more compact, i.e.:
      
         474.356 ( 0.007 ms): gnome-shell/22401 ioctl(fd: 8</dev/dri/card0>, cmd: (READ|WRITE, 0x64, 0xae, 0x1c), arg: 0x7ffc934f7880) = 0
         474.369 ( 0.053 ms): gnome-shell/22401 ioctl(fd: 8</dev/dri/card0>, cmd: (READ|WRITE, 0x64, 0xb0, 0x18), arg: 0x7ffc934f77d0) = 0
         505.055 ( 0.014 ms): gnome-shell/22401 ioctl(fd: 8</dev/dri/card0>, cmd: (READ|WRITE, 0x64, 0xaf, 0x4), arg: 0x7ffc934f741c) = 0
      
      This also moves it out of builtin-trace.c and into trace/beauty/ioctl.c
      to better compartimentalize all these formatters.
      
      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: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-s3enursdxsvnhdomh6qlte4g@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      1cc47f2d
    • Arnaldo Carvalho de Melo's avatar
      tools headers: Fixup tools/include/uapi/linux/bpf.h copy of kernel ABI header · f1d6cb2d
      Arnaldo Carvalho de Melo authored
      In 04df41e3 ("bpf: update tools/include/uapi/linux/bpf.h") the files
      added in 40304b2a ("bpf: BPF support for sock_ops") were added to
      tools/include, but not in a verbatim way, missing the comments, which
      ends up triggering this warning when build tools/perf/:
      
        make: Entering directory '/home/acme/git/linux/tools/perf'
          BUILD:   Doing 'make -j4' parallel build
        Warning: Kernel ABI header at 'tools/include/uapi/linux/bpf.h' differs from latest version at 'include/uapi/linux/bpf.h'
      
      Make sure the the lines are equal, to fix the simple header copy
      drift detector in tools/perf/.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: David S. Miller <davem@davemloft.net>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Lawrence Brakmo <brakmo@fb.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Fixes: 04df41e3 ("bpf: update tools/include/uapi/linux/bpf.h")
      Link: http://lkml.kernel.org/n/tip-z9qyyqht9qq3yyxu76sfy0dh@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      f1d6cb2d
    • Arnaldo Carvalho de Melo's avatar
      tools perf: Do not check spaces/blank lines when checking header file copy drift · 470de0f3
      Arnaldo Carvalho de Melo authored
      We copy headers from include/, arch/ to allow tools/ use defines,
      structs from newer kernels and still be able to build on older systems.
      
      We then, as part of a build, check if those copies got out of sync, when
      we emit a warning, so that we can check if something needs to be
      reflected on the tools, e.g. a 'perf trace' syscall argument beautifier
      needs tweaking.
      
      But we don't have to be super strict with that, for instance, extra
      spaces, tabs or blank lines aren't problematic, so change
      check-headers.sh to have "--ignore-blank-lines --ignore-space-change" as
      default "diff" arguments.
      
      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: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-d8emqpdc3m2qtzt1ei8ra2tf@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      470de0f3
    • Arnaldo Carvalho de Melo's avatar
      tools include uapi: Grab a copy of asm-generic/ioctls.h · 6375f0ab
      Arnaldo Carvalho de Melo authored
      So that we can build on older systems where otherwise we would end up
      with:
      
          CC       /tmp/build/perf/trace/beauty/ioctl.o
        trace/beauty/ioctl.c: In function 'ioctl__scnprintf_tty_cmd':
        trace/beauty/ioctl.c:25:17: error: 'TIOCGEXCL' undeclared (first use in this function)
        trace/beauty/ioctl.c:25:17: note: each undeclared identifier is reported only once for each function it appears in
        trace/beauty/ioctl.c:25:2: error: array index in initializer not of integer type
        trace/beauty/ioctl.c:25:2: error: (near initialization for 'ioctl_tty_cmd')
      
      This way we can build a tool on an older system and it will still be
      capable of processing perf.data files generated on newer systems.
      
      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: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-8qvkv6txwuzua6d0yvt65wl3@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      6375f0ab
  2. 31 Jul, 2017 4 commits
    • Arnaldo Carvalho de Melo's avatar
      tools headers: Fixup tools/include/uapi/linux/bpf.h copy of kernel ABI header · d62c1d72
      Arnaldo Carvalho de Melo authored
      In 2be7e212 ("bpf: add bpf_skb_adjust_room helper") BPF_ADJ_ROOM_NET was
      added to include/uapi/linux/bpf.h but BPF_ADJ_ROOM_NET_OPS was added to
      tools/include/uapi/linux/bpf.h, making these files differ, fix it by using the
      same name in both, BPF_ADJ_ROOM_NET, the one in the kernel headers copy.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: David S. Miller <davem@davemloft.net>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Fixes: 2be7e212 ("bpf: add bpf_skb_adjust_room helper")
      Link: http://lkml.kernel.org/n/tip-2bmwovi9lymplyz6wsszppyf@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      d62c1d72
    • Ingo Molnar's avatar
      tools headers: Sync kernel ABI headers with tooling headers · a40f6177
      Ingo Molnar authored
      Sync up (copy) the following v4.13 kernel headers to the tooling headers:
      
        arch/arm/include/uapi/asm/kvm.h:
        arch/arm64/include/uapi/asm/kvm.h:
        arch/powerpc/include/uapi/asm/kvm.h:
        arch/s390/include/uapi/asm/kvm.h:
      
         - KVM ABI extensions, which do not affect perf tooling
      
        arch/x86/include/asm/cpufeatures.h:
        arch/x86/include/asm/disabled-features.h:
      
         - New PCID CPU feature on Intel CPUs - does not affect tooling.
      
      I.e. no real changes were needed to resolve the build warnings, just a plain copy
      of the latest kernel header version.
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: David Carrillo-Cisneros <davidcc@google.com>
      Cc: Francis Deslauriers <francis.deslauriers@efficios.com>
      Cc: Geneviève Bastien <gbastien@versatic.net>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Julien Desfossez <jdesfossez@efficios.com>
      Cc: Martin Liška <mliska@suse.cz>
      Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
      Cc: Milian Wolff <milian.wolff@kdab.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Turner <pjt@google.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Simon Que <sque@chromium.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Taeung Song <treeze.taeung@gmail.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/20170730095232.4j4xigsoqwufl5hu@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      a40f6177
    • Ingo Molnar's avatar
      perf build: Clarify open-coded header version warning message · 8255e1ef
      Ingo Molnar authored
      In this patch we changed the header checks:
      
        perf build: Clarify header version warning message
      
      Unfortunately the header checks were copied to various places and thus the message got
      out of sync. Fix some of them here.
      
      Note that there's still old, misleading messages remaining in:
      
        tools/objtool/Makefile: || echo "warning: objtool: x86 instruction decoder differs from kernel" >&2 )) || true
        tools/objtool/Makefile: || echo "warning: objtool: orc_types.h differs from kernel" >&2 )) || true
      
      here objtool copied the perf message, plus:
      
       tools/perf/util/intel-pt-decoder/Build: || echo "Warning: Intel PT: x86 instruction decoder differs from kernel" >&2 )) || true
      
      here the PT code regressed over the original message and only emits a vague warning
      instead of specific file names...
      
      All of this should be consolidated into tools/Build/ and used in a consistent
      manner.
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: David Carrillo-Cisneros <davidcc@google.com>
      Cc: Francis Deslauriers <francis.deslauriers@efficios.com>
      Cc: Geneviève Bastien <gbastien@versatic.net>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Julien Desfossez <jdesfossez@efficios.com>
      Cc: Martin Liška <mliska@suse.cz>
      Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
      Cc: Milian Wolff <milian.wolff@kdab.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Turner <pjt@google.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Simon Que <sque@chromium.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Taeung Song <treeze.taeung@gmail.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/20170730095130.bblldwxjz5hamybb@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      8255e1ef
    • Ingo Molnar's avatar
      perf build: Clarify header version warning message · c59796d5
      Ingo Molnar authored
      Change this:
      
        Warning: arch/x86/include/asm/disabled-features.h differs from kernel
        Warning: arch/x86/include/asm/cpufeatures.h differs from kernel
        Warning: arch/powerpc/include/uapi/asm/kvm.h differs from kernel
        Warning: arch/s390/include/uapi/asm/kvm.h differs from kernel
      
        Warning: Kernel ABI header at 'tools/arch/x86/include/asm/disabled-features.h' differs from latest version at 'arch/x86/include/asm/disabled-features.h'
        Warning: Kernel ABI header at 'tools/arch/x86/include/asm/cpufeatures.h' differs from latest version at 'arch/x86/include/asm/cpufeatures.h'
        Warning: Kernel ABI header at 'tools/arch/powerpc/include/uapi/asm/kvm.h' differs from latest version at 'arch/powerpc/include/uapi/asm/kvm.h'
        Warning: Kernel ABI header at 'tools/arch/s390/include/uapi/asm/kvm.h' differs from latest version at 'arch/s390/include/uapi/asm/kvm.h'
      
      ... to make it clearer what the warning is about, and to make it easier
      to diff the two versions when syncing up the files.
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: David Carrillo-Cisneros <davidcc@google.com>
      Cc: Francis Deslauriers <francis.deslauriers@efficios.com>
      Cc: Geneviève Bastien <gbastien@versatic.net>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Julien Desfossez <jdesfossez@efficios.com>
      Cc: Martin Liška <mliska@suse.cz>
      Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
      Cc: Milian Wolff <milian.wolff@kdab.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Turner <pjt@google.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Simon Que <sque@chromium.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Taeung Song <treeze.taeung@gmail.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/20170730093747.qogjn3lp7ntwcgwg@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      c59796d5
  3. 30 Jul, 2017 2 commits
    • Ingo Molnar's avatar
      Merge tag 'perf-core-for-mingo-4.14-20170728' of... · c3a3800f
      Ingo Molnar authored
      Merge tag 'perf-core-for-mingo-4.14-20170728' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core
      
      Pull perf/core improvements and fixes for 4.14 from Arnaldo Carvalho de Melo:
      
      New features:
      
       - Add PERF_SAMPLE_CALLCHAIN and PERF_RECORD_MMAP[2] to 'perf data' CTF
         conversion, allowing CTF trace visualization tools to show callchains
         and to resolve symbols (Geneviève Bastien)
      
      Improvements:
      
       - Use group read for event groups in 'perf stat', reducing overhead when
         groups are defined in the event specification, i.e. when using {} to
         enclose a list of events, asking them to be read at the same time,
         e.g.: "perf stat -e '{cycles,instructions}'" (Jiri Olsa)
      
      Fixes:
      
       - Do not overwrite perf_sample->weight in 'perf annotate' when
         processing samples, use whatever came from the kernel when
         perf_event_attr.sample_type has PERF_SAMPLE_WEIGHT set or just handle
         its default value, 0, when that is not set and "weight" is one of the
         sort orders chosen (Arnaldo Carvalho de Melo)
      
       - 'perf annotate --show-total-period' fixes:
          - TUI should show period, not nr_samples
          - Set appropriate column width for period/percent
          - Fix the column header to show "Period" when when that is what
            is being asked for
         (Taeung Song, Arnaldo Carvalho de Melo)
      
       - Use default sort if evlist is empty, fixing pipe mode (David Carrillo-Cisneros)
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      c3a3800f
    • Ingo Molnar's avatar
  4. 28 Jul, 2017 9 commits
  5. 26 Jul, 2017 14 commits
    • Arnaldo Carvalho de Melo's avatar
      perf annotate stdio: Set enough columns for --show-total-period · ce9ee4a2
      Arnaldo Carvalho de Melo authored
      Now that we set the first column header according to wether
      --show-total-period is being used, we need to size it accordingly.
      Based-on-a-patch-by: default avatarTaeung Song <treeze.taeung@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Milian Wolff <milian.wolff@kdab.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: http://lkml.kernel.org/n/tip-pu504ffnit4m334k09hxcbs3@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      ce9ee4a2
    • David Carrillo-Cisneros's avatar
      perf sort: Use default sort if evlist is empty · 64831a21
      David Carrillo-Cisneros authored
      Fixes bug noted by Jiri in https://lkml.org/lkml/2017/6/13/755 and
      caused by commit d49dadea ("perf tools: Make 'trace' or
      'trace_fields' sort key default for tracepoint events") not taking into
      account that evlist is empty in pipe-mode.
      
      Before this commit, pipe mode will only show bogus "100.00%  N/A"
      instead of correct output as follows:
      
        $ perf record -o - sleep 1 | perf report -i -
        # To display the perf.data header info, please use --header/--header-only options.
        #
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.000 MB - ]
        #
        # Total Lost Samples: 0
        #
        # Samples: 8  of event 'cycles:ppH'
        # Event count (approx.): 145658
        #
        # Overhead  Trace output
        # ........  ............
        #
           100.00%  N/A
      
      Correct output, after patch:
      
        $ perf record -o - sleep 1 | perf report -i -
        # To display the perf.data header info, please use --header/--header-only options.
        #
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.000 MB - ]
        #
        # Total Lost Samples: 0
        #
        # Samples: 8  of event 'cycles:ppH'
        # Event count (approx.): 191331
        #
        # Overhead  Command  Shared Object      Symbol
        # ........  .......  .................  .................................
        #
            81.63%  sleep    libc-2.19.so       [.] _exit
            13.58%  sleep    ld-2.19.so         [.] do_lookup_x
             2.34%  sleep    [kernel.kallsyms]  [k] context_switch
             2.34%  sleep    libc-2.19.so       [.] __GI___libc_nanosleep
             0.11%  perf     [kernel.kallsyms]  [k] __intel_pmu_enable_a
      Reported-by: default avatarJiri Olsa <jolsa@kernel.org>
      Report-Link: https://lkml.kernel.org/r/20170613185422.GA6092@kravaSigned-off-by: default avatarDavid Carrillo-Cisneros <davidcc@google.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Turner <pjt@google.com>
      Cc: Simon Que <sque@chromium.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Fixes: d49dadea ("perf tools: Make 'trace' or 'trace_fields' sort key default for tracepoint events")
      Link: https://lkml.kernel.org/r/20170721051157.47331-1-davidcc@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      64831a21
    • Arnaldo Carvalho de Melo's avatar
      perf annotate: Do not overwrite perf_sample->weight · c6c13be7
      Arnaldo Carvalho de Melo authored
      When we parse an event we may get a value from the kernel in response to
      PERF_SAMPLE_WEIGHT being set in perf_event_attr->sample_type, and if it
      is not set, then perf_sample->weight will be set to zero, which should
      be ok according to a discussion with Andi Kleen [1]:
      
      1: https://lkml.kernel.org/r/20170724174637.GS3044@two.firstfloor.orgAcked-by: default avatarAndi Kleen <andi@firstfloor.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Milian Wolff <milian.wolff@kdab.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Taeung Song <treeze.taeung@gmail.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-8ev8ufk3lzmvgz37yg9nv3qz@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      c6c13be7
    • Jiri Olsa's avatar
      perf stat: Use group read for event groups · 82bf311e
      Jiri Olsa authored
      Make perf stat use  group read if there  are groups defined. The group
      read will get the values for all member of groups within a single
      syscall instead of calling read syscall for every event.
      
      We can see considerable less amount of kernel cycles spent on single
      group read, than reading each event separately, like for following perf
      stat command:
      
        # perf stat -e {cycles,instructions} -I 10 -a sleep 1
      
      Monitored with "perf stat -r 5 -e '{cycles:u,cycles:k}'"
      
      Before:
      
              24,325,676      cycles:u
             297,040,775      cycles:k
      
             1.038554134 seconds time elapsed
      
      After:
              25,034,418      cycles:u
             158,256,395      cycles:k
      
             1.036864497 seconds time elapsed
      
      The perf_evsel__open fallback changes contributed by Andi Kleen.
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <andi@firstfloor.org>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: http://lkml.kernel.org/r/20170726120206.9099-4-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      82bf311e
    • Jiri Olsa's avatar
      perf evsel: Add read_counter() · f7794d52
      Jiri Olsa authored
      Add perf_evsel__read_counter() to read single or group counter. After
      calling this function the counter's evsel::counts struct is filled with
      values for the counter and member of its group if there are any.
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <andi@firstfloor.org>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: http://lkml.kernel.org/r/20170726120206.9099-3-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      f7794d52
    • Jiri Olsa's avatar
      perf tools: Add perf_evsel__read_size function · de63403b
      Jiri Olsa authored
      Currently we use the size of struct perf_counts_values to read the
      event, which prevents us to put any new member to the struct.
      
      Adding perf_evsel__read_size to return size of the buffer needed for
      event read.
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <andi@firstfloor.org>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: http://lkml.kernel.org/r/20170726120206.9099-2-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      de63403b
    • Ingo Molnar's avatar
      Merge tag 'perf-core-for-mingo-4.14-20170725' of... · ee438ec8
      Ingo Molnar authored
      Merge tag 'perf-core-for-mingo-4.14-20170725' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core
      
      Pull perf/core improvemends and fixes for v4.14:
      
      New features:
      
      - Filter out 'sshd' in the tracer ancestry in 'perf trace' syswide tracing,
        to elliminate tracing loops (Arnaldo Carvalho de Melo)
      
      - Support lookup of symbols in other mount namespaces in 'perf top' (Krister Johansen)
      
      - Initial 'clone' syscall args beautifier in 'perf trace' (Arnaldo Carvalho de Melo)
      
      User visible changes:
      
      - Ignore 'fd' and 'offset' args for MAP_ANONYMOUS in 'perf trace'
        (Arnaldo Carvalho de Melo)
      
      - Process tracing data in 'perf annotate' pipe mode (David Carrillo-Cisneros)
      
      - Make 'perf report --branch-history' work without callgraphs(-g) option
        in perf record (Jin Yao)
      
      - Tag branch type/flag on "to" and tag cycles on "from" in 'perf report' (Jin Yao)
      
      Fixes:
      
      - Fix jvmti linker error when libelf config is disabled (Sudeep Holla)
      
      - Fix cgroups refcount usage (Arnaldo Carvalho de Melo)
      
      - Fix kernel symbol adjustment for s390x (Thomas Richter)
      
      - Fix 'perf report --stdio --show-total-period', it was showing the
        number of samples, not the total period (Taeung Song)
      
      Infrastructure changes:
      
      - Add perf_sample dictionary to tracepoint handlers in 'perf script'
        python, which were already present for other types of events
        (hardware, etc) (Arun Kalyanasundaram)
      
      - Make build fail on vendor events JSON parse error (Andi Kleen)
      
      - Adopt strstarts() from the kernel (Arnaldo Carvalho de Melo)
      
      Arch specific changes:
      
      - Set no_aux_samples for the tracking event in Intel PT (Kan Liang)
      
      - Always set no branch for Intel PT dummy event (Kan Liang)
      
      Trivial changes:
      
      - Simplify some error handlers in 'perf script' (Dan Carpenter)
      
      - Add EXCLUDE_EXTLIBS and EXTRA_PERFLIBS to makefile (David Carrillo-Cisneros)
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      ee438ec8
    • Arnaldo Carvalho de Melo's avatar
      perf tools: Add tools/include/uapi/asm-generic/fcntl.h to the MANIFEST · 62e6039f
      Arnaldo Carvalho de Melo authored
      This file was copied from the kernel so that we could build tools/perf/
      on older systems where some newer defines, such as these are available:
      
          CC       trace/beauty/fcntl.o
        trace/beauty/fcntl.c: In function ‘syscall_arg__scnprintf_fcntl_arg’:
        trace/beauty/fcntl.c:93:13: error: ‘F_OFD_SETLK’ undeclared (first use in this function)
              cmd == F_OFD_SETLK || cmd == F_OFD_SETLKW || cmd == F_OFD_GETLK ||
                     ^
        trace/beauty/fcntl.c:93:13: note: each undeclared identifier is reported only once for each function it appears in
        trace/beauty/fcntl.c:93:35: error: ‘F_OFD_SETLKW’ undeclared (first use in this function)
              cmd == F_OFD_SETLK || cmd == F_OFD_SETLKW || cmd == F_OFD_GETLK ||
                                           ^
        trace/beauty/fcntl.c:93:58: error: ‘F_OFD_GETLK’ undeclared (first use in this function)
              cmd == F_OFD_SETLK || cmd == F_OFD_SETLKW || cmd == F_OFD_GETLK ||
                                                                  ^
        mv: cannot stat ‘trace/beauty/.fcntl.o.tmp’: No such file or directory
        make[4]: *** [trace/beauty/fcntl.o] Error 1
        make[3]: *** [trace/beauty] Error 2
        make[3]: *** Waiting for unfinished jobs....
          CC       tests/llvm.o
      
      But we need to make sure that it is also in the tools/perf/MANIFEST file, that
      is used to build a tarball for detached (from the kernel sources) compilation,
      which was failing, with the above message, on a RHEL7.4 system, fix it.
      
      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: Wang Nan <wangnan0@huawei.com>
      Fixes: 84d1d8a1 ("tools include uapi asm-generic: Grab a copy of fcntl.h")
      Link: http://lkml.kernel.org/n/tip-2d5px7aq5stbwi24pgirwtlm@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      62e6039f
    • Taeung Song's avatar
      perf annotate stdio: Fix column header when using --show-total-period · 38d2dcd0
      Taeung Song authored
      Currently the first column header is always "Percent", fix it to show
      correct column name based on given options, i.e. if using
      --show-total-period, show "Event count" as a first column.
      Reported-by: default avatarMilian Wolff <milian.wolff@kdab.com>
      Signed-off-by: default avatarTaeung Song <treeze.taeung@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: http://lkml.kernel.org/r/c3c902e7-95bc-16d4-366f-12eb034c5c8d@gmail.com
      [ Extracted from a larger patch ]
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      38d2dcd0
    • Andi Kleen's avatar
      perf jevents: Make build fail on JSON parse error · 3f056b66
      Andi Kleen authored
      Today, when a JSON file fails parsing the build continues, but there are
      no json files built in, which is difficult to debug later.  Make the
      build stop on a parse error instead.
      
      v2: Add fixes from Sukadev. Now we handle architectures
          with no JSON events correctly. And fix some stale comments.
      
      Committer note:
      
      Tested by running the cross build container tests, that were all failing
      for v1.
      Signed-off-by: default avatarAndi Kleen <ak@linux.intel.com>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
      Link: http://lkml.kernel.org/r/20170725001638.19990-1-andi@firstfloor.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      3f056b66
    • Jin Yao's avatar
      perf report: Tag branch type/flag on "to" and tag cycles on "from" · a1a8bed3
      Jin Yao authored
      Current --branch-history LBR annotation displays confused data. For
      example, each cycles report is duplicated on both "from" and "to"
      entries.
      
      For example:
      
        perf report --branch-history --no-children --stdio
      
        --2.32%--main div.c:39 (COND_BWD CROSS_2M predicted:49.7% cycles:1)
                  main div.c:44 (predicted:49.7% cycles:1)
                  main div.c:42 (RET CROSS_2M cycles:2)
                  compute_flag div.c:28 (cycles:2)
                  compute_flag div.c:27 (RET CROSS_2M cycles:1)
                  rand rand.c:28 (cycles:1)
                  rand rand.c:28 (RET CROSS_2M cycles:1)
                  __random random.c:298 (cycles:1)
                  __random random.c:297 (COND_BWD CROSS_2M cycles:1)
                  __random random.c:295 (cycles:1)
                  __random random.c:295 (COND_BWD CROSS_2M cycles:1)
                  __random random.c:295 (cycles:1)
                  __random random.c:295 (RET CROSS_2M cycles:9)
      
      The cycles should be tagged only on the "from". It's for the code block
      that ends with "from", not for "to".
      
      Another issue is the "predicted:49.7%" is duplicated too (tag on both
      "from" and "to").
      
      This patch tags the branch type/flag on "to" and tag the cycles on
      "from".
      
      For example:
      
        --2.32%--main div.c:39 (COND_BWD CROSS_2M predicted:49.7%)
                  main div.c:44 (cycles:1)
                  main div.c:42 (RET CROSS_2M)
                  compute_flag div.c:28 (cycles:2)
                  compute_flag div.c:27 (RET CROSS_2M)
                  rand rand.c:28 (cycles:1)
                  rand rand.c:28 (RET CROSS_2M)
                  __random random.c:298 (cycles:1)
                  __random random.c:297 (COND_BWD CROSS_2M)
                  __random random.c:295 (cycles:1)
                  __random random.c:295 (COND_BWD CROSS_2M)
                  __random random.c:295 (cycles:1)
                  __random random.c:295 (RET CROSS_2M)
                  |
                   --2.23%--__random_r random_r.c:392 (cycles:9)
      
      In this example, The "main div.c:39 (COND_BWD CROSS_2M predicted:49.7%)"
      is "to" of branch and "main div.c:44 (cycles:1)" is "from" of branch.
      It should be easier for understanding than before.
      Signed-off-by: default avatarYao Jin <yao.jin@linux.intel.com>
      Reviewed-by: default avatarAndi Kleen <ak@linux.intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/1500894547-18411-1-git-send-email-yao.jin@linux.intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      a1a8bed3
    • Jin Yao's avatar
      perf report: Make --branch-history work without callgraphs(-g) option in perf record · b49a821e
      Jin Yao authored
        perf record -b -g <command>
        perf report --branch-history
      
      This merges the LBRs with the callgraphs.
      
      However it would be nice if it also works without callgraphs (-g) set in
      perf record, so that only the LBRs are displayed.  But currently perf
      report errors in this case. For example,
      
        perf record -b <command>
        perf report --branch-history
      
        Error:
        Selected -g or --branch-history but no callchain data. Did
        you call 'perf record' without -g?
      
      This patch displays the LBRs only even if callgraphs(-g) is not enabled
      in perf record.
      
      Change log:
      
      v2: According to Milian Wolff's comment, change the obsolete error
      message. Now the error message is:
      
                       ┌─Error:─────────────────────────────────────┐
                       │Selected -g or --branch-history.            │
                       │But no callchain or branch data.            │
                       │Did you call 'perf record' without -g or -b?│
                       │                                            │
                       │                                            │
                       │Press any key...                            │
                       └────────────────────────────────────────────┘
      
      When passing the last parameter to hists__fprintf,
      changes "|" to "||".
      
        hists__fprintf(hists, !quiet, 0, 0, rep->min_percent, stdout,
                       symbol_conf.use_callchain || symbol_conf.show_branchflag_count);
      Signed-off-by: default avatarYao Jin <yao.jin@linux.intel.com>
      Reviewed-by: default avatarAndi Kleen <ak@linux.intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/1494240182-28899-1-git-send-email-yao.jin@linux.intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      b49a821e
    • Arun Kalyanasundaram's avatar
      perf script python: Generate hooks with additional argument · a6418605
      Arun Kalyanasundaram authored
      Modify the signature of tracepoint specific and trace_unhandled hooks to
      add the perf_sample dict as a new argument.
      Create a python helper function to print a dictionary.
      Signed-off-by: default avatarArun Kalyanasundaram <arunkaly@google.com>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: David Carrillo-Cisneros <davidcc@google.com>
      Cc: David S. Miller <davem@davemloft.net>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Seongjae Park <sj38.park@gmail.com>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/r/20170721220422.63962-6-arunkaly@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      a6418605
    • Arun Kalyanasundaram's avatar
      perf script python: Add perf_sample dict to tracepoint handlers · f38d2816
      Arun Kalyanasundaram authored
      The process_event python hook receives a dict with all perf_sample
      entries, but the tracepoint specific and trace_unhandled hooks predate
      the introduction of this dict, and do not receive it.
      
      Add the aforementioned dict as an additional argument to the affected
      handlers. To keep backwards compatibility (and avoid unnecessary work),
      do not pass the dict if the number of arguments signals that handler
      version predates this change.
      Signed-off-by: default avatarArun Kalyanasundaram <arunkaly@google.com>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: David Carrillo-Cisneros <davidcc@google.com>
      Cc: David S. Miller <davem@davemloft.net>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Seongjae Park <sj38.park@gmail.com>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/r/20170721220422.63962-5-arunkaly@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      f38d2816