02 Nov, 2017

1 commit

  • Many source files in the tree are missing licensing information, which
    makes it harder for compliance tools to determine the correct license.

    By default all files without license information are under the default
    license of the kernel, which is GPL version 2.

    Update the files which contain no license information with the 'GPL-2.0'
    SPDX license identifier. The SPDX identifier is a legally binding
    shorthand, which can be used instead of the full boiler plate text.

    This patch is based on work done by Thomas Gleixner and Kate Stewart and
    Philippe Ombredanne.

    How this work was done:

    Patches were generated and checked against linux-4.14-rc6 for a subset of
    the use cases:
    - file had no licensing information it it.
    - file was a */uapi/* one with no licensing information in it,
    - file was a */uapi/* one with existing licensing information,

    Further patches will be generated in subsequent months to fix up cases
    where non-standard license headers were used, and references to license
    had to be inferred by heuristics based on keywords.

    The analysis to determine which SPDX License Identifier to be applied to
    a file was done in a spreadsheet of side by side results from of the
    output of two independent scanners (ScanCode & Windriver) producing SPDX
    tag:value files created by Philippe Ombredanne. Philippe prepared the
    base worksheet, and did an initial spot review of a few 1000 files.

    The 4.13 kernel was the starting point of the analysis with 60,537 files
    assessed. Kate Stewart did a file by file comparison of the scanner
    results in the spreadsheet to determine which SPDX license identifier(s)
    to be applied to the file. She confirmed any determination that was not
    immediately clear with lawyers working with the Linux Foundation.

    Criteria used to select files for SPDX license identifier tagging was:
    - Files considered eligible had to be source code files.
    - Make and config files were included as candidates if they contained >5
    lines of source
    - File already had some variant of a license header in it (even if
    Reviewed-by: Philippe Ombredanne
    Reviewed-by: Thomas Gleixner
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

29 Aug, 2017

1 commit

  • Reuse 'mprotect' beautifiers for 'pkey_mprotect'.

    System wide tracing pkey_alloc, pkey_free and pkey_mprotect calls, with
    backtraces:

    # perf trace -e pkey_alloc,pkey_mprotect,pkey_free --max-stack=5
    0.000 ( 0.011 ms): pkey/7818 pkey_alloc(init_val: DISABLE_ACCESS|DISABLE_WRITE) = -1 EINVAL Invalid argument
    syscall (/usr/lib64/libc-2.25.so)
    pkey_alloc (/home/acme/c/pkey)
    0.022 ( 0.003 ms): pkey/7818 pkey_mprotect(start: 0x7f28c3890000, len: 4096, prot: READ|WRITE, pkey: -1) = 0
    syscall (/usr/lib64/libc-2.25.so)
    pkey_mprotect (/home/acme/c/pkey)
    0.030 ( 0.002 ms): pkey/7818 pkey_free(pkey: -1 ) = -1 EINVAL Invalid argument
    syscall (/usr/lib64/libc-2.25.so)
    pkey_free (/home/acme/c/pkey)

    The tools/include/uapi/asm-generic/mman-common.h file is used to find
    the access rights defines for the pkey_alloc syscall second argument.

    Since we have the detector of changes for the tools/include header files
    versus its kernel origin (include/uapi/asm-generic/mman-common.h), we'll
    get whatever new flag appears for that argument automatically.

    This method should be used in other cases where it is easy to generate
    those flags tables because the header has properly namespaced defines
    like PKEY_DISABLE_ACCESS and PKEY_DISABLE_WRITE.

    Cc: Adrian Hunter
    Cc: Arnd Bergmann
    Cc: Dave Hansen
    Cc: David Ahern
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Cc: Wang Nan
    Link: http://lkml.kernel.org/n/tip-3xq5312qlks7wtfzv2sk3nct@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Arnaldo Carvalho de Melo
     

02 Aug, 2017

6 commits

  • Also trying a new approach, using the copy of uapi/linux/perf_event.h we
    auto generate the string tables, then include it in the ioctl cmd
    beautifier.

    This way either the perf 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., looking at some of the perf ioctls issued by the 'perf test' test cases:

    # (perf trace -e perf_event_open,ioctl perf test) 2>&1 | egrep "(cmd: PERF_|perf_event_open)"
    4: Read samples using the mmap interface :
    348.811 ( 0.062 ms): perf/23351 perf_event_open(attr_uptr: 0x414a5e8, pid: 23351 (perf), group_fd: -1, flags: FD_CLOEXEC) = 3
    348.878 ( 0.039 ms): perf/23351 perf_event_open(attr_uptr: 0x414a5e8, pid: 23351 (perf), cpu: 1, group_fd: -1, flags: FD_CLOEXEC) = 4
    348.919 ( 0.036 ms): perf/23351 perf_event_open(attr_uptr: 0x414a5e8, pid: 23351 (perf), cpu: 2, group_fd: -1, flags: FD_CLOEXEC) = 5
    348.958 ( 0.036 ms): perf/23351 perf_event_open(attr_uptr: 0x414a5e8, pid: 23351 (perf), cpu: 3, group_fd: -1, flags: FD_CLOEXEC) = 6
    349.070 ( 0.046 ms): perf/23351 perf_event_open(attr_uptr: 0x414aa38, pid: 23351 (perf), group_fd: -1, flags: FD_CLOEXEC) = 7
    349.120 ( 0.037 ms): perf/23351 perf_event_open(attr_uptr: 0x414aa38, pid: 23351 (perf), cpu: 1, group_fd: -1, flags: FD_CLOEXEC) = 8
    349.161 ( 0.036 ms): perf/23351 perf_event_open(attr_uptr: 0x414aa38, pid: 23351 (perf), cpu: 2, group_fd: -1, flags: FD_CLOEXEC) = 9
    349.201 ( 0.035 ms): perf/23351 perf_event_open(attr_uptr: 0x414aa38, pid: 23351 (perf), cpu: 3, group_fd: -1, flags: FD_CLOEXEC) = 10
    349.306 ( 0.041 ms): perf/23351 perf_event_open(attr_uptr: 0x414b2d8, pid: 23351 (perf), group_fd: -1, flags: FD_CLOEXEC) = 11
    349.611 ( 0.005 ms): perf/23351 ioctl(fd: 3, cmd: PERF_ID, arg: 0x7fff025999b8) = 0
    349.619 ( 0.002 ms): perf/23351 ioctl(fd: 7, cmd: PERF_SET_OUTPUT, arg: 0x3 ) = 0
    349.623 ( 0.002 ms): perf/23351 ioctl(fd: 7, cmd: PERF_ID, arg: 0x7fff025999b8) = 0
    349.627 ( 0.002 ms): perf/23351 ioctl(fd: 11, cmd: PERF_SET_OUTPUT, arg: 0x3 ) = 0
    349.630 ( 0.001 ms): perf/23351 ioctl(fd: 11, cmd: PERF_ID, arg: 0x7fff025999b8) = 0

    7: PERF_RECORD_* events & perf_sample fields :
    647.150 ( 0.014 ms): perf/23354 perf_event_open(attr_uptr: 0x7fff02599920, pid: -1, cpu: 2, group_fd: -1, flags: FD_CLOEXEC) = 3
    647.197 ( 0.076 ms): perf/23354 perf_event_open(attr_uptr: 0x414b478, pid: -1, group_fd: -1, flags: FD_CLOEXEC) = 3
    647.289 ( 0.040 ms): perf/23354 perf_event_open(attr_uptr: 0x414b478, pid: -1, group_fd: -1, flags: FD_CLOEXEC) = 3
    647.368 ( 0.011 ms): perf/23354 perf_event_open(attr_uptr: 0x414a5e8, pid: 23355 (perf), group_fd: -1, flags: FD_CLOEXEC) = 3
    647.381 ( 0.005 ms): perf/23354 perf_event_open(attr_uptr: 0x414a5e8, pid: 23355 (perf), cpu: 1, group_fd: -1, flags: FD_CLOEXEC) = 4
    647.387 ( 0.005 ms): perf/23354 perf_event_open(attr_uptr: 0x414a5e8, pid: 23355 (perf), cpu: 2, group_fd: -1, flags: FD_CLOEXEC) = 5
    647.393 ( 0.004 ms): perf/23354 perf_event_open(attr_uptr: 0x414a5e8, pid: 23355 (perf), cpu: 3, group_fd: -1, flags: FD_CLOEXEC) = 7
    648.026 ( 0.011 ms): perf/23354 ioctl(fd: 3, cmd: PERF_ENABLE) = 0
    648.038 ( 0.002 ms): perf/23354 ioctl(fd: 4, cmd: PERF_ENABLE) = 0
    648.042 ( 0.002 ms): perf/23354 ioctl(fd: 5, cmd: PERF_ENABLE) = 0
    648.045 ( 0.002 ms): perf/23354 ioctl(fd: 7, cmd: PERF_ENABLE) = 0

    18: Breakpoint overflow signal handler :
    2772.721 ( 0.017 ms): perf/23375 perf_event_open(attr_uptr: 0x7fff02599d20, pid: -1, cpu: 3, group_fd: -1, flags: FD_CLOEXEC) = 3
    2772.748 ( 0.009 ms): perf/23375 perf_event_open(attr_uptr: 0x7fff02599e60, cpu: -1, group_fd: -1, flags: FD_CLOEXEC) = 3
    2772.768 ( 0.002 ms): perf/23375 ioctl(fd: 3, cmd: PERF_RESET) = 0
    2772.776 ( 0.008 ms): perf/23375 perf_event_open(attr_uptr: 0x7fff02599e60, cpu: -1, group_fd: -1, flags: FD_CLOEXEC) = 4
    2772.788 ( 0.002 ms): perf/23375 ioctl(fd: 4, cmd: PERF_RESET) = 0
    2772.791 ( 0.006 ms): perf/23375 perf_event_open(attr_uptr: 0x7fff02599e60, cpu: -1, group_fd: -1, flags: FD_CLOEXEC) = 5
    2772.800 ( 0.001 ms): perf/23375 ioctl(fd: 5, cmd: PERF_RESET) = 0
    2772.803 ( 0.005 ms): perf/23375 ioctl(fd: 3, cmd: PERF_ENABLE) = 0
    2772.810 ( 0.004 ms): perf/23375 ioctl(fd: 4, cmd: PERF_ENABLE) = 0
    2772.815 ( 0.004 ms): perf/23375 ioctl(fd: 5, cmd: PERF_ENABLE) = 0

    Cc: Adrian Hunter
    Cc: David Ahern
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Cc: Wang Nan
    Link: http://lkml.kernel.org/n/tip-ahotwscqt080ae0ulu3zznh2@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Arnaldo Carvalho de Melo
     
  • 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

    Arnaldo Carvalho de Melo
     
  • 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-rq6q717ql7j2z7kuccafgq84@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Arnaldo Carvalho de Melo
     
  • 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, cmd: KVM_IRQ_LINE_STATUS, arg: 0x7f484c6c73c0) = 0

    7801.715 ( 0.001 ms): CPU 0/KVM/21276 ioctl(fd: 13, cmd: KVM_IRQ_LINE_STATUS, arg: 0x7f484c6c73e0) = 0
    11001.051 ( 0.008 ms): qemu-system-x8/21238 ioctl(fd: 13, cmd: KVM_SIGNAL_MSI, arg: 0x563c83379d70) = 1
    11001.225 ( 0.005 ms): qemu-system-x8/21238 ioctl(fd: 13, 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, cmd: KVM_SIGNAL_MSI, arg: 0x563c83379d90) = 1
    11011.929 ( 0.005 ms): qemu-system-x8/21238 ioctl(fd: 13, cmd: KVM_SIGNAL_MSI, arg: 0x7fff053e1000) = 1
    11012.090 ( 0.004 ms): qemu-system-x8/21238 ioctl(fd: 13, cmd: KVM_SIGNAL_MSI, arg: 0x563c83379d70) = 1
    11023.127 ( 0.020 ms): qemu-system-x8/21238 ioctl(fd: 13, 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, cmd: KVM_IRQ_LINE_STATUS, arg: 0x7fff053e1080) = 0

    25621.025 ( 0.002 ms): qemu-system-x8/21238 ioctl(fd: 13, 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, cmd: KVM_IRQ_LINE_STATUS, arg: 0x7f484c6c73c0) = 0

    25621.346 ( 0.001 ms): CPU 0/KVM/21276 ioctl(fd: 13, cmd: KVM_IRQ_LINE_STATUS, arg: 0x7f484c6c73e0) = 0
    40456.997 ( 0.100 ms): qemu-system-x8/21238 ioctl(fd: 27, cmd: (WRITE, 0xaf, 0x30, 0x8), arg: 0x7fff053dffe0) = 0
    40457.100 ( 0.019 ms): qemu-system-x8/21238 ioctl(fd: 27, cmd: (WRITE, 0xaf, 0x30, 0x8), arg: 0x7fff053dffe0) = 0
    40457.133 ( 0.002 ms): qemu-system-x8/21238 ioctl(fd: 27, cmd: (READ|WRITE, 0xaf, 0x12, 0x8), arg: 0x7fff053dff60) = 0
    40457.139 ( 0.001 ms): qemu-system-x8/21238 ioctl(fd: 27, cmd: (READ|WRITE, 0xaf, 0x12, 0x8), arg: 0x7fff053dff60) = 0
    40458.503 ( 0.027 ms): qemu-system-x8/21238 ioctl(fd: 13, cmd: KVM_IOEVENTFD, arg: 0x7fff053dfc80) = 0
    40458.601 ( 0.030 ms): qemu-system-x8/21238 ioctl(fd: 13, cmd: KVM_IOEVENTFD, arg: 0x7fff053dfc80) = 0
    40458.649 ( 0.003 ms): qemu-system-x8/21238 ioctl(fd: 27, cmd: (WRITE, 0xaf, 0x21, 0x8), arg: 0x7fff053dff20) = 0
    40458.654 ( 0.002 ms): qemu-system-x8/21238 ioctl(fd: 27, cmd: (WRITE, 0xaf, 0x21, 0x8), arg: 0x7fff053dff20) = 0
    40458.657 ( 0.018 ms): qemu-system-x8/21238 ioctl(fd: 13, cmd: KVM_IRQFD, arg: 0x7fff053dff00 ) = 0
    40459.077 ( 0.017 ms): qemu-system-x8/21238 ioctl(fd: 13, cmd: KVM_IRQFD, arg: 0x7fff053dff00 ) = 0
    40459.123 ( 0.017 ms): qemu-system-x8/21238 ioctl(fd: 13, cmd: KVM_IOEVENTFD, arg: 0x7fff053dfd20) = 0

    40463.477 ( 0.013 ms): qemu-system-x8/21238 ioctl(fd: 13, cmd: KVM_IOEVENTFD, arg: 0x7fff053dfd20) = 0
    40464.874 ( 0.010 ms): qemu-system-x8/21238 ioctl(fd: 13, cmd: KVM_GET_VCPU_EVENTS, arg: 0x7fff053e0000) = 0
    40464.892 ( 0.048 ms): qemu-system-x8/21238 ioctl(fd: 12, cmd: KVM_CHECK_EXTENSION, arg: 0x4c ) = 1
    40464.991 ( 0.002 ms): qemu-system-x8/21238 ioctl(fd: 13, cmd: KVM_GET_CLOCK, arg: 0x7fff053e0040) = 0
    40464.962 ( 0.013 ms): CPU 0/KVM/21276 ioctl(fd: 20, cmd: KVM_GET_MSRS, arg: 0x7f484c6c7670) = 1
    44540.437 ( 0.103 ms): qemu-system-x8/21238 ioctl(fd: 13, cmd: KVM_SET_GSI_ROUTING, arg: 0x563c7c93c000) = 0
    44540.544 ( 0.008 ms): qemu-system-x8/21238 ioctl(fd: 13, cmd: KVM_IRQFD, arg: 0x7fff053dfea0 ) = 0
    44540.555 ( 0.029 ms): qemu-system-x8/21238 ioctl(fd: 13, cmd: KVM_SET_GSI_ROUTING, arg: 0x563c7c93c000) = 0
    44540.586 ( 0.003 ms): qemu-system-x8/21238 ioctl(fd: 13, cmd: KVM_IRQFD, arg: 0x7fff053dfea0 ) = 0
    44540.592 ( 0.027 ms): qemu-system-x8/21238 ioctl(fd: 13, cmd: KVM_SET_GSI_ROUTING, arg: 0x563c7c93c000) = 0
    44540.625 ( 0.005 ms): qemu-system-x8/21238 ioctl(fd: 27, cmd: (WRITE, 0xaf, 0x21, 0x8), arg: 0x7fff053dfe20) = 0
    44540.639 ( 0.018 ms): qemu-system-x8/21238 ioctl(fd: 13, cmd: KVM_SET_GSI_ROUTING, arg: 0x563c7c93c000) = 0
    44540.658 ( 0.003 ms): qemu-system-x8/21238 ioctl(fd: 27, cmd: (WRITE, 0xaf, 0x21, 0x8), arg: 0x7fff053dfe20) = 0
    44540.686 ( 0.015 ms): qemu-system-x8/21238 ioctl(fd: 13, cmd: KVM_IOEVENTFD, arg: 0x7fff053dfbe0) = 0
    44540.727 ( 0.014 ms): qemu-system-x8/21238 ioctl(fd: 13, cmd: KVM_IOEVENTFD, arg: 0x7fff053dfbe0) = 0
    44540.748 ( 0.005 ms): qemu-system-x8/21238 ioctl(fd: 27, cmd: (WRITE, 0xaf, 0, 0x8), arg: 0x7fff053dfe88) = 0
    44540.754 ( 0.026 ms): qemu-system-x8/21238 ioctl(fd: 27, cmd: (WRITE, 0xaf, 0x3, 0x8), arg: 0x563c7c906870) = 0
    44540.783 ( 0.002 ms): qemu-system-x8/21238 ioctl(fd: 27, cmd: (WRITE, 0xaf, 0x10, 0x8), arg: 0x7fff053dff00) = 0
    44540.787 ( 0.002 ms): qemu-system-x8/21238 ioctl(fd: 27, cmd: (WRITE, 0xaf, 0x12, 0x8), arg: 0x7fff053dff00) = 0
    44540.793 ( 0.002 ms): qemu-system-x8/21238 ioctl(fd: 27, cmd: (WRITE, 0xaf, 0x11, 0x28), arg: 0x7fff053dfe70) = 0
    44540.796 ( 0.010 ms): qemu-system-x8/21238 ioctl(fd: 27, cmd: (WRITE, 0xaf, 0x20, 0x8), arg: 0x7fff053dfef0) = 0
    44540.811 ( 0.002 ms): qemu-system-x8/21238 ioctl(fd: 27, cmd: (WRITE, 0xaf, 0x10, 0x8), arg: 0x7fff053dff00) = 0
    44540.814 ( 0.002 ms): qemu-system-x8/21238 ioctl(fd: 27, cmd: (WRITE, 0xaf, 0x12, 0x8), arg: 0x7fff053dff00) = 0
    44540.819 ( 0.002 ms): qemu-system-x8/21238 ioctl(fd: 27, cmd: (WRITE, 0xaf, 0x11, 0x28), arg: 0x7fff053dfe70) = 0
    44540.822 ( 0.005 ms): qemu-system-x8/21238 ioctl(fd: 27, cmd: (WRITE, 0xaf, 0x20, 0x8), arg: 0x7fff053dfef0) = 0
    44540.837 ( 0.006 ms): qemu-system-x8/21238 ioctl(fd: 27, cmd: (WRITE, 0xaf, 0x30, 0x8), arg: 0x7fff053dff80) = 0
    44540.862 ( 0.004 ms): qemu-system-x8/21238 ioctl(fd: 27, cmd: (WRITE, 0xaf, 0x30, 0x8), arg: 0x7fff053dff80) = 0
    44540.887 ( 0.014 ms): qemu-system-x8/21238 ioctl(fd: 13, cmd: KVM_IOEVENTFD, arg: 0x7fff053dfd00) = 0

    44542.756 ( 0.020 ms): qemu-system-x8/21238 ioctl(fd: 13, cmd: KVM_IOEVENTFD, arg: 0x7fff053dfd00) = 0
    44542.809 ( 0.007 ms): qemu-system-x8/21238 ioctl(fd: 13, cmd: KVM_SET_VCPU_EVENTS, arg: 0x7fff053dffb0) = 0
    44542.819 ( 0.003 ms): qemu-system-x8/21238 ioctl(fd: 12, cmd: KVM_CHECK_EXTENSION, arg: 0x4c ) = 1
    44543.016 ( 0.004 ms): qemu-system-x8/21238 ioctl(fd: 13, cmd: KVM_SET_CLOCK, arg: 0x7fff053dfff0) = 0
    44543.022 ( 0.008 ms): qemu-system-x8/21238 ioctl(fd: 20, cmd: KVM_KVMCLOCK_CTRL ) = 0
    46952.502 ( 0.010 ms): qemu-system-x8/21238 ioctl(fd: 13, 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
    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-zxhebe579n338d7qrnjoctes@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Arnaldo Carvalho de Melo
     
  • 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, cmd: SNDRV_PCM_HWSYNC, arg: 0x557f8d7fa0f0) = 0
    0.344 ( 0.041 ms): alsa-sink-ALC3/22084 ioctl(fd: 46, cmd: SNDRV_CTL_ELEM_READ, arg: 0x7fe764018ee0) = 0
    0.403 ( 0.011 ms): alsa-sink-ALC3/22084 ioctl(fd: 49, cmd: SNDRV_PCM_HWSYNC, arg: 0x557f8d7fa0f0) = 0
    0.427 ( 0.009 ms): alsa-sink-ALC3/22084 ioctl(fd: 49, cmd: SNDRV_PCM_STATUS_EXT, arg: 0x7fe76c2e0b30) = 0
    2.461 ( 0.042 ms): alsa-sink-ALC3/22084 ioctl(fd: 49, cmd: SNDRV_PCM_HWSYNC, arg: 0x557f8d7fa0f0) = 0
    #

    Cc: Adrian Hunter
    Cc: David Ahern
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Cc: Wang Nan
    Link: http://lkml.kernel.org/n/tip-8zuyf3e3u6jjcb2xzerw0kdi@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Arnaldo Carvalho de Melo
     
  • 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, cmd: DRM_I915_GEM_BUSY, arg: 0x7ffc934f7600) = 0
    1010.865 (0.003 ms): gnome-shell/22401 ioctl(fd: 8, cmd: DRM_I915_GEM_SET_DOMAIN, arg: 0x7ffc934f7550) = 0
    1010.872 (0.002 ms): gnome-shell/22401 ioctl(fd: 8, cmd: DRM_I915_GEM_SW_FINISH, arg: 0x7ffc934f76e0) = 0
    1010.939 (0.015 ms): gnome-shell/22401 ioctl(fd: 8, cmd: DRM_I915_GEM_SW_FINISH, arg: 0x7ffc934f7780) = 0
    1010.959 (0.085 ms): gnome-shell/22401 ioctl(fd: 8, cmd: DRM_I915_GEM_EXECBUFFER2, arg: 0x7ffc934f7700) = 0
    1011.048 (0.003 ms): gnome-shell/22401 ioctl(fd: 8, cmd: DRM_I915_GEM_SET_DOMAIN, arg: 0x7ffc934f7780) = 0
    1011.056 (0.002 ms): gnome-shell/22401 ioctl(fd: 8, cmd: DRM_I915_GEM_MADVISE, arg: 0x7ffc934f76f0) = 0
    1011.060 (0.002 ms): gnome-shell/22401 ioctl(fd: 8, cmd: DRM_I915_GEM_BUSY, arg: 0x7ffc934f76c0) = 0
    1011.064 (0.003 ms): gnome-shell/22401 ioctl(fd: 8, cmd: DRM_I915_GEM_MADVISE, arg: 0x7ffc934f76b0) = 0
    1011.068 (0.002 ms): gnome-shell/22401 ioctl(fd: 8, cmd: DRM_I915_GEM_SET_DOMAIN, arg: 0x7ffc934f76d0) = 0
    1011.074 (0.009 ms): gnome-shell/22401 ioctl(fd: 8, cmd: DRM_MODE_ADDFB, arg: 0x7ffc934f7880 ) = 0
    1011.096 (0.072 ms): gnome-shell/22401 ioctl(fd: 8, cmd: DRM_MODE_PAGE_FLIP, arg: 0x7ffc934f77d0) = 0
    ^C[root@jouet linux]#

    Cc: Adrian Hunter
    Cc: David Ahern
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Cc: Wang Nan
    Link: http://lkml.kernel.org/n/tip-mly2d7v9kf28rso81dijbixq@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Arnaldo Carvalho de Melo
     

01 Aug, 2017

1 commit

  • 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, cmd: (READ|WRITE, 0x64, 0xae, 0x1c), arg: 0x7ffc934f7880) = 0
    474.369 ( 0.053 ms): gnome-shell/22401 ioctl(fd: 8, cmd: (READ|WRITE, 0x64, 0xb0, 0x18), arg: 0x7ffc934f77d0) = 0
    505.055 ( 0.014 ms): gnome-shell/22401 ioctl(fd: 8, 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
    Cc: David Ahern
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Cc: Wang Nan
    Link: http://lkml.kernel.org/n/tip-s3enursdxsvnhdomh6qlte4g@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Arnaldo Carvalho de Melo
     

20 Jul, 2017

3 commits

  • The 'parent_tidptr', 'child_tidptr' and 'tls' arguments to the 'clone'
    syscall are only used when certain flags are set in 'flags', suppress
    them when those aren't there.

    E.g:

    9886.919 (0.236 ms): fetchmail/19298 clone(flags: CHILD_CLEARTID|CHILD_SETTID|0x11, child_stack: 0, child_tidptr: 0x7fe43f468590) = 19608 (fetchmail)
    12876.052 (0.249 ms): qemu-system-x8/21238 clone(flags: VM|FS|FILES|SIGHAND|THREAD|SYSVSEM|SETTLS|PARENT_SETTID|CHILD_CLEARTID, child_stack: 0x7f48117fc770, parent_tidptr: 0x7f48117ff9d0, child_tidptr: 0x7f48117ff9d0, tls: 0x7f48117ff700) = 19611 (qemu-system-x86)
    12876.555 (0.048 ms): worker/19611 clone(flags: VM|FS|FILES|SIGHAND|THREAD|SYSVSEM|SETTLS|PARENT_SETTID|CHILD_CLEARTID, child_stack: 0x7f480f7f8770, parent_tidptr: 0x7f480f7fb9d0, child_tidptr: 0x7f480f7fb9d0, tls: 0x7f480f7fb700) = 19612 (worker)
    16575.240 (0.469 ms): fetchmail/19298 clone(flags: CHILD_CLEARTID|CHILD_SETTID|0x11, child_stack: 0, child_tidptr: 0x7fe43f468590) = 19613 (fetchmail)
    20797.270 (0.335 ms): fetchmail/19298 clone(flags: CHILD_CLEARTID|CHILD_SETTID|0x11, child_stack: 0, child_tidptr: 0x7fe43f468590) = 19614 (fetchmail)
    21228.585 (0.501 ms): vim/19519 clone(flags: CHILD_CLEARTID|CHILD_SETTID|0x11, child_stack: 0, child_tidptr: 0x7fbad6ac27d0) = 19615 (vim)
    21232.193 (0.137 ms): bash/19615 clone(flags: CHILD_CLEARTID|CHILD_SETTID|0x11, child_stack: 0, child_tidptr: 0x7fad8bff49d0) = 19616 (bash)

    Cc: Adrian Hunter
    Cc: David Ahern
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Cc: Wang Nan
    Link: http://lkml.kernel.org/n/tip-0um93djul9knf239gwa5mpcb@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Arnaldo Carvalho de Melo
     
  • Now, syswide tracing, selected entries:

    # trace -e clone
    24417.203 ( 0.158 ms): bash/11323 clone(flags: CHILD_CLEARTID|CHILD_SETTID|0x11, child_stack: 0, parent_tidptr: 0, child_tidptr: 0x7f0778e5c9d0, tls: 0x7f0778e5c700) = 11325 (bash)
    ? ( ? ): bash/11325 ... [continued]: clone()) = 0
    24419.355 ( 0.093 ms): bash/10586 clone(flags: CHILD_CLEARTID|CHILD_SETTID|0x11, child_stack: 0, parent_tidptr: 0, child_tidptr: 0x7f0778e5c9d0, tls: 0x7f0778e5c700) = 11326 (bash)
    ? ( ? ): bash/11326 ... [continued]: clone()) = 0
    24419.744 ( 0.102 ms): bash/11326 clone(flags: CHILD_CLEARTID|CHILD_SETTID|0x11, child_stack: 0, parent_tidptr: 0, child_tidptr: 0x7f0778e5c9d0, tls: 0x7f0778e5c700) = 11327 (bash)
    ? ( ? ): bash/11327 ... [continued]: clone()) = 0
    24420.138 ( 0.105 ms): bash/11327 clone(flags: CHILD_CLEARTID|CHILD_SETTID|0x11, child_stack: 0, parent_tidptr: 0, child_tidptr: 0x7f0778e5c9d0, tls: 0x7f0778e5c700) = 11328 (bash)
    ? ( ? ): bash/11328 ... [continued]: clone()) = 0
    35747.722 ( 0.044 ms): gpg-agent/18087 clone(flags: VM|FS|FILES|SIGHAND|THREAD|SYSVSEM|SETTLS|PARENT_SETTID|CHILD_CLEARTID, child_stack: 0x7ff0755f6ff0, parent_tidptr: 0x7ff0755f79d0, child_tidptr: 0x7ff0755f79d0, tls: 0x7ff0755f7700) = 11329 (gpg-agent)
    ? ( ? ): gpg-agent/11329 ... [continued]: clone()) = 0
    35748.359 ( 0.022 ms): gpg-agent/18087 clone(flags: VM|FS|FILES|SIGHAND|THREAD|SYSVSEM|SETTLS|PARENT_SETTID|CHILD_CLEARTID, child_stack: 0x7ff075df7ff0, parent_tidptr: 0x7ff075df89d0, child_tidptr: 0x7ff075df89d0, tls: 0x7ff075df8700) = 11330 (gpg-agent)
    ? ( ? ): gpg-agent/11330 ... [continued]: clone()) = 0
    35781.422 ( 0.452 ms): NetworkManager/1112 clone(flags: VM|FS|FILES|SIGHAND|THREAD|SYSVSEM|SETTLS|PARENT_SETTID|CHILD_CLEARTID, child_stack: 0x7f2f1fffedb0, parent_tidptr: 0x7f2f1ffff9d0, child_tidptr: 0x7f2f1ffff9d0, tls: 0x7f2f1ffff700) = 11331 (NetworkManager)
    ? ( ? ): NetworkManager/11331 ... [continued]: clone()) = 0

    Need to improve the formatting of the second return, to the child, this
    cset only focused on the argument formatting.

    If we trace just one pid:

    # trace -e clone -p 19863
    0.349 ( 0.025 ms): Chrome_IOThrea/19863 clone(flags: VM|FS|FILES|SIGHAND|THREAD|SYSVSEM|SETTLS|PARENT_SETTID|CHILD_CLEARTID, child_stack: 0x7ffb84eaac70, parent_tidptr: 0x7ffb84eab9d0, child_tidptr: 0x7ffb84eab9d0, tls: 0x7ffb84eab700) = 11637 (Chrome_IOThread)
    0.392 ( 0.013 ms): Chrome_IOThrea/19863 clone(flags: VM|FS|FILES|SIGHAND|THREAD|SYSVSEM|SETTLS|PARENT_SETTID|CHILD_CLEARTID, child_stack: 0x7ffb664b8c70, parent_tidptr: 0x7ffb664b99d0, child_tidptr: 0x7ffb664b99d0, tls: 0x7ffb664b9700) = 11638 (Chrome_IOThread)
    0.573 ( 0.015 ms): Chrome_IOThrea/19863 clone(flags: VM|FS|FILES|SIGHAND|THREAD|SYSVSEM|SETTLS|PARENT_SETTID|CHILD_CLEARTID, child_stack: 0x7ffb6046cc70, parent_tidptr: 0x7ffb6046d9d0, child_tidptr: 0x7ffb6046d9d0, tls: 0x7ffb6046d700) = 11639 (Chrome_IOThread)
    0.617 ( 0.014 ms): Chrome_IOThrea/19863 clone(flags: VM|FS|FILES|SIGHAND|THREAD|SYSVSEM|SETTLS|PARENT_SETTID|CHILD_CLEARTID, child_stack: 0x7ffb730dcc70, parent_tidptr: 0x7ffb730dd9d0, child_tidptr: 0x7ffb730dd9d0, tls: 0x7ffb730dd700) = 11640 (Chrome_IOThread)
    4.350 ( 0.065 ms): Chrome_IOThrea/19863 clone(flags: VM|FS|FILES|SIGHAND|THREAD|SYSVSEM|SETTLS|PARENT_SETTID|CHILD_CLEARTID, child_stack: 0x7ffb720d9c70, parent_tidptr: 0x7ffb720da9d0, child_tidptr: 0x7ffb720da9d0, tls: 0x7ffb720da700) = 11642 (Chrome_IOThread)
    5.642 ( 0.079 ms): Chrome_IOThrea/19863 clone(flags: VM|FS|FILES|SIGHAND|THREAD|SYSVSEM|SETTLS|PARENT_SETTID|CHILD_CLEARTID, child_stack: 0x7ffb718d8c70, parent_tidptr: 0x7ffb718d99d0, child_tidptr: 0x7ffb718d99d0, tls: 0x7ffb718d9700) = 11643 (Chrome_IOThread)
    ^C#

    We'll also have to fix the argument ordering in different arches,
    probably having multiple syscall_fmt entries with each possible order
    and then use perf_evsel__env_arch() (if dealing with a perf.data file)
    or the current system info, for live sessions.

    Cc: Adrian Hunter
    Cc: David Ahern
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Cc: Wang Nan
    Link: http://lkml.kernel.org/n/tip-am068uyubgj83snepolwhbfe@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Arnaldo Carvalho de Melo
     
  • Just suppress them, not used by the kernel.

    Cc: Adrian Hunter
    Cc: David Ahern
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Cc: Wang Nan
    Link: http://lkml.kernel.org/n/tip-atpt07y2x9a8ttlwja94ow3j@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Arnaldo Carvalho de Melo
     

19 Jul, 2017

22 commits


21 Apr, 2017

1 commit


01 Apr, 2017

1 commit

  • To test it, build samples/statx/test_statx, which I did as:

    $ make headers_install
    $ cc -I ~/git/linux/usr/include samples/statx/test-statx.c -o /tmp/statx

    And then use perf trace on it:

    # perf trace -e statx /tmp/statx /etc/passwd
    statx(/etc/passwd) = 0
    results=7ff
    Size: 3496 Blocks: 8 IO Block: 4096 regular file
    Device: fd:00 Inode: 280156 Links: 1
    Access: (0644/-rw-r--r--) Uid: 0 Gid: 0
    Access: 2017-03-29 16:01:01.650073438-0300
    Modify: 2017-03-10 16:25:14.156479354-0300
    Change: 2017-03-10 16:25:14.171479328-0300
    0.000 ( 0.007 ms): statx/30648 statx(dfd: CWD, filename: 0x7ef503f4, flags: SYMLINK_NOFOLLOW, mask: TYPE|MODE|NLINK|UID|GID|ATIME|MTIME|CTIME|INO|SIZE|BLOCKS|BTIME, buffer: 0x7fff7ef4eb10) = 0
    #

    Using the test-stat.c options to change the mask:

    # perf trace -e statx /tmp/statx -O /etc/passwd > /dev/null
    0.000 ( 0.008 ms): statx/30745 statx(dfd: CWD, filename: 0x3a0753f4, flags: SYMLINK_NOFOLLOW, mask: BTIME, buffer: 0x7ffd3a0735c0) = 0
    #
    # perf trace -e statx /tmp/statx -A /etc/passwd > /dev/null
    0.000 ( 0.010 ms): statx/30757 statx(dfd: CWD, filename: 0xa94e63f4, flags: SYMLINK_NOFOLLOW|NO_AUTOMOUNT, mask: TYPE|MODE|NLINK|UID|GID|ATIME|MTIME|CTIME|INO|SIZE|BLOCKS|BTIME, buffer: 0x7ffea94e49d0) = 0
    #
    # trace --no-inherit -e statx /tmp/statx -F /etc/passwd > /dev/null
    0.000 ( 0.011 ms): statx(dfd: CWD, filename: 0x3b02d3f3, flags: SYMLINK_NOFOLLOW|STATX_FORCE_SYNC, mask: TYPE|MODE|NLINK|UID|GID|ATIME|MTIME|CTIME|INO|SIZE|BLOCKS|BTIME, buffer: 0x7ffd3b02c850) = 0
    #
    # trace --no-inherit -e statx /tmp/statx -F -L /etc/passwd > /dev/null
    0.000 ( 0.008 ms): statx(dfd: CWD, filename: 0x15cff3f3, flags: STATX_FORCE_SYNC, mask: TYPE|MODE|NLINK|UID|GID|ATIME|MTIME|CTIME|INO|SIZE|BLOCKS|BTIME, buffer: 0x7fff15cfdda0) = 0
    #
    # trace --no-inherit -e statx /tmp/statx -D -O /etc/passwd > /dev/null
    0.000 ( 0.009 ms): statx(dfd: CWD, filename: 0xfa37f3f3, flags: SYMLINK_NOFOLLOW|STATX_DONT_SYNC, mask: BTIME, buffer: 0x7ffffa37da20) = 0
    #

    Adding a probe to get the filename collected as well:

    # perf probe 'vfs_getname=getname_flags:72 pathname=result->name:string'
    Added new event:
    probe:vfs_getname (on getname_flags:72 with pathname=result->name:string)

    You can now use it in all perf tools, such as:

    perf record -e probe:vfs_getname -aR sleep 1

    # trace --no-inherit -e statx /tmp/statx -D -O /etc/passwd > /dev/null
    0.169 ( 0.007 ms): statx(dfd: CWD, filename: /etc/passwd, flags: SYMLINK_NOFOLLOW|STATX_DONT_SYNC, mask: BTIME, buffer: 0x7ffda9bf50f0) = 0
    #

    Same technique could be used to collect and beautify the result put in
    the 'buffer' argument.

    Finally do a system wide 'perf trace' session looking for any use of statx,
    then run the test proggie with various flags:

    # trace -e statx
    16612.967 ( 0.028 ms): statx/4562 statx(dfd: CWD, filename: /tmp/statx, flags: SYMLINK_NOFOLLOW, mask: TYPE|MODE|NLINK|UID|GID|ATIME|MTIME|CTIME|INO|SIZE|BLOCKS|BTIME, buffer: 0x7ffef195d660) = 0
    33064.447 ( 0.011 ms): statx/4569 statx(dfd: CWD, filename: /tmp/statx, flags: SYMLINK_NOFOLLOW|STATX_FORCE_SYNC, mask: TYPE|MODE|NLINK|UID|GID|ATIME|MTIME|CTIME|INO|SIZE|BLOCKS|BTIME, buffer: 0x7ffc5484c790) = 0
    36050.891 ( 0.023 ms): statx/4576 statx(dfd: CWD, filename: /tmp/statx, flags: SYMLINK_NOFOLLOW, mask: BTIME, buffer: 0x7ffeb18b66e0) = 0
    38039.889 ( 0.023 ms): statx/4584 statx(dfd: CWD, filename: /tmp/statx, flags: SYMLINK_NOFOLLOW, mask: TYPE|MODE|NLINK|UID|GID|ATIME|MTIME|CTIME|INO|SIZE|BLOCKS|BTIME, buffer: 0x7fff1db0ea90) = 0
    ^C#

    This one also starts moving the beautifiers from files directly included
    in builtin-trace.c to separate objects + a beauty.h header with
    prototypes, so that we can add test cases in tools/perf/tests/ to fire
    syscalls with various arguments and then get them intercepted as
    syscalls:sys_enter_foo or raw_syscalls:sys_enter + sys_exit to then
    format and check that the formatted output is the one we expect.

    Cc: Adrian Hunter
    Cc: Al Viro
    Cc: David Ahern
    Cc: David Howells
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Cc: Wang Nan
    Link: http://lkml.kernel.org/n/tip-xvzw8eynffvez5czyzidhrno@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Arnaldo Carvalho de Melo
     

20 Dec, 2016

1 commit

  • There might be systems where MAP_32BIT is not defined, like some some
    RHEL7 powerpc versions.

    Signed-off-by: Jiri Olsa
    Cc: David Ahern
    Cc: Kyle McMartin
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Fixes: 256763b01741 ("perf trace beauty mmap: Add more conditional defines")
    Link: http://lkml.kernel.org/r/1481831814-23683-1-git-send-email-jolsa@kernel.org
    [ Changed the Fixme cset to the one removing the conditional switch case for MAP_32BIT ]
    Signed-off-by: Arnaldo Carvalho de Melo

    Jiri Olsa
     

19 Sep, 2016

1 commit

  • tools/perf/trace/beauty/mmap.c forgets to check MADV_FREE.
    This patch fixes it.

    Signed-off-by: Wang Nan
    Cc: Naveen N. Rao
    Cc: Zefan Li
    Cc: pi3orama@163.com
    Link: http://lkml.kernel.org/r/1473850649-83389-2-git-send-email-wangnan0@huawei.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Wang Nan
     

14 Sep, 2016

1 commit

  • Several defines have different values in different arches, so we can't
    just define it to the x86_64 value, use uapi/linux/mmap.h that was
    recently introduced to reliably find those, not using possibly outdated
    libc headers.

    Cc: Adrian Hunter
    Cc: David Ahern
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Cc: Wang Nan
    Cc: Zefan Li
    Link: http://lkml.kernel.org/n/tip-4eajp5yp8i2fuw44n7jmcg5t@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Arnaldo Carvalho de Melo
     

13 Jul, 2016

1 commit