1. 09 Jun, 2020 13 commits
    • Ian Rogers's avatar
      perf parse-events: Fix an old style declaration · ffaecd7d
      Ian Rogers authored
      Fixes: a26e4716 (perf tools: Move ALLOC_LIST into a function)
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20200609053610.206588-2-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      ffaecd7d
    • Ian Rogers's avatar
      perf parse-events: Fix an incompatible pointer · c2412fae
      Ian Rogers authored
      Arrays are pointer types and don't need their address taking.
      
      Fixes: 8255718f (perf pmu: Expand PMU events by prefix match)
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20200609053610.206588-1-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      c2412fae
    • Sumanth Korikkar's avatar
      perf bpf: Fix bpf prologue generation · d38c692f
      Sumanth Korikkar authored
      Issue:
      
      bpf_probe_read() is no longer available for architecture which has
      overlapping address space. Hence bpf prologue generation fails
      
      Fix:
      
      Use bpf_probe_read_kernel for kernel member access. For user attribute
      access in kprobes, use bpf_probe_read_user.
      
      Other:
      
      @user attribute was introduced in commit 1e032f7c ("perf-probe: Add
      user memory access attribute support")
      
      Test:
      
      1. ulimit -l 128 ; ./perf record -e tests/bpf_sched_setscheduler.c
      2. cat tests/bpf_sched_setscheduler.c
      
      static void (*bpf_trace_printk)(const char *fmt, int fmt_size, ...) =
              (void *) 6;
      static int (*bpf_probe_read_user)(void *dst, __u32 size,
                                        const void *unsafe_ptr) = (void *) 112;
      static int (*bpf_probe_read_kernel)(void *dst, __u32 size,
              const void *unsafe_ptr) = (void *) 113;
      
      SEC("func=do_sched_setscheduler  pid policy param->sched_priority@user")
      int bpf_func__setscheduler(void *ctx, int err, pid_t pid, int policy,
                                 int param)
      {
              char fmt[] = "prio: %ld";
              bpf_trace_printk(fmt, sizeof(fmt), param);
              return 1;
      }
      
      char _license[] SEC("license") = "GPL";
      int _version SEC("version") = LINUX_VERSION_CODE;
      
      3. ./perf script
         sched 305669 [000] 1614458.838675: perf_bpf_probe:func: (2904e508)
         pid=261614 policy=2 sched_priority=1
      
      4. cat /sys/kernel/debug/tracing/trace
         <...>-309956 [006] .... 1616098.093957: 0: prio: 1
      
      Committer testing:
      
      I had to add some missing headers in the bpf_sched_setscheduler.c test
      proggie, then instead of using record+script I used 'perf trace' to
      drive everything in one go:
      
        # cat bpf_sched_setscheduler.c
        #include <linux/types.h>
        #include <bpf.h>
      
        static void (*bpf_trace_printk)(const char *fmt, int fmt_size, ...) = (void *) 6;
        static int (*bpf_probe_read_user)(void *dst, __u32 size, const void *unsafe_ptr) = (void *) 112;
        static int (*bpf_probe_read_kernel)(void *dst, __u32 size, const void *unsafe_ptr) = (void *) 113;
      
        SEC("func=do_sched_setscheduler  pid policy param->sched_priority@user")
        int bpf_func__setscheduler(void *ctx, int err, pid_t pid, int policy, int param)
        {
                char fmt[] = "prio: %ld";
                bpf_trace_printk(fmt, sizeof(fmt), param);
                return 1;
        }
      
        char _license[] SEC("license") = "GPL";
        int _version SEC("version") = LINUX_VERSION_CODE;
        #
        #
        # perf trace -e bpf_sched_setscheduler.c chrt -f 42 sleep 1
           0.000 chrt/80125 perf_bpf_probe:func(__probe_ip: -1676607808, policy: 1, sched_priority: 42)
        #
      
      And even with backtraces :-)
      
        # perf trace -e bpf_sched_setscheduler.c/max-stack=8/ chrt -f 42 sleep 1
             0.000 chrt/79805 perf_bpf_probe:func(__probe_ip: -1676607808, policy: 1, sched_priority: 42)
                                               do_sched_setscheduler ([kernel.kallsyms])
                                               __x64_sys_sched_setscheduler ([kernel.kallsyms])
                                               do_syscall_64 ([kernel.kallsyms])
                                               entry_SYSCALL_64 ([kernel.kallsyms])
                                               __GI___sched_setscheduler (/usr/lib64/libc-2.30.so)
        #
      Signed-off-by: default avatarSumanth Korikkar <sumanthk@linux.ibm.com>
      Reviewed-by: default avatarThomas Richter <tmricht@linux.ibm.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Ilya Leoshkevich <iii@linux.ibm.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: bpf@vger.kernel.org
      LPU-Reference: 20200609081019.60234-3-sumanthk@linux.ibm.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      d38c692f
    • Sumanth Korikkar's avatar
      perf probe: Fix user attribute access in kprobes · 9256c303
      Sumanth Korikkar authored
      Issue:
      
        # perf probe -a 'do_sched_setscheduler pid policy param->sched_priority@user'
      
      did not work before.
      
      Fix:
      
      Make:
      
        # perf probe -a 'do_sched_setscheduler pid policy param->sched_priority@user'
      
      output equivalent to ftrace:
      
        # echo 'p:probe/do_sched_setscheduler _text+517384 pid=%r2:s32 policy=%r3:s32 sched_priority=+u0(%r4):s32' > /sys/kernel/debug/tracing/kprobe_events
      
      Other:
      
      1. Right now, __match_glob() does not handle [u]<offset>. For now, use
        *u]<offset>.
      
      2. @user attribute was introduced in commit 1e032f7c ("perf-probe:
         Add user memory access attribute support")
      
      Test:
      1. perf probe -a 'do_sched_setscheduler  pid policy
         param->sched_priority@user'
      
      2 ./perf script
         sched 305669 [000] 1614458.838675: perf_bpf_probe:func: (2904e508)
         pid=261614 policy=2 sched_priority=1
      
      3. cat /sys/kernel/debug/tracing/trace
         <...>-309956 [006] .... 1616098.093957: 0: prio: 1
      
      Committer testing:
      
      Before:
      
        # perf probe -a 'do_sched_setscheduler pid policy param->sched_priority@user'
        param(type:sched_param) has no member sched_priority@user.
          Error: Failed to add events.
        # pahole sched_param
        struct sched_param {
        	int                        sched_priority;       /*     0     4 */
      
        	/* size: 4, cachelines: 1, members: 1 */
        	/* last cacheline: 4 bytes */
        };
        #
      
      After:
      
        # perf probe -a 'do_sched_setscheduler pid policy param->sched_priority@user'
        Added new event:
          probe:do_sched_setscheduler (on do_sched_setscheduler with pid policy sched_priority=param->sched_priority)
      
        You can now use it in all perf tools, such as:
      
        	perf record -e probe:do_sched_setscheduler -aR sleep 1
      
        # cat /sys/kernel/debug/tracing/kprobe_events
        p:probe/do_sched_setscheduler _text+1113792 pid=%di:s32 policy=%si:s32 sched_priority=+u0(%dx):s32
        #
      
      Fixes: 1e032f7c ("perf-probe: Add user memory access attribute support")
      Signed-off-by: default avatarSumanth Korikkar <sumanthk@linux.ibm.com>
      Reviewed-by: default avatarThomas Richter <tmricht@linux.ibm.com>
      Acked-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Ilya Leoshkevich <iii@linux.ibm.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Cc: bpf@vger.kernel.org
      LPU-Reference: 20200609081019.60234-2-sumanthk@linux.ibm.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      9256c303
    • Hongbo Yao's avatar
      perf stat: Fix NULL pointer dereference · c0c652fc
      Hongbo Yao authored
      If config->aggr_map is NULL and config->aggr_get_id is not NULL,
      the function print_aggr() will still calling arrg_update_shadow(),
      which can result in accessing the invalid pointer.
      
      Fixes: 088519f3 ("perf stat: Move the display functions to stat-display.c")
      Signed-off-by: default avatarHongbo Yao <yaohongbo@huawei.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wei Li <liwei391@huawei.com>
      Link: https://lore.kernel.org/lkml/20200608163625.GC3073@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      c0c652fc
    • Gaurav Singh's avatar
      perf report: Fix NULL pointer dereference in hists__fprintf_nr_sample_events() · 11b6e548
      Gaurav Singh authored
      The 'evname' variable can be NULL, as it is checked a few lines back,
      check it before using.
      
      Fixes: 9e207ddf ("perf report: Show call graph from reference events")
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lore.kernel.org/lkml/Signed-off-by: default avatarGaurav Singh <gaurav1086@gmail.com>
      11b6e548
    • Arnaldo Carvalho de Melo's avatar
      tools headers UAPI: Sync kvm.h headers with the kernel sources · dd76c302
      Arnaldo Carvalho de Melo authored
      To pick the changes in:
      
        f97f5a56 ("x86/kvm/hyper-v: Add support for synthetic debugger interface")
        850448f3 ("KVM: nVMX: Fix VMX preemption timer migration")
        2c4c4132 ("KVM: x86: Print symbolic names of VMX VM-Exit flags in traces")
        cc440cda ("KVM: nSVM: implement KVM_GET_NESTED_STATE and KVM_SET_NESTED_STATE")
        f7d31e65 ("x86/kvm/hyper-v: Explicitly align hcall param for kvm_hyperv_exit")
        72de5fa4 ("KVM: x86: announce KVM_FEATURE_ASYNC_PF_INT")
        acd05785 ("kvm: add capability for halt polling")
        3ecad8c2 ("docs: fix broken references for ReST files that moved around")
      
      That do not result in any change in tooling, as the additions are not
      being used in any table generator.
      
      This silences these perf build warning:
      
        Warning: Kernel ABI header at 'tools/include/uapi/linux/kvm.h' differs from latest version at 'include/uapi/linux/kvm.h'
        diff -u tools/include/uapi/linux/kvm.h include/uapi/linux/kvm.h
        Warning: Kernel ABI header at 'tools/arch/x86/include/uapi/asm/kvm.h' differs from latest version at 'arch/x86/include/uapi/asm/kvm.h'
        diff -u tools/arch/x86/include/uapi/asm/kvm.h arch/x86/include/uapi/asm/kvm.h
        Warning: Kernel ABI header at 'tools/arch/x86/include/uapi/asm/vmx.h' differs from latest version at 'arch/x86/include/uapi/asm/vmx.h'
        diff -u tools/arch/x86/include/uapi/asm/vmx.h arch/x86/include/uapi/asm/vmx.h
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Matlack <dmatlack@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Jon Doron <arilou@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Peter Shier <pshier@google.com>
      Cc: Sean Christopherson <sean.j.christopherson@intel.com>
      Cc: Vitaly Kuznetsov <vkuznets@redhat.com>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      dd76c302
    • Arnaldo Carvalho de Melo's avatar
      tools headers UAPI: Sync drm/i915_drm.h with the kernel sources · 377cb673
      Arnaldo Carvalho de Melo authored
      To pick the change in:
      
        4ef10fe0 ("drm/i915/perf: add new open param to configure polling of OA buffer")
        11ecbddd ("drm/i915/perf: introduce global sseu pinning")
      
      That don't result in any changes in tooling, just silences this perf
      build warning:
      
        Warning: Kernel ABI header at 'tools/include/uapi/drm/i915_drm.h' differs from latest version at 'include/uapi/drm/i915_drm.h'
        diff -u tools/include/uapi/drm/i915_drm.h include/uapi/drm/i915_drm.h
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      377cb673
    • Arnaldo Carvalho de Melo's avatar
      tools headers UAPI: Sync linux/fscrypt.h with the kernel sources · d8e1ef67
      Arnaldo Carvalho de Melo authored
      To pick the changes from:
      
        e3b1078b ("fscrypt: add support for IV_INO_LBLK_32 policies")
      
      That don't trigger any changes in tooling.
      
      This silences this perf build warning:
      
        Warning: Kernel ABI header at 'tools/include/uapi/linux/fscrypt.h' differs from latest version at 'include/uapi/linux/fscrypt.h'
        diff -u tools/include/uapi/linux/fscrypt.h include/uapi/linux/fscrypt.h
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Eric Biggers <ebiggers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      d8e1ef67
    • Arnaldo Carvalho de Melo's avatar
      perf beauty: Add support to STATX_MNT_ID in the 'statx' syscall 'mask' argument · 5d33cbfe
      Arnaldo Carvalho de Melo authored
      Introduced in:
      
        fa2fcf4f ("statx: add mount ID")
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Miklos Szeredi <mszeredi@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      5d33cbfe
    • Arnaldo Carvalho de Melo's avatar
      tools headers uapi: Sync linux/stat.h with the kernel sources · 93dc627f
      Arnaldo Carvalho de Melo authored
      To pick the changes from:
      
        80340fe3 ("statx: add mount_root")
        fa2fcf4f ("statx: add mount ID")
        581701b7 ("uapi: deprecate STATX_ALL")
        712b2698 ("fs/stat: Define DAX statx attribute")
      
      These add some constants that will have to be manually added in a
      followup cset, at some point this should move to the shell based
      automated way.
      
      This silences this perf build warning:
      
        Warning: Kernel ABI header at 'tools/include/uapi/linux/stat.h' differs from latest version at 'include/uapi/linux/stat.h'
        diff -u tools/include/uapi/linux/stat.h include/uapi/linux/stat.h
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Darrick J. Wong <darrick.wong@oracle.com>
      Cc: Ira Weiny <ira.weiny@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Miklos Szeredi <mszeredi@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      93dc627f
    • Arnaldo Carvalho de Melo's avatar
      tools arch x86 uapi: Synch asm/unistd.h with the kernel sources · 7e579f3a
      Arnaldo Carvalho de Melo authored
      To pick up the change in:
      
        700d3a5a ("x86/syscalls: Revert "x86/syscalls: Make __X32_SYSCALL_BIT be unsigned long"")
      
      That doesn't trigger any changes in tooling and silences this perf build
      warning:
      
        Warning: Kernel ABI header at 'tools/arch/x86/include/uapi/asm/unistd.h' differs from latest version at 'arch/x86/include/uapi/asm/unistd.h'
        diff -u tools/arch/x86/include/uapi/asm/unistd.h arch/x86/include/uapi/asm/unistd.h
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      7e579f3a
    • Arnaldo Carvalho de Melo's avatar
      tools headers API: Update faccessat2 affected files · 6c3c184f
      Arnaldo Carvalho de Melo authored
      Update the copies of files affected by:
      
        c8ffd8bc ("vfs: add faccessat2 syscall")
      
      To address this perf build warning:
      
        Warning: Kernel ABI header at 'tools/include/uapi/linux/fcntl.h' differs from latest version at 'include/uapi/linux/fcntl.h'
        diff -u tools/include/uapi/linux/fcntl.h include/uapi/linux/fcntl.h
        Warning: Kernel ABI header at 'tools/include/uapi/asm-generic/unistd.h' differs from latest version at 'include/uapi/asm-generic/unistd.h'
        diff -u tools/include/uapi/asm-generic/unistd.h include/uapi/asm-generic/unistd.h
        Warning: Kernel ABI header at 'tools/perf/arch/x86/entry/syscalls/syscall_64.tbl' differs from latest version at 'arch/x86/entry/syscalls/syscall_64.tbl'
        diff -u tools/perf/arch/x86/entry/syscalls/syscall_64.tbl arch/x86/entry/syscalls/syscall_64.tbl
      
      Which results in 'perf trace' gaining support for the 'faccessat2'
      syscall, now one can use:
      
        # perf trace -e faccessat2
      
      And have system wide tracing of this syscall. And this also will include
      it;
      
        # perf trace -e faccess*
      
      Together with the other variants.
      
      How it affects building/usage (on an x86_64 system):
      
        $ cp /tmp/build/perf/arch/x86/include/generated/asm/syscalls_64.c /tmp/syscalls_64.c.before
        $
        [root@five ~]# perf trace -e faccessat2
        event syntax error: 'faccessat2'
                             \___ parser error
        Run 'perf list' for a list of valid events
      
         Usage: perf trace [<options>] [<command>]
            or: perf trace [<options>] -- <command> [<options>]
            or: perf trace record [<options>] [<command>]
            or: perf trace record [<options>] -- <command> [<options>]
      
            -e, --event <event>   event/syscall selector. use 'perf list' to list available events
        [root@five ~]#
        $ cp arch/x86/entry/syscalls/syscall_64.tbl tools/perf/arch/x86/entry/syscalls/syscall_64.tbl
        $ git diff
        diff --git a/tools/perf/arch/x86/entry/syscalls/syscall_64.tbl b/tools/perf/arch/x86/entry/syscalls/syscall_64.tbl
        index 37b844f839bc..78847b32e137 100644
        --- a/tools/perf/arch/x86/entry/syscalls/syscall_64.tbl
        +++ b/tools/perf/arch/x86/entry/syscalls/syscall_64.tbl
        @@ -359,6 +359,7 @@
         435    common  clone3                  sys_clone3
         437    common  openat2                 sys_openat2
         438    common  pidfd_getfd             sys_pidfd_getfd
        +439    common  faccessat2              sys_faccessat2
      
         #
         # x32-specific system call numbers start at 512 to avoid cache impact
        $
      
        $ make -C tools/perf O=/tmp/build/perf/ install-bin
        <SNIP>
        CC       /tmp/build/perf/util/syscalltbl.o
        LD       /tmp/build/perf/util/perf-in.o
        LD       /tmp/build/perf/perf-in.o
        LINK     /tmp/build/perf/perf
        <SNIP>
        [root@five ~]# perf trace -e faccessat2
        ^C[root@five ~]#
      
      Cc: Miklos Szeredi <mszeredi@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      6c3c184f
  2. 08 Jun, 2020 27 commits