1. 19 Dec, 2020 3 commits
    • Kan Liang's avatar
      perf mem: Factor out a function to generate sort order · 2e7f5450
      Kan Liang authored
      Now, "--phys-data" is the only option which impacts the sort order.  A
      simple "if else" is enough to handle the option. But there will be more
      options added, e.g. "--data-page-size", which also impact the sort
      order. The code will become too complex to be maintained.
      
      Divide the sort order string into several small pieces.  The first piece
      is always the default sort string for LOAD/STORE.  Appends the specific
      sort string if related option is applied.
      
      No functional change.
      Signed-off-by: default avatarKan Liang <kan.liang@linux.intel.com>
      Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Will Deacon <will@kernel.org>
      Link: http://lore.kernel.org/lkml/20201216185805.9981-4-kan.liang@linux.intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      2e7f5450
    • Kan Liang's avatar
      perf sort: Add sort option for data page size · a50d03e3
      Kan Liang authored
      Add a new sort option "data_page_size" for --mem-mode sort.  With this
      option applied, perf can sort and report by sample's data page size.
      
      Here is an example:
      
      perf report --stdio --mem-mode
      --sort=comm,symbol,phys_daddr,data_page_size
      
       # To display the perf.data header info, please use
       # --header/--header-only options.
       #
       #
       # Total Lost Samples: 0
       #
       # Samples: 9K of event 'mem-loads:uP'
       # Total weight : 9028
       # Sort order   : comm,symbol,phys_daddr,data_page_size
       #
       # Overhead  Command  Symbol                        Data Physical
       # Address
       # Data Page Size
       # ........  .......  ............................
       # ......................  ......................
       #
          11.19%  dtlb     [.] touch_buffer              [.] 0x00000003fec82ea8  4K
           8.61%  dtlb     [.] GetTickCount              [.] 0x00000003c4f2c8a8  4K
           4.52%  dtlb     [.] GetTickCount              [.] 0x00000003fec82f58  4K
           4.33%  dtlb     [.] __gettimeofday            [.] 0x00000003fec82f48  4K
           4.32%  dtlb     [.] GetTickCount              [.] 0x00000003fec82f78  4K
           4.28%  dtlb     [.] GetTickCount              [.] 0x00000003fec82f50  4K
           4.23%  dtlb     [.] GetTickCount              [.] 0x00000003fec82f70  4K
           4.11%  dtlb     [.] GetTickCount              [.] 0x00000003fec82f68  4K
           4.00%  dtlb     [.] Calibrate                 [.] 0x00000003fec82f98  4K
           3.91%  dtlb     [.] Calibrate                 [.] 0x00000003fec82f90  4K
           3.43%  dtlb     [.] touch_buffer              [.] 0x00000003fec82e98  4K
           3.42%  dtlb     [.] touch_buffer              [.] 0x00000003fec82e90  4K
           0.09%  dtlb     [.] DoDependentLoads          [.] 0x000000036ea084c0  2M
           0.08%  dtlb     [.] DoDependentLoads          [.] 0x000000032b010b80  2M
      Signed-off-by: default avatarKan Liang <kan.liang@linux.intel.com>
      Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Will Deacon <will@kernel.org>
      Link: http://lore.kernel.org/lkml/20201216185805.9981-3-kan.liang@linux.intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      a50d03e3
    • Kan Liang's avatar
      perf script: Support data page size · 6b9bae63
      Kan Liang authored
      Display the data page size if it is available and asked by the user:
      
      Can be configured by the user, for example:
      
        perf script --fields comm,event,phys_addr,data_page_size
                  dtlb mem-loads:uP:        3fec82ea8 4K
                  dtlb mem-loads:uP:        3fec82e90 4K
                  dtlb mem-loads:uP:        3e23700a4 4K
                  dtlb mem-loads:uP:        3fec82f20 4K
                  dtlb mem-loads:uP:        3e23700a4 4K
                  dtlb mem-loads:uP:        3b4211bec 4K
                  dtlb mem-loads:uP:        382205dc0 2M
                  dtlb mem-loads:uP:        36fa082c0 2M
                  dtlb mem-loads:uP:        377607340 2M
                  dtlb mem-loads:uP:        330010180 2M
                  dtlb mem-loads:uP:        33200fd80 2M
                  dtlb mem-loads:uP:        31b012b80 2M
      Signed-off-by: default avatarKan Liang <kan.liang@linux.intel.com>
      Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Will Deacon <will@kernel.org>
      Link: http://lore.kernel.org/lkml/20201216185805.9981-2-kan.liang@linux.intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      6b9bae63
  2. 18 Dec, 2020 10 commits
    • Arnaldo Carvalho de Melo's avatar
      tools headers UAPI: Update asm-generic/unistd.h · b53d4872
      Arnaldo Carvalho de Melo authored
      Just a comment change, trivial.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Ian Rogers <irogers@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>
      b53d4872
    • Arnaldo Carvalho de Melo's avatar
      tools headers cpufeatures: Sync with the kernel sources · f93c789a
      Arnaldo Carvalho de Melo authored
      To pick the changes in:
      
        e7b6385b ("x86/cpufeatures: Add Intel SGX hardware bits")
      
      That causes only these 'perf bench' objects to rebuild:
      
        CC       /tmp/build/perf/bench/mem-memcpy-x86-64-asm.o
        CC       /tmp/build/perf/bench/mem-memset-x86-64-asm.o
      
      And addresses these perf build warnings:
      
        Warning: Kernel ABI header at 'tools/arch/x86/include/asm/disabled-features.h' differs from latest version at 'arch/x86/include/asm/disabled-features.h'
        diff -u tools/arch/x86/include/asm/disabled-features.h arch/x86/include/asm/disabled-features.h
        Warning: Kernel ABI header at 'tools/arch/x86/include/asm/cpufeatures.h' differs from latest version at 'arch/x86/include/asm/cpufeatures.h'
        diff -u tools/arch/x86/include/asm/cpufeatures.h arch/x86/include/asm/cpufeatures.h
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Sean Christopherson <seanjc@google.com>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      f93c789a
    • Arnaldo Carvalho de Melo's avatar
      tools headers UAPI: Sync linux/prctl.h with the kernel sources · d6dbfcee
      Arnaldo Carvalho de Melo authored
      To pick a new prctl introduced in:
      
        1446e1df ("kernel: Implement selective syscall userspace redirection")
      
      That results in:
      
        $ tools/perf/trace/beauty/prctl_option.sh > before
        $ cp include/uapi/linux/prctl.h tools/include/uapi/linux/prctl.h
        $ tools/perf/trace/beauty/prctl_option.sh > after
        $ diff -u before after
        --- before	2020-12-17 15:00:42.012537367 -0300
        +++ after	2020-12-17 15:00:49.832699463 -0300
        @@ -53,6 +53,7 @@
         	[56] = "GET_TAGGED_ADDR_CTRL",
         	[57] = "SET_IO_FLUSHER",
         	[58] = "GET_IO_FLUSHER",
        +	[59] = "SET_SYSCALL_USER_DISPATCH",
         };
         static const char *prctl_set_mm_options[] = {
         	[1] = "START_CODE",
        $
      
      Now users can do:
      
        # perf trace -e syscalls:sys_enter_prctl --filter "option==SET_SYSCALL_USER_DISPATCH"
      ^C#
        # trace -v -e syscalls:sys_enter_prctl --filter "option==SET_SYSCALL_USER_DISPATCH"
        New filter for syscalls:sys_enter_prctl: (option==0x3b) && (common_pid != 5519 && common_pid != 3404)
      ^C#
      
      And also when prctl appears in a session, its options will be
      translated to the string.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Gabriel Krisman Bertazi <krisman@collabora.com>
      Cc: Ian Rogers <irogers@google.com>
      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>
      d6dbfcee
    • Arnaldo Carvalho de Melo's avatar
      tools headers UAPI: Sync linux/fscrypt.h with the kernel sources · 4a443a51
      Arnaldo Carvalho de Melo authored
      To pick the changes from:
      
        3ceb6543 ("fscrypt: remove kernel-internal constants from UAPI header")
      
      That don't result in any changes in tooling, just addressing 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: Ian Rogers <irogers@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>
      4a443a51
    • Arnaldo Carvalho de Melo's avatar
      tools headers UAPI: Sync linux/const.h with the kernel headers · 7ddcdea5
      Arnaldo Carvalho de Melo authored
      To pick up the changes in:
      
        a85cbe61 ("uapi: move constants from <linux/kernel.h> to <linux/const.h>")
      
      That causes no changes in tooling, just addresses this perf build
      warning:
      
        Warning: Kernel ABI header at 'tools/include/uapi/linux/const.h' differs from latest version at 'include/uapi/linux/const.h'
        diff -u tools/include/uapi/linux/const.h include/uapi/linux/const.h
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Petr Vorel <petr.vorel@gmail.com>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      7ddcdea5
    • Arnaldo Carvalho de Melo's avatar
      tools arch x86: Sync the msr-index.h copy with the kernel sources · e9bde94f
      Arnaldo Carvalho de Melo authored
      To pick up the changes in:
      
        d205e0f1 ("x86/{cpufeatures,msr}: Add Intel SGX Launch Control hardware bits")
        e7b6385b ("x86/cpufeatures: Add Intel SGX hardware bits")
        43756a29 ("powercap: Add AMD Fam17h RAPL support")
        298ed2b3 ("x86/msr-index: sort AMD RAPL MSRs by address")
        68299a42 ("x86/mce: Enable additional error logging on certain Intel CPUs")
      
      That cause these changes in tooling:
      
        $ tools/perf/trace/beauty/tracepoints/x86_msr.sh > before
        $ cp arch/x86/include/asm/msr-index.h tools/arch/x86/include/asm/msr-index.h
        $ tools/perf/trace/beauty/tracepoints/x86_msr.sh > after
        $ diff -u before after
        --- before	2020-12-17 14:45:49.036994450 -0300
        +++ after	2020-12-17 14:46:01.654256639 -0300
        @@ -22,6 +22,10 @@
         	[0x00000060] = "LBR_CORE_TO",
         	[0x00000079] = "IA32_UCODE_WRITE",
         	[0x0000008b] = "IA32_UCODE_REV",
        +	[0x0000008C] = "IA32_SGXLEPUBKEYHASH0",
        +	[0x0000008D] = "IA32_SGXLEPUBKEYHASH1",
        +	[0x0000008E] = "IA32_SGXLEPUBKEYHASH2",
        +	[0x0000008F] = "IA32_SGXLEPUBKEYHASH3",
         	[0x0000009b] = "IA32_SMM_MONITOR_CTL",
         	[0x0000009e] = "IA32_SMBASE",
         	[0x000000c1] = "IA32_PERFCTR0",
        @@ -59,6 +63,7 @@
         	[0x00000179] = "IA32_MCG_CAP",
         	[0x0000017a] = "IA32_MCG_STATUS",
         	[0x0000017b] = "IA32_MCG_CTL",
        +	[0x0000017f] = "ERROR_CONTROL",
         	[0x00000180] = "IA32_MCG_EAX",
         	[0x00000181] = "IA32_MCG_EBX",
         	[0x00000182] = "IA32_MCG_ECX",
        @@ -294,6 +299,7 @@
         	[0xc0010241 - x86_AMD_V_KVM_MSRs_offset] = "F15H_NB_PERF_CTR",
         	[0xc0010280 - x86_AMD_V_KVM_MSRs_offset] = "F15H_PTSC",
         	[0xc0010299 - x86_AMD_V_KVM_MSRs_offset] = "AMD_RAPL_POWER_UNIT",
        +	[0xc001029a - x86_AMD_V_KVM_MSRs_offset] = "AMD_CORE_ENERGY_STATUS",
         	[0xc001029b - x86_AMD_V_KVM_MSRs_offset] = "AMD_PKG_ENERGY_STATUS",
         	[0xc00102f0 - x86_AMD_V_KVM_MSRs_offset] = "AMD_PPIN_CTL",
         	[0xc00102f1 - x86_AMD_V_KVM_MSRs_offset] = "AMD_PPIN",
        $
      
      Which causes these parts of tools/perf/ to be rebuilt:
      
        CC       /tmp/build/perf/trace/beauty/tracepoints/x86_msr.o
        LD       /tmp/build/perf/trace/beauty/tracepoints/perf-in.o
        LD       /tmp/build/perf/trace/beauty/perf-in.o
        LD       /tmp/build/perf/perf-in.o
        LINK     /tmp/build/perf/perf
      
      At some point these should just be tables read by perf on demand.
      
      This allows 'perf trace' users to use those strings to translate from
      the msr ids provided by the msr: tracepoints.
      
      This addresses this perf tools build warning:
      
        diff -u tools/arch/x86/include/asm/msr-index.h arch/x86/include/asm/msr-index.h
        Warning: Kernel ABI header at 'tools/arch/x86/include/asm/msr-index.h' differs from latest version at 'arch/x86/include/asm/msr-index.h'
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
      Cc: Sean Christopherson <seanjc@google.com>
      Cc: Tony Luck <tony.luck@intel.com>
      Cc: Victor Ding <victording@google.com>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      e9bde94f
    • Arnaldo Carvalho de Melo's avatar
      perf trace beauty: Update copy of linux/socket.h with the kernel sources · eb2842da
      Arnaldo Carvalho de Melo authored
      This just triggers the rebuilding of the syscall beautifiers that
      extract patterns from this file due to this cset:
      
        b713c195 ("net: provide __sys_shutdown_sock() that takes a socket")
      
      After updating it:
      
          CC       /tmp/build/perf/trace/beauty/sockaddr.o
      
      Addressing this perf build warning:
      
        Warning: Kernel ABI header at 'tools/perf/trace/beauty/include/linux/socket.h' differs from latest version at 'include/linux/socket.h'
        diff -u tools/perf/trace/beauty/include/linux/socket.h include/linux/socket.h
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jens Axboe <axboe@kernel.dk>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      eb2842da
    • Arnaldo Carvalho de Melo's avatar
      tools headers: Update linux/ctype.h with the kernel sources · 23cd9543
      Arnaldo Carvalho de Melo authored
      To pick up the changes in:
      
        caabdd0f ("ctype.h: remove duplicate isdigit() helper")
      
      Addressing this perf build warning:
      
        Warning: Kernel ABI header at 'tools/include/linux/ctype.h' differs from latest version at 'include/linux/ctype.h'
        diff -u tools/include/linux/ctype.h include/linux/ctype.h
      
      And we need to continue using the combination of:
      
        inline __isdigit()
        #define isdigit() __isdigit
      
      When the __has_builtin() thing isn't available, as it is a builtin in
      older systems with it as a builtin but with compilers not hacinv
      __has_builtin(), rendering the __has_builtin() check useless otherwise.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Ian Rogers <irogers@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>
      23cd9543
    • Arnaldo Carvalho de Melo's avatar
      tools headers: Add conditional __has_builtin() · ffb9beb1
      Arnaldo Carvalho de Melo authored
      As it'll be used by the ctype.h sync with its kernel source original.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Ian Rogers <irogers@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>
      ffb9beb1
    • Arnaldo Carvalho de Melo's avatar
      tools headers: Get tools's linux/compiler.h closer to the kernel's · 4bba4c4b
      Arnaldo Carvalho de Melo authored
      We're cherry picking stuff from the kernel to allow for the other
      headers that we keep in sync via tools/perf/check-headers.sh to work,
      so introduce linux/compiler_types.h and from there get the compiler
      specific stuff.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Ian Rogers <irogers@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>
      4bba4c4b
  3. 17 Dec, 2020 27 commits
    • Arnaldo Carvalho de Melo's avatar
      tools headers UAPI: Sync linux/stat.h with the kernel sources · 1c28a05d
      Arnaldo Carvalho de Melo authored
      To pick the changes in:
      
        72d1249e ("uapi: fix statx attribute value overlap for DAX & MOUNT_ROOT")
      
      That don't cause any change in tooling, just addresses 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: Eric Sandeen <sandeen@redhat.com>
      Cc: Ian Rogers <irogers@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>
      1c28a05d
    • Arnaldo Carvalho de Melo's avatar
      tools headers: Syncronize linux/build_bug.h with the kernel sources · 4262f8c3
      Arnaldo Carvalho de Melo authored
      To pick up the changes in:
      
        14dc3983 ("kbuild: avoid static_assert for genksyms")
      
      And silence this perf build warning:
      
        Warning: Kernel ABI header at 'tools/include/linux/build_bug.h' differs from latest version at 'include/linux/build_bug.h'
        diff -u tools/include/linux/build_bug.h include/linux/build_bug.h
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Ian Rogers <irogers@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>
      4262f8c3
    • Arnaldo Carvalho de Melo's avatar
      Merge remote-tracking branch 'torvalds/master' into perf/core · 281a94b0
      Arnaldo Carvalho de Melo authored
      To pick up fixes and check what UAPI headers need to be synched.
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      281a94b0
    • Jiri Olsa's avatar
      perf tools: Reformat record's control fd man text · feca8a83
      Jiri Olsa authored
      Adding available control commands in separate paragraph, so it's more
      readable and easier to add new commands.
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexei Budankov <abudankov@huawei.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Michael Petlan <mpetlan@redhat.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/20201216083914.47215-2-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      feca8a83
    • Nick Thompson's avatar
      perf config: Fix example command in manpage to conform to syntax specified in the SYNOPSIS section. · 526671bf
      Nick Thompson authored
      Committer testing:
      
      With the previously documented example:
      
        $ perf config --user report sort-order=srcline
        The config variable does not contain a section name: report
        $
      
      With the fixed example line:
      
        $ perf config --user report.sort-order=srcline
        $ perf config --user report.sort-order
        report.sort-order=srcline
        $
      Signed-off-by: default avatarNick Thompson <nathompson7@protonmail.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lore.kernel.org/linux-perf-users/20201217142619.GA14524@redhat.com/Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      526671bf
    • Arnaldo Carvalho de Melo's avatar
      perf test: Make sample-parsing test aware of PERF_SAMPLE_{CODE,DATA}_PAGE_SIZE · dc67d192
      Arnaldo Carvalho de Melo authored
      To fix this:
      
        $ perf test -v 27
        27: Sample parsing                                                  :
        --- start ---
        test child forked, pid 586013
        sample format has changed, some new PERF_SAMPLE_ bit was introduced - test needs updating
        test child finished with -1
        ---- end ----
        Sample parsing: FAILED!
        $
      
      This patchset is still not completely merged, so when adding the
      PERF_SAMPLE_CODE_PAGE_SIZE to 'struct perf_sample' we need to add the
      bits added in this patch for 'perf_sample.data_page_size'.
      
      Fixes: 251cc77b8176de37 ("tools headers UAPI: Update tools's copy of linux/perf_event.h")
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      dc67d192
    • Jiri Olsa's avatar
      perf tools: Add support to read build id from compressed elf · 47dce51a
      Jiri Olsa authored
      Adding support to decompress file before reading build id.
      
      Adding filename__read_build_id and change its current versions to
      read_build_id.
      
      Shutting down stderr output of perf list in the shell test:
        82: Check open filename arg using perf trace + vfs_getname          : Ok
      
      because with decompression code in the place we the
      filename__read_build_id function is more verbose in case
      of error and the test did not account for that.
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexei Budankov <abudankov@huawei.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20201214105457.543111-7-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      47dce51a
    • Jiri Olsa's avatar
      perf debug: Add debug_set_file function · 8abceacf
      Jiri Olsa authored
      Allow to set debug output file via new debug_set_file function.
      
      It's called during perf startup in perf_debug_setup to set stderr file
      as default and any perf command can set it later to different file.
      
      It will be used in perf daemon command to get verbose output into log
      file.
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexei Budankov <abudankov@huawei.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Michael Petlan <mpetlan@redhat.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/20201212104358.412065-2-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      8abceacf
    • Jiri Olsa's avatar
      perf tools: Add evlist__disable_evsel/evlist__enable_evsel · 7cfcd1e0
      Jiri Olsa authored
      Adding interface to enable/disable single event in the evlist based on
      its name. It will be used later in new control enable/disable interface.
      
      Keeping the evlist::enabled true when one or more events are enabled so
      the toggle can work properly and toggle evlist to disabled state.
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Acked-by: default avatarAlexei Budankov <abudankov@huawei.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Stephane Eranian <eranian@google.com>
      Link: https://lore.kernel.org/r/20201210204330.233864-2-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      7cfcd1e0
    • Namhyung Kim's avatar
      perf evlist: Support pipe mode display · 96aea4da
      Namhyung Kim authored
      Likewise, perf evlist command should print event attributes by reading
      PERF_RECORD_HEADER_ATTR records.
      
      Before:
        $ perf record -o- true | ./perf evlist -i-
        (prints nothing)
      
      After:
        $ perf record -o- true | ./perf evlist -i-
        cycles:pppH
      
      Committer testing:
      
      Verbose mode also works as expected:
      
        $ perf record -o- true | perf evlist -i-
        cycles:uhH
        $ perf record -o- true | perf evlist -vi-
        cycles:uhH: size: 120, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|ID|PERIOD, read_format: ID, disabled: 1, inherit: 1, exclude_kernel: 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
        $
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: https://lore.kernel.org/r/20201210061302.88213-2-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      96aea4da
    • Namhyung Kim's avatar
      perf report: Support --header-only for pipe mode · 03de8656
      Namhyung Kim authored
      The --header-only checks file header and prints the feature data.  But
      as pipe mode doesn't have it in the header it prints almost nothing.
      Change it to process first few records until it founds HEADER_FEATURE.
      
      Before:
        $ perf record -o- true | perf report -i- --header-only
        # ========
        # captured on    : Thu Dec 10 14:34:59 2020
        # header version : 1
        # data offset    : 0
        # data size      : 0
        # feat offset    : 0
        # ========
        #
      
      After:
        $ perf record -o- true | perf report -i- --header-only
        # ========
        # captured on    : Thu Dec 10 14:49:11 2020
        # header version : 1
        # data offset    : 0
        # data size      : 0
        # feat offset    : 0
        # ========
        #
        # hostname : balhae
        # os release : 5.7.17-1xxx
        # perf version : 5.10.rc6.gdb0ea13c
        # arch : x86_64
        # nrcpus online : 8
        # nrcpus avail : 8
        # cpudesc : Intel(R) Core(TM) i7-8665U CPU @ 1.90GHz
        # cpuid : GenuineIntel,6,142,12
        # total memory : 16158916 kB
        # cmdline : perf record -o- true
        # event : name = cycles, , id = { 81, 82, 83, 84, 85, 86, 87, 88 }, size = 120, ...
        # CPU_TOPOLOGY info available, use -I to display
        # NUMA_TOPOLOGY info available, use -I to display
        # pmu mappings: intel_pt = 9, intel_bts = 8, software = 1, power = 20, uprobe = 7, ...
        # time of first sample : 0.000000
        # time of last sample : 0.000000
        # sample duration :      0.000 ms
        # MEM_TOPOLOGY info available, use -I to display
        # cpu pmu capabilities: branches=32, max_precise=3, pmu_name=skylake
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: https://lore.kernel.org/r/20201210061302.88213-1-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      03de8656
    • Joakim Zhang's avatar
      perf vendor events: Add JSON metrics for imx8mm DDR Perf · e15a5365
      Joakim Zhang authored
      Add JSON metrics for imx8mm DDR Perf.
      Signed-off-by: default avatarJoakim Zhang <qiangqing.zhang@nxp.com>
      Acked-by: default avatarKajol Jain <kjain@linux.ibm.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Kim Phillips <kim.phillips@amd.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Shaokun Zhang <zhangshaokun@hisilicon.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: linuxarm@huawei.com
      Signed-off-by: default avatarJohn Garry <john.garry@huawei.com>
      Link: http://lore.kernel.org/lkml/1607080216-36968-11-git-send-email-john.garry@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      e15a5365
    • John Garry's avatar
      perf metricgroup: Support adding metrics for system PMUs · be335ec2
      John Garry authored
      Currently adding metrics for core- or uncore-based events matched by CPUID
      is supported.
      
      Extend this for system events.
      Signed-off-by: default avatarJohn Garry <john.garry@huawei.com>
      Acked-by: default avatarKajol Jain <kjain@linux.ibm.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Joakim Zhang <qiangqing.zhang@nxp.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Kim Phillips <kim.phillips@amd.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Shaokun Zhang <zhangshaokun@hisilicon.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: linuxarm@huawei.com
      Link: http://lore.kernel.org/lkml/1607080216-36968-10-git-send-email-john.garry@huawei.com
      [ Reorder 'struct metricgroup_add_iter_data' field to avoid alignment holes ]
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      be335ec2
    • John Garry's avatar
      perf metricgroup: Support printing metric groups for system PMUs · a36fadb1
      John Garry authored
      Currently printing metricgroups for core- or uncore-based events matched
      by CPUID is supported.
      
      Extend this for system events.
      Signed-off-by: default avatarJohn Garry <john.garry@huawei.com>
      Acked-by: default avatarKajol Jain <kjain@linux.ibm.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Joakim Zhang <qiangqing.zhang@nxp.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Kim Phillips <kim.phillips@amd.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Shaokun Zhang <zhangshaokun@hisilicon.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: linuxarm@huawei.com
      Link: http://lore.kernel.org/lkml/1607080216-36968-9-git-send-email-john.garry@huawei.com
      [ Reorder 'struct metricgroup_print_sys_idata' field to avoid alignment holes ]
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      a36fadb1
    • John Garry's avatar
      perf metricgroup: Split up metricgroup__print() · f6fe1e48
      John Garry authored
      To aid supporting system event metric groups, break up the function
      metricgroup__print() into a part which iterates metrics and a part which
      actually "prints" the metric.
      
      No functional change intended.
      Signed-off-by: default avatarJohn Garry <john.garry@huawei.com>
      Acked-by: default avatarKajol Jain <kjain@linux.ibm.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Joakim Zhang <qiangqing.zhang@nxp.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Kim Phillips <kim.phillips@amd.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Shaokun Zhang <zhangshaokun@hisilicon.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: linuxarm@huawei.com
      Link: http://lore.kernel.org/lkml/1607080216-36968-8-git-send-email-john.garry@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      f6fe1e48
    • John Garry's avatar
      perf metricgroup: Fix metrics using aliases covering multiple PMUs · c2337d67
      John Garry authored
      Support for metric expressions using aliases which cover multiple PMUs
      is broken. Consider the following test metric expression:
      
        "MetricExpr": "UNC_CBO_XSNP_RESPONSE.MISS_XCORE * UNC_CBO_XSNP_RESPONSE.MISS_EVICTION"
      
      When used on my broadwell, "perf stat" gives:
      
        unc_cbo_xsnp_response.miss_eviction -> uncore_cbox_1/umask=0x81,event=0x22/
        unc_cbo_xsnp_response.miss_eviction -> uncore_cbox_0/umask=0x81,event=0x22/
        unc_cbo_xsnp_response.miss_xcore -> uncore_cbox_1/umask=0x41,event=0x22/
        unc_cbo_xsnp_response.miss_xcore -> uncore_cbox_0/umask=0x41,event=0x22/
        Control descriptor is not initialized
        unc_cbo_xsnp_response.miss_eviction: 3645925 1000850523 1000850523
        unc_cbo_xsnp_response.miss_xcore: 106850 1000850523 1000850523
      
         Performance counter stats for 'system wide':
      
                 3,645,925      unc_cbo_xsnp_response.miss_eviction # 389567086250.00 test_metric_inc
                   106,850      unc_cbo_xsnp_response.miss_xcore
      
               1.000883096 seconds time elapsed
      
      Notice that only the results from one PMU are included. Fix the logic of
      find_evsel_group() to enable events which apply to multiple PMUs, by
      checking if the event pmu_name matches that of the metric event.
      
      With that, "perf stat" now gives:
      
        unc_cbo_xsnp_response.miss_eviction -> uncore_cbox_1/umask=0x81,event=0x22/
        unc_cbo_xsnp_response.miss_eviction -> uncore_cbox_0/umask=0x81,event=0x22/
        unc_cbo_xsnp_response.miss_xcore -> uncore_cbox_1/umask=0x41,event=0x22/
        unc_cbo_xsnp_response.miss_xcore -> uncore_cbox_0/umask=0x41,event=0x22/
        Control descriptor is not initialized
        unc_cbo_xsnp_response.miss_eviction: 4237983 1000904100 1000904100
        unc_cbo_xsnp_response.miss_xcore: 218643 1000904100 1000904100
        unc_cbo_xsnp_response.miss_eviction: 4254148 1000902629 1000902629
        unc_cbo_xsnp_response.miss_xcore: 213352 1000902629 1000902629
      
         Performance counter stats for 'system wide':
      
                 4,237,983      unc_cbo_xsnp_response.miss_eviction # 3668558131345.00 test_metric_inc
                   218,643      unc_cbo_xsnp_response.miss_xcore
                 4,254,148      unc_cbo_xsnp_response.miss_eviction
                   213,352      unc_cbo_xsnp_response.miss_xcore
      
               1.000938151 seconds time elapsed
      Signed-off-by: default avatarJohn Garry <john.garry@huawei.com>
      Acked-by: default avatarKajol Jain <kjain@linux.ibm.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Joakim Zhang <qiangqing.zhang@nxp.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Kim Phillips <kim.phillips@amd.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Shaokun Zhang <zhangshaokun@hisilicon.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: linuxarm@huawei.com
      Link: http://lore.kernel.org/lkml/1607080216-36968-7-git-send-email-john.garry@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      c2337d67
    • John Garry's avatar
      perf evlist: Change evlist__splice_list_tail() ordering · 6d2783fe
      John Garry authored
      Function find_evsel_group() expects events to be ordered such that they
      are grouped after their leader.
      
      Modify evlist__splice_list_tail() to guarantee this (ordering).
      
      [Should prob also change the function name]
      Signed-off-by: default avatarJohn Garry <john.garry@huawei.com>
      Acked-by: default avatarKajol Jain <kjain@linux.ibm.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Joakim Zhang <qiangqing.zhang@nxp.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Kim Phillips <kim.phillips@amd.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Shaokun Zhang <zhangshaokun@hisilicon.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: linuxarm@huawei.com
      Link: http://lore.kernel.org/lkml/1607080216-36968-6-git-send-email-john.garry@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      6d2783fe
    • John Garry's avatar
      perf pmu: Add pmu_add_sys_aliases() · 4513c719
      John Garry authored
      Add pmu_add_sys_aliases() to add system PMU events aliases.
      
      For adding system PMU events, iterate through all the events for all SoC
      event tables in pmu_sys_event_tables[].
      
      Matches must satisfy both:
      - PMU identifier matches event "compat" value
      - event "Unit" member must match, same as uncore event aliases matched by
        CPUID
      Signed-off-by: default avatarJohn Garry <john.garry@huawei.com>
      Acked-by: default avatarKajol Jain <kjain@linux.ibm.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Joakim Zhang <qiangqing.zhang@nxp.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Kim Phillips <kim.phillips@amd.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Shaokun Zhang <zhangshaokun@hisilicon.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: linuxarm@huawei.com
      Link: http://lore.kernel.org/lkml/1607080216-36968-5-git-send-email-john.garry@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      4513c719
    • John Garry's avatar
      perf pmu: Add pmu_id() · 51d54847
      John Garry authored
      Add a function to read the PMU id sysfs entry. This is only done for uncore
      PMUs where this would possibly be relevant.
      Signed-off-by: default avatarJohn Garry <john.garry@huawei.com>
      Acked-by: default avatarKajol Jain <kjain@linux.ibm.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Joakim Zhang <qiangqing.zhang@nxp.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Kim Phillips <kim.phillips@amd.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Shaokun Zhang <zhangshaokun@hisilicon.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: linuxarm@huawei.com
      Link: http://lore.kernel.org/lkml/1607080216-36968-4-git-send-email-john.garry@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      51d54847
    • John Garry's avatar
      perf jevents: Add support for system events tables · 4689f567
      John Garry authored
      Process the JSONs to find support for "system" events, which are not
      tied to a specific CPUID.
      
      A "COMPAT" property is now used to match against the namespace ID from
      the kernel PMU driver.
      
      The generated pmu-events.c will now have 2 tables:
      
      a. CPU events, as before.
      b. New pmu_sys_event_tables[] table, which will have events matched to
         specific SoCs.
      
      It will look like this:
      
      struct pmu_event pme_hisilicon_hip09_sys[] = {
      {
      	.name = "cycles",
      	.compat = "0x00030736",
      	.event = "event=0",
      	.desc = "Clock cycles",
      	.topic = "smmu v3 pmcg",
      	.long_desc = "Clock cycles",
      },
      {
      	.name = "smmuv3_pmcg.l1_tlb",
      	.compat = "0x00030736",
      	.event = "event=0x8a",
      	.desc = "SMMUv3 PMCG l1_tlb. Unit: smmuv3_pmcg ",
      	.topic = "smmu v3 pmcg",
      	.long_desc = "SMMUv3 PMCG l1_tlb",
      	.pmu = "smmuv3_pmcg",
      },
      ...
      };
      
      struct pmu_event pme_arm_cortex_a53[] = {
      {
      	.name = "ext_mem_req",
      	.event = "event=0xc0",
      	.desc = "External memory request",
      	.topic = "memory",
      },
      {
      	.name = "ext_mem_req_nc",
      	.event = "event=0xc1",
      	.desc = "Non-cacheable external memory request",
      	.topic = "memory",
      },
      ...
      };
      
      struct pmu_event pme_hisilicon_hip09_cpu[] = {
      {
      	.name = "l2d_cache_refill_wr",
      	.event = "event=0x53",
      	.desc = "L2D cache refill, write",
      	.topic = "core imp def",
      	.long_desc = "Attributable Level 2 data cache refill, write",
      },
      ...
      };
      
      struct pmu_events_map pmu_events_map[] = {
      {
      	.cpuid = "0x00000000410fd030",
      	.version = "v1",
      	.type = "core",
      	.table = pme_arm_cortex_a53
      },
      {
      	.cpuid = "0x00000000480fd010",
      	.version = "v1",
      	.type = "core",
      	.table = pme_hisilicon_hip09_cpu
      },
      	{
      		.table = 0
      	},
      };
      
      struct pmu_event pme_hisilicon_hip09_cpu[] = {
      {
      	.name = "uncore_hisi_l3c.rd_cpipe",
      	.event = "event=0",
      	.desc = "Total read accesses. Unit: hisi_sccl,l3c ",
      	.topic = "uncore l3c",
      	.long_desc = "Total read accesses",
      	.pmu = "hisi_sccl,l3c",
      },
      {
      	.name = "uncore_hisi_l3c.wr_cpipe",
      	.event = "event=0x1",
      	.desc = "Total write accesses. Unit: hisi_sccl,l3c ",
      	.topic = "uncore l3c",
      	.long_desc = "Total write accesses",
      	.pmu = "hisi_sccl,l3c",
      },
      ...
      };
      
      struct pmu_sys_events pmu_sys_event_tables[] = {
      {
      	.table = pme_hisilicon_hip09_sys,
      },
      ...
      };
      
      Committer notes:
      
      Added the fix for architectures without PMU events, provided by John
      after I reported the build failing in such systems.
      
      Link: https://lore.kernel.org/lkml/650baaf2-36b6-a9e2-ff49-963ef864c1f3@huawei.com/Signed-off-by: default avatarJohn Garry <john.garry@huawei.com>
      Acked-by: default avatarKajol Jain <kjain@linux.ibm.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Joakim Zhang <qiangqing.zhang@nxp.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Kim Phillips <kim.phillips@amd.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Shaokun Zhang <zhangshaokun@hisilicon.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: linuxarm@huawei.com
      Link: http://lore.kernel.org/lkml/1607080216-36968-3-git-send-email-john.garry@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      4689f567
    • John Garry's avatar
      perf jevents: Add support for an extra directory level · 4853f1ca
      John Garry authored
      Currently only upto a level 2 directory is supported, in form
      vendor/platform.
      
      Add support for a further level, to support vendor/platform
      sub-directories in future, which will be vendor/platform/cpu and
      vendor/platform/sys.
      Signed-off-by: default avatarJohn Garry <john.garry@huawei.com>
      Acked-by: default avatarKajol Jain <kjain@linux.ibm.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Joakim Zhang <qiangqing.zhang@nxp.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Kim Phillips <kim.phillips@amd.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Shaokun Zhang <zhangshaokun@hisilicon.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: linuxarm@huawei.com
      Link: http://lore.kernel.org/lkml/1607080216-36968-2-git-send-email-john.garry@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      4853f1ca
    • Arnaldo Carvalho de Melo's avatar
      perf evsel: Emit warning about kernel not supporting the data page size sample_type bit · 456ef4c1
      Arnaldo Carvalho de Melo authored
      Before we had this unhelpful message:
      
        $ perf record --data-page-size sleep 1
        Error:
        The sys_perf_event_open() syscall returned with 22 (Invalid argument) for event (cycles:u).
        /bin/dmesg | grep -i perf may provide additional information.
        $
      
      Add support to the perf_missing_features variable to remember what
      caused evsel__open() to fail and then use that information in
      evsel__open_strerror().
      
        $ perf record --data-page-size sleep 1
        Error:
        Asking for the data page size isn't supported by this kernel.
        $
      
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Will Deacon <will@kernel.org>
      Link: http://lore.kernel.org/lkml/20201207170759.GB129853@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      456ef4c1
    • Kan Liang's avatar
      perf record: Support new sample type for data page size · 542b88fd
      Kan Liang authored
      Support new sample type PERF_SAMPLE_DATA_PAGE_SIZE for page size.
      
      Add new option --data-page-size to record sample data page size.
      Signed-off-by: default avatarKan Liang <kan.liang@linux.intel.com>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Will Deacon <will@kernel.org>
      Link: http://lore.kernel.org/lkml/20201130172803.2676-3-kan.liang@linux.intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      542b88fd
    • Kan Liang's avatar
      tools headers UAPI: Update tools's copy of linux/perf_event.h · 47d98220
      Kan Liang authored
      To get the changes in:
      
         commit 8d97e718 ("perf/core: Add PERF_SAMPLE_DATA_PAGE_SIZE")
         commit 995f088e ("perf/core: Add support for PERF_SAMPLE_CODE_PAGE_SIZE")
      
      This silences this perf tools build warning:
      
        Warning: Kernel ABI header at 'tools/include/uapi/linux/perf_event.h'
      differs from latest version at 'include/uapi/linux/perf_event.h'
        diff -u tools/include/uapi/linux/perf_event.h
      include/uapi/linux/perf_event.h
      Signed-off-by: default avatarKan Liang <kan.liang@linux.intel.com>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Will Deacon <will@kernel.org>
      Link: http://lore.kernel.org/lkml/20201130172803.2676-2-kan.liang@linux.intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      47d98220
    • Jan Kratochvil's avatar
      perf unwind: Fix separate debug info files when using elfutils' libdw's unwinder · bf53fc6b
      Jan Kratochvil authored
      elfutils needs to be provided main binary and separate debug info file
      respectively. Providing separate debug info file instead of the main
      binary is not sufficient.
      
      One needs to try both supplied filename and its possible cache by its
      build-id depending on the use case.
      Signed-off-by: default avatarJan Kratochvil <jan.kratochvil@redhat.com>
      Tested-by: default avatarJiri Olsa <jolsa@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      bf53fc6b
    • Zheng Zengkai's avatar
      perf record: Fix memory leak when using '--user-regs=?' to list registers · 2eb5dd41
      Zheng Zengkai authored
      When using 'perf record's option '-I' or '--user-regs=' along with
      argument '?' to list available register names, memory of variable 'os'
      allocated by strdup() needs to be released before __parse_regs()
      returns, otherwise memory leak will occur.
      
      Fixes: bcc84ec6 ("perf record: Add ability to name registers to record")
      Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
      Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Li Bin <huawei.libin@huawei.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lore.kernel.org/r/20200703093344.189450-1-zhengzengkai@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      2eb5dd41
    • Jiri Olsa's avatar
      tools build: Add missing libcap to test-all.bin target · 09d59c2f
      Jiri Olsa authored
      We're missing -lcap in test-all.bin target, so in case it's the only
      library missing (if more are missing test-all.bin fails anyway), we will
      falsely claim that we detected it and fail build, like:
      
        $ make
        ...
        Auto-detecting system features:
        ...                         dwarf: [ on  ]
        ...            dwarf_getlocations: [ on  ]
        ...                         glibc: [ on  ]
        ...                        libbfd: [ on  ]
        ...                libbfd-buildid: [ on  ]
        ...                        libcap: [ on  ]
        ...                        libelf: [ on  ]
        ...                       libnuma: [ on  ]
        ...        numa_num_possible_cpus: [ on  ]
        ...                       libperl: [ on  ]
        ...                     libpython: [ on  ]
        ...                     libcrypto: [ on  ]
        ...                     libunwind: [ on  ]
        ...            libdw-dwarf-unwind: [ on  ]
        ...                          zlib: [ on  ]
        ...                          lzma: [ on  ]
        ...                     get_cpuid: [ on  ]
        ...                           bpf: [ on  ]
        ...                        libaio: [ on  ]
        ...                       libzstd: [ on  ]
        ...        disassembler-four-args: [ on  ]
      
        ...
      
          CC       builtin-ftrace.o
      
        In file included from builtin-ftrace.c:29:
        util/cap.h:11:10: fatal error: sys/capability.h: No such file or directory
           11 | #include <sys/capability.h>
              |          ^~~~~~~~~~~~~~~~~~
        compilation terminated.
      
      Fixes: 74d5f3d0 ("tools build: Add capability-related feature detection")
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Igor Lubashev <ilubashe@akamai.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Michael Petlan <mpetlan@redhat.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/20201203230836.3751981-1-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      09d59c2f