1. 25 Sep, 2019 16 commits
  2. 23 Sep, 2019 2 commits
    • Arnaldo Carvalho de Melo's avatar
      perf record: Move restricted maps check to after a possible fallback to not collect kernel samples · c8b567c8
      Arnaldo Carvalho de Melo authored
      Before:
      
        [acme@quaco ~]$ perf record -b -e cycles date
        WARNING: Kernel address maps (/proc/{kallsyms,modules}) are restricted,
        check /proc/sys/kernel/kptr_restrict and /proc/sys/kernel/perf_event_paranoid.
      
        Samples in kernel functions may not be resolved if a suitable vmlinux
        file is not found in the buildid cache or in the vmlinux path.
      
        Samples in kernel modules won't be resolved at all.
      
        If some relocation was applied (e.g. kexec) symbols may be misresolved
        even with a suitable vmlinux or kallsyms file.
      
        Mon 23 Sep 2019 11:00:59 AM -03
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.005 MB perf.data (14 samples) ]
        [acme@quaco ~]$
      
      But we did a fallback and exclude_kernel was set, so no need for
      resolving kernel symbols:
      
        $ perf evlist -v
        cycles:u: size: 112, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|PERIOD|BRANCH_STACK, read_format: ID, disabled: 1, inherit: 1, exclude_kernel: 1, exclude_hv: 1, mmap: 1, comm: 1, freq: 1, enable_on_exec: 1, task: 1, sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1, ksymbol: 1, bpf_event: 1, branch_sample_type: ANY
        $
      
      After:
      
        [acme@quaco ~]$ perf record -b -e cycles date
        Mon 23 Sep 2019 11:07:18 AM -03
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.007 MB perf.data (16 samples) ]
        [acme@quaco ~]$ perf evlist -v
        cycles:u: size: 112, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|PERIOD|BRANCH_STACK, read_format: ID, disabled: 1, inherit: 1, exclude_kernel: 1, exclude_hv: 1, mmap: 1, comm: 1, freq: 1, enable_on_exec: 1, task: 1, sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1, ksymbol: 1, bpf_event: 1, branch_sample_type: ANY
        [acme@quaco ~]$
      
      No needless warning is emitted.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: https://lkml.kernel.org/n/tip-5yqnr8xcqwhr15xktj2097ac@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      c8b567c8
    • Stephane Eranian's avatar
      perf record: Fix priv level with branch sampling for paranoid=2 · 4ec8d984
      Stephane Eranian authored
      Now that the default perf_events paranoid level is set to 2, a regular
      user cannot monitor kernel level activity anymore. As such, with the
      following cmdline:
      
        $ perf record -e cycles date
      
      The perf tool first tries cycles:uk but then falls back to cycles:u as
      can be seen in the perf report --header-only output:
      
        cmdline : /export/hda3/tmp/perf.tip record -e cycles ls
        event : name = cycles:u, , id = { 436186, ... }
      
      This is okay as long as there is way to learn the priv level was changed
      internally by the tool.
      
      But consider a similar example:
      
        $ perf record -b -e cycles date
        Error:
        You may not have permission to collect stats.
      
      Consider tweaking /proc/sys/kernel/perf_event_paranoid,
      which controls use of the performance events system by
      unprivileged users (without CAP_SYS_ADMIN).
      ...
      
      Why is that treated differently given that the branch sampling inherits the
      priv level of the first event in this case, i.e., cycles:u? It turns out
      that the branch sampling code is more picky and also checks exclude_hv.
      
      In the fallback path, perf record is setting exclude_kernel = 1, but it
      does not change exclude_hv. This does not seem to match the restriction
      imposed by paranoid = 2.
      
      This patch fixes the problem by forcing exclude_hv = 1 in the fallback
      for paranoid=2. With this in place:
      
        $ perf record -b -e cycles date
          cmdline : /export/hda3/tmp/perf.tip record -b -e cycles ls
          event : name = cycles:u, , id = { 436847, ... }
      
      And the command succeeds as expected.
      
      V2 fix a white space.
      
      Committer testing:
      
      After aplying the patch we get:
      
        [acme@quaco ~]$ perf record -b -e cycles date
        WARNING: Kernel address maps (/proc/{kallsyms,modules}) are restricted,
        check /proc/sys/kernel/kptr_restrict and /proc/sys/kernel/perf_event_paranoid.
      
        Samples in kernel functions may not be resolved if a suitable vmlinux
        file is not found in the buildid cache or in the vmlinux path.
      
        Samples in kernel modules won't be resolved at all.
      
        If some relocation was applied (e.g. kexec) symbols may be misresolved
        even with a suitable vmlinux or kallsyms file.
      
        Mon 23 Sep 2019 11:00:59 AM -03
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.005 MB perf.data (14 samples) ]
        [acme@quaco ~]$ perf evlist -v
        cycles:u: size: 112, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|PERIOD|BRANCH_STACK, read_format: ID, disabled: 1, inherit: 1, exclude_kernel: 1, exclude_hv: 1, mmap: 1, comm: 1, freq: 1, enable_on_exec: 1, task: 1, sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1, ksymbol: 1, bpf_event: 1, branch_sample_type: ANY
        [acme@quaco ~]$
      
      That warning about restricted kernel maps will be suppressed in a follow
      up patch, as perf_event_attr.exclude_kernel is set, i.e. no samples for
      the kernel will be taken and thus no need for those maps.
      Signed-off-by: default avatarStephane Eranian <eranian@google.com>
      Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lore.kernel.org/lkml/20190920230356.41420-1-eranian@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      4ec8d984
  3. 22 Sep, 2019 1 commit
    • Ingo Molnar's avatar
      Merge tag 'perf-urgent-for-mingo-5.4-20190921' of... · 2b327697
      Ingo Molnar authored
      Merge tag 'perf-urgent-for-mingo-5.4-20190921' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent
      
      Pull perf/urgent fixes from Arnaldo Carvalho de Melo:
      
      perf tests:
      
        Jiri Olsa:
      
        - Fix 'make -C tools/perf build-test' static build entry.
      
      perf record:
      
        Jiri Olsa:
      
        - Fix segfault in cpu_cache_level__read() when reading CPU topology.
      
      session:
      
        Mamatha Inamdar:
      
        - Properly propagate error when reading a perf.data file, it may
          not exist or the user may not have permissions, etc.
      
      perf probe:
      
        Masami Hiramatsu:
      
        - Skip same probe address for a given line.
      
        - Clear tev->nargs in clear_probe_trace_event(), fixing segfault.
      
      tools headers UAPI:
      
        Arnaldo Carvalho de Melo:
      
        - Sync headers, among them prctl.h, that introduces two new options
          that are now supported in the 'perf trace' prctl syscall args
          beautifiers.
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      2b327697
  4. 20 Sep, 2019 21 commits
    • Roy Ben Shlomo's avatar
      perf/core: Fix several typos in comments · 9f014e3a
      Roy Ben Shlomo authored
      Fix typos in a few functions' documentation comments.
      Signed-off-by: default avatarRoy Ben Shlomo <royb@sentinelone.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: Peter Zijlstra <peterz@infradead.org>
      Cc: royb@sentinelone.com
      Link: http://lore.kernel.org/lkml/20190920171254.31373-1-royb@sentinelone.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      9f014e3a
    • Mamatha Inamdar's avatar
      perf session: Return error code for perf_session__new() function on failure · 6ef81c55
      Mamatha Inamdar authored
      This patch is to return error code of perf_new_session function on
      failure instead of NULL.
      
      Test Results:
      
      Before Fix:
      
        $ perf c2c report -input
        failed to open nput: No such file or directory
      
        $ echo $?
        0
        $
      
      After Fix:
      
        $ perf c2c report -input
        failed to open nput: No such file or directory
      
        $ echo $?
        254
        $
      
      Committer notes:
      
      Fix 'perf tests topology' case, where we use that TEST_ASSERT_VAL(...,
      session), i.e. we need to pass zero in case of failure, which was the
      case before when NULL was returned by perf_session__new() for failure,
      but now we need to negate the result of IS_ERR(session) to respect that
      TEST_ASSERT_VAL) expectation of zero meaning failure.
      Reported-by: default avatarNageswara R Sastry <rnsastry@linux.vnet.ibm.com>
      Signed-off-by: default avatarMamatha Inamdar <mamatha4@linux.vnet.ibm.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Tested-by: default avatarNageswara R Sastry <rnsastry@linux.vnet.ibm.com>
      Acked-by: default avatarRavi Bangoria <ravi.bangoria@linux.ibm.com>
      Reviewed-by: default avatarJiri Olsa <jolsa@redhat.com>
      Reviewed-by: default avatarMukesh Ojha <mojha@codeaurora.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Jeremie Galarneau <jeremie.galarneau@efficios.com>
      Cc: Kate Stewart <kstewart@linuxfoundation.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Shawn Landden <shawn@git.icu>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Tzvetomir Stoyanov <tstoyanov@vmware.com>
      Link: http://lore.kernel.org/lkml/20190822071223.17892.45782.stgit@localhost.localdomainSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      6ef81c55
    • Masami Hiramatsu's avatar
      perf probe: Fix to clear tev->nargs in clear_probe_trace_event() · 9e6124d9
      Masami Hiramatsu authored
      Since add_probe_trace_event() can reuse tf->tevs[i] after calling
      clear_probe_trace_event(), this can make perf-probe crash if the 1st
      attempt of probe event finding fails to find an event argument, and the
      2nd attempt fails to find probe point.
      
      E.g.
        $ perf probe -D "task_pid_nr tsk"
        Failed to find 'tsk' in this function.
        Failed to get entry address of warn_bad_vsyscall
        Segmentation fault (core dumped)
      
      Committer testing:
      
      After the patch:
      
        $ perf probe -D "task_pid_nr tsk"
        Failed to find 'tsk' in this function.
        Failed to get entry address of warn_bad_vsyscall
        Failed to get entry address of signal_fault
        Failed to get entry address of show_signal
        Failed to get entry address of umip_printk
        Failed to get entry address of __bad_area_nosemaphore
        <SNIP>
        Failed to get entry address of sock_set_timeout
        Failed to get entry address of tcp_recvmsg
        Probe point 'task_pid_nr' not found.
          Error: Failed to add events.
        $
      
      Fixes: 092b1f0b ("perf probe: Clear probe_trace_event when add_probe_trace_event() fails")
      Signed-off-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lore.kernel.org/lkml/156856587999.25775.5145779959474477595.stgit@devnote2Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      9e6124d9
    • Masami Hiramatsu's avatar
      perf probe: Skip same probe address for a given line · 1a375ae7
      Masami Hiramatsu authored
      Fix to skip making a same probe address on given line.
      
      Since a DWARF line info contains several entries for one line with
      different column, perf probe will make a different probe on same address
      if user specifies a probe point by "function:line" or "file:line".
      
      e.g.
       $ perf probe -D kernel_read:8
       p:probe/kernel_read_L8 kernel_read+39
       p:probe/kernel_read_L8_1 kernel_read+39
      
      This skips such duplicated probe addresses.
      
      Committer testing:
      
        # uname -a
        Linux quaco 5.3.0+ #2 SMP Thu Sep 19 16:13:22 -03 2019 x86_64 x86_64 x86_64 GNU/Linux
        #
      
      Before:
      
        # perf probe -D kernel_read:8
        p:probe/kernel_read _text+3115191
        p:probe/kernel_read_1 _text+3115191
        #
      
      After:
      
        # perf probe -D kernel_read:8
        p:probe/kernel_read _text+3115191
        #
      Signed-off-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lore.kernel.org/lkml/156886447061.10772.4261569305869149178.stgit@devnote2Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      1a375ae7
    • Jiri Olsa's avatar
      perf tools: Fix segfault in cpu_cache_level__read() · 0216234c
      Jiri Olsa authored
      We release wrong pointer on error path in cpu_cache_level__read
      function, leading to segfault:
      
        (gdb) r record ls
        Starting program: /root/perf/tools/perf/perf record ls
        ...
        [ perf record: Woken up 1 times to write data ]
        double free or corruption (out)
      
        Thread 1 "perf" received signal SIGABRT, Aborted.
        0x00007ffff7463798 in raise () from /lib64/power9/libc.so.6
        (gdb) bt
        #0  0x00007ffff7463798 in raise () from /lib64/power9/libc.so.6
        #1  0x00007ffff7443bac in abort () from /lib64/power9/libc.so.6
        #2  0x00007ffff74af8bc in __libc_message () from /lib64/power9/libc.so.6
        #3  0x00007ffff74b92b8 in malloc_printerr () from /lib64/power9/libc.so.6
        #4  0x00007ffff74bb874 in _int_free () from /lib64/power9/libc.so.6
        #5  0x0000000010271260 in __zfree (ptr=0x7fffffffa0b0) at ../../lib/zalloc..
        #6  0x0000000010139340 in cpu_cache_level__read (cache=0x7fffffffa090, cac..
        #7  0x0000000010143c90 in build_caches (cntp=0x7fffffffa118, size=<optimiz..
        ...
      
      Releasing the proper pointer.
      
      Fixes: 720e98b5 ("perf tools: Add perf data cache feature")
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: stable@vger.kernel.org: # v4.6+
      Link: http://lore.kernel.org/lkml/20190912105235.10689-1-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      0216234c
    • Arnaldo Carvalho de Melo's avatar
      tools arch x86: Sync asm/cpufeatures.h with the kernel sources · 40f1c039
      Arnaldo Carvalho de Melo authored
      To pick up the changes from:
      
        b4dd4f6e ("x86/vmware: Add a header file for hypercall definitions")
        f36cf386 ("x86/speculation/swapgs: Exclude ATOMs from speculation through SWAPGS")
        be261ffc ("x86: Remove X86_FEATURE_MFENCE_RDTSC")
        018ebca8 ("x86/cpufeatures: Enable a new AVX512 CPU feature")
      
      These don't cause any changes in tooling, just silences this perf build
      warning:
      
        Warning: Kernel ABI header at 'tools/arch/x86/include/asm/cpufeatures.h' differs from latest version at 'arch/x86/include/asm/cpufeatures.h'
        diff -u tools/arch/x86/include/asm/cpufeatures.h arch/x86/include/asm/cpufeatures.h
      
      To clarify, updating those files cause these bits of tools/perf to rebuild:
      
        CC       /tmp/build/perf/bench/mem-memcpy-x86-64-asm.o
        CC       /tmp/build/perf/bench/mem-memset-x86-64-asm.o
        INSTALL  GTK UI
        LD       /tmp/build/perf/bench/perf-in.o
      
      Those use just:
      
        $ grep FEATURE tools/arch/x86/lib/mem*.S
        tools/arch/x86/lib/memcpy_64.S:	ALTERNATIVE_2 "jmp memcpy_orig", "", X86_FEATURE_REP_GOOD, \
        tools/arch/x86/lib/memcpy_64.S:		      "jmp memcpy_erms", X86_FEATURE_ERMS
        tools/arch/x86/lib/memset_64.S:	ALTERNATIVE_2 "jmp memset_orig", "", X86_FEATURE_REP_GOOD, \
        tools/arch/x86/lib/memset_64.S:		      "jmp memset_erms", X86_FEATURE_ERMS
        $
      
      I.e. none of the feature defines added/removed by the patches above.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: Gayatri Kammela <gayatri.kammela@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Thomas Hellstrom <thellstrom@vmware.com>
      Link: https://lkml.kernel.org/n/tip-pq63abgknsaeov23p80d8gjv@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      40f1c039
    • Arnaldo Carvalho de Melo's avatar
      tools arch x86 uapi: Synch asm/unistd.h with the kernel sources · 761830a0
      Arnaldo Carvalho de Melo authored
      To pick up the change in:
      
        45e29d11 ("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: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      761830a0
    • Arnaldo Carvalho de Melo's avatar
      tools uapi asm-generic: Sync unistd.h with the kernel sources · 9846f136
      Arnaldo Carvalho de Melo authored
      To pick the change from:
      
        78e05972 ("ipc: fix semtimedop for generic 32-bit architectures")
      
      Which doesn't trigger any change in tooling and silences this perf build
      warning:
      
        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
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-hpnjuyjzoudltqe7dvbokqdt@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      9846f136
    • Arnaldo Carvalho de Melo's avatar
      tools headers uapi: Sync prctl.h with the kernel sources · 7b678ccd
      Arnaldo Carvalho de Melo authored
      To get the changes in:
      
        63f0c603 ("arm64: Introduce prctl() options to control the tagged user addresses ABI")
      
      that introduces prctl options that then automagically gets catched by
      the prctl cmd table generator, and thus supported in the 'perf trace'
      prctl beautifier for the 'option' argument:
      
        $ tools/perf/trace/beauty/prctl_option.sh  > after
        $ diff -u before after
        --- before	2019-09-20 14:38:41.386720870 -0300
        +++ after	2019-09-20 14:40:02.583990802 -0300
        @@ -49,6 +49,8 @@
         	[52] = "GET_SPECULATION_CTRL",
         	[53] = "SET_SPECULATION_CTRL",
         	[54] = "PAC_RESET_KEYS",
        +	[55] = "SET_TAGGED_ADDR_CTRL",
        +	[56] = "GET_TAGGED_ADDR_CTRL",
         };
         static const char *prctl_set_mm_options[] = {
         	[1] = "START_CODE",
        $
      
      For now just the translation of 55 and 56 to the respecting strings are
      done, more work needed to allow for filters to be used using strings.
      
      This, for instance, already works:
      
        # perf record -e syscalls:sys_enter_close --filter="fd==4"
        # perf script | head -5
                     gpm  1018 [006] 21327.171436: syscalls:sys_enter_close: fd: 0x00000004
                     gpm  1018 [006] 21329.171583: syscalls:sys_enter_close: fd: 0x00000004
                    bash  4882 [002] 21330.785496: syscalls:sys_enter_close: fd: 0x00000004
                    bash 20672 [001] 21330.785719: syscalls:sys_enter_close: fd: 0x00000004
                    find 20672 [001] 21330.789082: syscalls:sys_enter_close: fd: 0x00000004
        # perf record -e syscalls:sys_enter_close --filter="fd>=4"
        ^C[ perf record: Woken up 1 times to write data ]
        # perf script | head -5
                     gpm  1018 [005] 21401.178501: syscalls:sys_enter_close: fd: 0x00000004
         gsd-housekeepin  2287 [006] 21402.225365: syscalls:sys_enter_close: fd: 0x0000000b
         gsd-housekeepin  2287 [006] 21402.226234: syscalls:sys_enter_close: fd: 0x0000000b
         gsd-housekeepin  2287 [006] 21402.227255: syscalls:sys_enter_close: fd: 0x0000000b
         gsd-housekeepin  2287 [006] 21402.228088: syscalls:sys_enter_close: fd: 0x0000000b
        #
      
      Being able to pass something like:
      
        # perf record -e syscalls:sys_enter_prctl --filter="option=*TAGGED_ADDR*"
      
      Should be easy enough, first using tracepoint filters, then via the
      augmented_raw_syscalls.c BPF method.
      
      This addresses this perf build warning:
      
        Warning: Kernel ABI header at 'tools/include/uapi/linux/prctl.h' differs from latest version at 'include/uapi/linux/prctl.h'
        diff -u tools/include/uapi/linux/prctl.h include/uapi/linux/prctl.h
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Will Deacon <will@kernel.org>
      Link: https://lkml.kernel.org/n/tip-y8u8kvflooyo9x0if1g3jska@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      7b678ccd
    • Jiri Olsa's avatar
      perf tests: Fix static build test · b117b9b4
      Jiri Olsa authored
      Disable the potentional shared library features, which breaks static
      build if they are enabled and detected: jvmti and vdso libraries.
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lore.kernel.org/lkml/20190905090924.GA1949@kravaSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      b117b9b4
    • Ingo Molnar's avatar
      Merge tag 'perf-core-for-mingo-5.4-20190920-2' of... · 351a1f5c
      Ingo Molnar authored
      Merge tag 'perf-core-for-mingo-5.4-20190920-2' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent
      
      Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo:
      
      perf stat:
      
        Srikar Dronamraju:
      
        - Fix a segmentation fault when using repeat forever.
      
        - Reset previous counts on repeat with interval.
      
      aarch64:
      
        James Clark:
      
        - Add PMU event JSON files for Cortex-A76 and Neoverse N1.
      
      PowerPC:
      
        Anju T Sudhakar:
      
        - Make 'trace_cycles' the default event for 'perf kvm record' in PowerPC.
      
      S/390:
      
        - Link libjvmti to tools/lib/string.o to have a weak strlcpy()
          implementation, providing previously unresolved symbol on s/390.
      
      perf test:
      
        Jiri Olsa:
      
        - Add libperf automated tests to 'make -C tools/perf build-test'.
      
        Colin Ian King:
      
        - Fix spelling mistake.
      
      Tree wide:
      
        Arnaldo Carvalho de Melo:
      
        - Some more header file sanitization.
      
      libperf:
      
        Jiri Olsa:
      
        - Add dependency on libperf for python.so binding.
      
      libtraceevent:
      
        Sakari Ailus:
      
        - Convert remaining %p[fF] users to %p[sS].
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      351a1f5c
    • Anju T Sudhakar's avatar
      perf kvm stat: Set 'trace_cycles' as default event for 'perf kvm record' in powerpc · 2bff2b82
      Anju T Sudhakar authored
      Use 'trace_imc/trace_cycles' as the default event for 'perf kvm record'
      in powerpc.
      Signed-off-by: default avatarAnju T Sudhakar <anju@linux.vnet.ibm.com>
      Reviewed-by: default avatarRavi Bangoria <ravi.bangoria@linux.ibm.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: linuxppc-dev@lists.ozlabs.org
      Link: http://lore.kernel.org/lkml/20190718181749.30612-3-anju@linux.vnet.ibm.com
      [ Add missing pmu.h header, needed because this patch uses pmu_have_event() ]
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      2bff2b82
    • Anju T Sudhakar's avatar
      perf kvm: Add arch neutral function to choose event for perf kvm record · 124eb5f8
      Anju T Sudhakar authored
      'perf kvm record' uses 'cycles'(if the user did not specify any event)
      as the default event to profile the guest.
      
      This will not provide any proper samples from the guest incase of
      powerpc architecture, since in powerpc the PMUs are controlled by the
      guest rather than the host.
      
      Patch adds a function to pick an arch specific event for 'perf kvm
      record', instead of selecting 'cycles' as a default event for all
      architectures.
      
      For powerpc this function checks for any user specified event, and if
      there isn't any it returns invalid instead of proceeding with 'cycles'
      event.
      Signed-off-by: default avatarAnju T Sudhakar <anju@linux.vnet.ibm.com>
      Reviewed-by: default avatarRavi Bangoria <ravi.bangoria@linux.ibm.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: linuxppc-dev@lists.ozlabs.org
      Link: http://lore.kernel.org/lkml/20190718181749.30612-2-anju@linux.vnet.ibm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      124eb5f8
    • Anju T Sudhakar's avatar
      perf kvm: Move kvm-stat header file from conditional inclusion to common include section · 8067b3da
      Anju T Sudhakar authored
      Move kvm-stat header file to the common include section, and make the
      definitions in the header file under the conditional inclusion `#ifdef
      HAVE_KVM_STAT_SUPPORT`.
      
      This helps to define other 'perf kvm' related function prototypes in
      kvm-stat header file, which may not need kvm-stat support.
      Signed-off-by: default avatarAnju T Sudhakar <anju@linux.vnet.ibm.com>
      Reviewed-By: default avatarRavi Bangoria <ravi.bangoria@linux.ibm.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: linuxppc-dev@lists.ozlabs.org
      Link: http://lore.kernel.org/lkml/20190718181749.30612-1-anju@linux.vnet.ibm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      8067b3da
    • Colin Ian King's avatar
      perf test: Fix spelling mistake "allos" -> "allocate" · ce095c9a
      Colin Ian King authored
      There is a spelling mistake in a TEST_ASSERT_VAL message. Fix it.
      Signed-off-by: default avatarColin King <colin.king@canonical.com>
      Reviewed-by: default avatarMukesh Ojha <mojha@codeaurora.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: kernel-janitors@vger.kernel.org
      Link: http://lore.kernel.org/lkml/20190911152148.17031-1-colin.king@canonical.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      ce095c9a
    • Srikar Dronamraju's avatar
      perf stat: Fix a segmentation fault when using repeat forever · 443f2d5b
      Srikar Dronamraju authored
      Observe a segmentation fault when 'perf stat' is asked to repeat forever
      with the interval option.
      
      Without fix:
      
        # perf stat -r 0 -I 5000 -e cycles -a sleep 10
        #           time             counts unit events
             5.000211692  3,13,89,82,34,157      cycles
            10.000380119  1,53,98,52,22,294      cycles
            10.040467280       17,16,79,265      cycles
        Segmentation fault
      
      This problem was only observed when we use forever option aka -r 0 and
      works with limited repeats. Calling print_counter with ts being set to
      NULL, is not a correct option when interval is set. Hence avoid
      print_counter(NULL,..)  if interval is set.
      
      With fix:
      
        # perf stat -r 0 -I 5000 -e cycles -a sleep 10
         #           time             counts unit events
             5.019866622  3,15,14,43,08,697      cycles
            10.039865756  3,15,16,31,95,261      cycles
            10.059950628     1,26,05,47,158      cycles
             5.009902655  3,14,52,62,33,932      cycles
            10.019880228  3,14,52,22,89,154      cycles
            10.030543876       66,90,18,333      cycles
             5.009848281  3,14,51,98,25,437      cycles
            10.029854402  3,15,14,93,04,918      cycles
             5.009834177  3,14,51,95,92,316      cycles
      
      Committer notes:
      
      Did the 'git bisect' to find the cset introducing the problem to add the
      Fixes tag below, and at that time the problem reproduced as:
      
        (gdb) run stat -r0 -I500 sleep 1
        <SNIP>
        Program received signal SIGSEGV, Segmentation fault.
        print_interval (prefix=prefix@entry=0x7fffffffc8d0 "", ts=ts@entry=0x0) at builtin-stat.c:866
        866		sprintf(prefix, "%6lu.%09lu%s", ts->tv_sec, ts->tv_nsec, csv_sep);
        (gdb) bt
        #0  print_interval (prefix=prefix@entry=0x7fffffffc8d0 "", ts=ts@entry=0x0) at builtin-stat.c:866
        #1  0x000000000041860a in print_counters (ts=ts@entry=0x0, argc=argc@entry=2, argv=argv@entry=0x7fffffffd640) at builtin-stat.c:938
        #2  0x0000000000419a7f in cmd_stat (argc=2, argv=0x7fffffffd640, prefix=<optimized out>) at builtin-stat.c:1411
        #3  0x000000000045c65a in run_builtin (p=p@entry=0x6291b8 <commands+216>, argc=argc@entry=5, argv=argv@entry=0x7fffffffd640) at perf.c:370
        #4  0x000000000045c893 in handle_internal_command (argc=5, argv=0x7fffffffd640) at perf.c:429
        #5  0x000000000045c8f1 in run_argv (argcp=argcp@entry=0x7fffffffd4ac, argv=argv@entry=0x7fffffffd4a0) at perf.c:473
        #6  0x000000000045cac9 in main (argc=<optimized out>, argv=<optimized out>) at perf.c:588
        (gdb)
      
      Mostly the same as just before this patch:
      
        Program received signal SIGSEGV, Segmentation fault.
        0x00000000005874a7 in print_interval (config=0xa1f2a0 <stat_config>, evlist=0xbc9b90, prefix=0x7fffffffd1c0 "`", ts=0x0) at util/stat-display.c:964
        964		sprintf(prefix, "%6lu.%09lu%s", ts->tv_sec, ts->tv_nsec, config->csv_sep);
        (gdb) bt
        #0  0x00000000005874a7 in print_interval (config=0xa1f2a0 <stat_config>, evlist=0xbc9b90, prefix=0x7fffffffd1c0 "`", ts=0x0) at util/stat-display.c:964
        #1  0x0000000000588047 in perf_evlist__print_counters (evlist=0xbc9b90, config=0xa1f2a0 <stat_config>, _target=0xa1f0c0 <target>, ts=0x0, argc=2, argv=0x7fffffffd670)
            at util/stat-display.c:1172
        #2  0x000000000045390f in print_counters (ts=0x0, argc=2, argv=0x7fffffffd670) at builtin-stat.c:656
        #3  0x0000000000456bb5 in cmd_stat (argc=2, argv=0x7fffffffd670) at builtin-stat.c:1960
        #4  0x00000000004dd2e0 in run_builtin (p=0xa30e00 <commands+288>, argc=5, argv=0x7fffffffd670) at perf.c:310
        #5  0x00000000004dd54d in handle_internal_command (argc=5, argv=0x7fffffffd670) at perf.c:362
        #6  0x00000000004dd694 in run_argv (argcp=0x7fffffffd4cc, argv=0x7fffffffd4c0) at perf.c:406
        #7  0x00000000004dda11 in main (argc=5, argv=0x7fffffffd670) at perf.c:531
        (gdb)
      
      Fixes: d4f63a47 ("perf stat: Introduce print_counters function")
      Signed-off-by: default avatarSrikar Dronamraju <srikar@linux.vnet.ibm.com>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Tested-by: default avatarRavi Bangoria <ravi.bangoria@linux.ibm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
      Cc: stable@vger.kernel.org # v4.2+
      Link: http://lore.kernel.org/lkml/20190904094738.9558-3-srikar@linux.vnet.ibm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      443f2d5b
    • Srikar Dronamraju's avatar
      perf stat: Reset previous counts on repeat with interval · b63fd11c
      Srikar Dronamraju authored
      When using 'perf stat' with repeat and interval option, it shows wrong
      values for events.
      
      The wrong values will be shown for the first interval on the second and
      subsequent repetitions.
      
      Without the fix:
      
        # perf stat -r 3 -I 2000 -e faults -e sched:sched_switch -a sleep 5
      
           2.000282489                 53      faults
           2.000282489                513      sched:sched_switch
           4.005478208              3,721      faults
           4.005478208              2,666      sched:sched_switch
           5.025470933                395      faults
           5.025470933              1,307      sched:sched_switch
           2.009602825 1,84,46,74,40,73,70,95,47,520      faults 		<------
           2.009602825 1,84,46,74,40,73,70,95,49,568      sched:sched_switch  <------
           4.019612206              4,730      faults
           4.019612206              2,746      sched:sched_switch
           5.039615484              3,953      faults
           5.039615484              1,496      sched:sched_switch
           2.000274620 1,84,46,74,40,73,70,95,47,520      faults		<------
           2.000274620 1,84,46,74,40,73,70,95,47,520      sched:sched_switch	<------
           4.000480342              4,282      faults
           4.000480342              2,303      sched:sched_switch
           5.000916811              1,322      faults
           5.000916811              1,064      sched:sched_switch
        #
      
      prev_raw_counts is allocated when using intervals. This is used when
      calculating the difference in the counts of events when using interval.
      
      The current counts are stored in prev_raw_counts to calculate the
      differences in the next iteration.
      
      On the first interval of the second and subsequent repetitions,
      prev_raw_counts would be the values stored in the last interval of the
      previous repetitions, while the current counts will only be for the
      first interval of the current repetition.
      
      Hence there is a possibility of events showing up as big number.
      
      Fix this by resetting prev_raw_counts whenever perf stat repeats the
      command.
      
      With the fix:
      
        # perf stat -r 3 -I 2000 -e faults -e sched:sched_switch -a sleep 5
      
           2.019349347              2,597      faults
           2.019349347              2,753      sched:sched_switch
           4.019577372              3,098      faults
           4.019577372              2,532      sched:sched_switch
           5.019415481              1,879      faults
           5.019415481              1,356      sched:sched_switch
           2.000178813              8,468      faults
           2.000178813              2,254      sched:sched_switch
           4.000404621              7,440      faults
           4.000404621              1,266      sched:sched_switch
           5.040196079              2,458      faults
           5.040196079                556      sched:sched_switch
           2.000191939              6,870      faults
           2.000191939              1,170      sched:sched_switch
           4.000414103                541      faults
           4.000414103                902      sched:sched_switch
           5.000809863                450      faults
           5.000809863                364      sched:sched_switch
        #
      
      Committer notes:
      
      This was broken since the cset introducing the --interval feature, i.e.
      --repeat + --interval wasn't tested at that point, add the Fixes tag so
      that automatic scripts can pick this up.
      
      Fixes: 13370a9b ("perf stat: Add interval printing")
      Signed-off-by: default avatarSrikar Dronamraju <srikar@linux.vnet.ibm.com>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Tested-by: default avatarRavi Bangoria <ravi.bangoria@linux.ibm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: stable@vger.kernel.org # v3.9+
      Link: http://lore.kernel.org/lkml/20190904094738.9558-2-srikar@linux.vnet.ibm.com
      [ Fixed up conflicts with libperf, i.e. some perf_{evsel,evlist} lost the 'perf' prefix ]
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      b63fd11c
    • Sakari Ailus's avatar
      tools lib traceevent: Convert remaining %p[fF] users to %p[sS] · b295c3e3
      Sakari Ailus authored
      There are no in-kernel %p[fF] users left. Convert the traceevent tool,
      too, to align with the kernel.
      Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: devicetree@vger.kernel.org
      Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Joe Perches <joe@perches.com>
      Cc: linux-acpi@vger.kernel.org
      Cc: linux-trace-devel@vger.kernel.org
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: Rafael J. Wysocki <rafael@kernel.org>
      Cc: Rob Herring <robh@kernel.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Cc: Tzvetomir Stoyanov <tstoyanov@vmware.com>
      Link: http://lore.kernel.org/lkml/20190918133419.7969-2-sakari.ailus@linux.intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      b295c3e3
    • Arnaldo Carvalho de Melo's avatar
      perf tools: Move event synthesizing routines to separate .c file · 055c67ed
      Arnaldo Carvalho de Melo authored
      For better grouping, in time we may end up making most of these static,
      i.e. generalizing the 'perf record' synthesizing code so that based on
      the target it can do the right thing and call the needed synthesizers.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-s9zxxhk40s95pjng9panet16@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      055c67ed
    • Arnaldo Carvalho de Melo's avatar
      perf memswap: Adopt 'struct u64_swap' from evsel.h · 5cac8ea3
      Arnaldo Carvalho de Melo authored
      As it is not used in evsel.h and is a memory swap struct, so fits better
      in memswap.h.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-wvzxu7a5l3m868ywwphrnnqo@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      5cac8ea3
    • Arnaldo Carvalho de Melo's avatar
      perf tools: Move event synthesizing routines to separate header · ea49e01c
      Arnaldo Carvalho de Melo authored
      Those are the only routines using the perf_event__handler_t typedef and
      are all related, so move to a separate header to reduce the header
      dependency tree, lots of places were getting event.h and even stdio.h,
      limits.h indirectly, so fix those as well.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-yvx9u1mf7baq6cu1abfhbqgs@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      ea49e01c