1. 17 Aug, 2023 6 commits
    • Arnaldo Carvalho de Melo's avatar
      perf top: Don't pass an ERR_PTR() directly to perf_session__delete() · ef23cb59
      Arnaldo Carvalho de Melo authored
      While debugging a segfault on 'perf lock contention' without an
      available perf.data file I noticed that it was basically calling:
      
      	perf_session__delete(ERR_PTR(-1))
      
      Resulting in:
      
        (gdb) run lock contention
        Starting program: /root/bin/perf lock contention
        [Thread debugging using libthread_db enabled]
        Using host libthread_db library "/lib64/libthread_db.so.1".
        failed to open perf.data: No such file or directory  (try 'perf record' first)
        Initializing perf session failed
      
        Program received signal SIGSEGV, Segmentation fault.
        0x00000000005e7515 in auxtrace__free (session=0xffffffffffffffff) at util/auxtrace.c:2858
        2858		if (!session->auxtrace)
        (gdb) p session
        $1 = (struct perf_session *) 0xffffffffffffffff
        (gdb) bt
        #0  0x00000000005e7515 in auxtrace__free (session=0xffffffffffffffff) at util/auxtrace.c:2858
        #1  0x000000000057bb4d in perf_session__delete (session=0xffffffffffffffff) at util/session.c:300
        #2  0x000000000047c421 in __cmd_contention (argc=0, argv=0x7fffffffe200) at builtin-lock.c:2161
        #3  0x000000000047dc95 in cmd_lock (argc=0, argv=0x7fffffffe200) at builtin-lock.c:2604
        #4  0x0000000000501466 in run_builtin (p=0xe597a8 <commands+552>, argc=2, argv=0x7fffffffe200) at perf.c:322
        #5  0x00000000005016d5 in handle_internal_command (argc=2, argv=0x7fffffffe200) at perf.c:375
        #6  0x0000000000501824 in run_argv (argcp=0x7fffffffe02c, argv=0x7fffffffe020) at perf.c:419
        #7  0x0000000000501b11 in main (argc=2, argv=0x7fffffffe200) at perf.c:535
        (gdb)
      
      So just set it to NULL after using PTR_ERR(session) to decode the error
      as perf_session__delete(NULL) is supported.
      
      The same problem was found in 'perf top' after an audit of all
      perf_session__new() failure handling.
      
      Fixes: 6ef81c55 ("perf session: Return error code for perf_session__new() function on failure")
      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: Jiri Olsa <jolsa@kernel.org>
      Cc: Kate Stewart <kstewart@linuxfoundation.org>
      Cc: Mamatha Inamdar <mamatha4@linux.vnet.ibm.com>
      Cc: Mukesh Ojha <mojha@codeaurora.org>
      Cc: Nageswara R Sastry <rnsastry@linux.vnet.ibm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
      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: https://lore.kernel.org/lkml/ZN4Q2rxxsL08A8rd@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      ef23cb59
    • James Clark's avatar
      perf vendor events arm64: Update N2 and V2 metrics and events using Arm telemetry repo · 44739490
      James Clark authored
      Apart from some slight naming and grouping differences, the new metrics
      are functionally the same as the existing ones. Any missing metrics were
      manually appended to the end of the auto generated file.
      
      For the events, the new data includes descriptions that may have product
      specific details and new groupings that will be consistent with other
      products.
      
      After generating the metrics from the telemetry repo [1], the following
      manual steps were performed:
      
       * Change the topdown expressions to compare on CPUID and use
         #slots so that the same data can be shared between N2 and V2. Apart
         from these modifications, the expressions now match more closely with
         the Arm telemetry data which will hopefully make future updates
         easier.
      
       * Append some metrics from the old N2/V2 data that aren't present in
         the telemetry data. These will possibly be added to the
         telemetry-solution repo at a later time:
      
          l3d_cache_mpki, l3d_cache_miss_rate, branch_pki, ipc_rate, spec_ipc,
          retired_rate, wasted_rate, branch_immed_spec_rate,
          branch_return_spec_rate, branch_indirect_spec_rate
      
      [1]: https://gitlab.arm.com/telemetry-solution/telemetry-solution/-/blob/main/data/pmu/cpu/neoverse/neoverse-n2.jsonSigned-off-by: default avatarJames Clark <james.clark@arm.com>
      Reviewed-by: default avatarJohn Garry <john.g.garry@oracle.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andrii Nakryiko <andrii@kernel.org>
      Cc: Eduard Zingerman <eddyz87@gmail.com>
      Cc: Haixin Yu <yuhaixin.yhx@linux.alibaba.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jing Zhang <renyu.zj@linux.alibaba.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nick Forrington <nick.forrington@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Rob Herring <robh@kernel.org>
      Cc: Sohom Datta <sohomdatta1@gmail.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/20230816114841.1679234-7-james.clark@arm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      44739490
    • James Clark's avatar
      perf vendor events arm64: Update stall_slot workaround for N2 r0p3 · d43f5491
      James Clark authored
      N2 r0p3 doesn't require the workaround [1], so gating on (#slots - 5) no
      longer works because all N2s have 5 slots. Use the new expression
      builtin that allows calling strcmp_cpuid_str() and comparing CPUIDs in
      metric formulas.
      
      In this case, the commented formula looks like this:
      
        strcmp_cpuid_str(0x410fd493)        # greater than or equal to N2 r0p3
        | strcmp_cpuid_str(0x410fd490) ^ 1  # OR NOT any version of N2
      
      [1]: https://gitlab.arm.com/telemetry-solution/telemetry-solution/-/blob/main/data/pmu/cpu/neoverse/neoverse-n2-r0p3.jsonSigned-off-by: default avatarJames Clark <james.clark@arm.com>
      Reviewed-by: default avatarJohn Garry <john.g.garry@oracle.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Eduard Zingerman <eddyz87@gmail.com>
      Cc: Haixin Yu <yuhaixin.yhx@linux.alibaba.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jing Zhang <renyu.zj@linux.alibaba.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nick Forrington <nick.forrington@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Rob Herring <robh@kernel.org>
      Cc: Sohom Datta <sohomdatta1@gmail.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/20230816114841.1679234-6-james.clark@arm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      d43f5491
    • James Clark's avatar
      perf jevents: Add a new expression builtin strcmp_cpuid_str() · 9d5da30e
      James Clark authored
      This will allow writing formulas that are conditional on a specific
      CPU type or CPU version. It calls through to the existing
      strcmp_cpuid_str() function in Perf which has a default weak version,
      and an arch specific version for x86 and arm64.
      
      The function takes an 'ID' type value, which is a string. But in this
      case Arm CPU IDs are hex numbers prefixed with '0x'. metric.py
      assumes strings are only used by event names, and that they can't start
      with a number ('0'), so an additional change has to be made to the
      regex to convert hex numbers back to 'ID' types.
      Signed-off-by: default avatarJames Clark <james.clark@arm.com>
      Reviewed-by: default avatarJohn Garry <john.g.garry@oracle.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Eduard Zingerman <eddyz87@gmail.com>
      Cc: Haixin Yu <yuhaixin.yhx@linux.alibaba.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jing Zhang <renyu.zj@linux.alibaba.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nick Forrington <nick.forrington@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Rob Herring <robh@kernel.org>
      Cc: Sohom Datta <sohomdatta1@gmail.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/20230816114841.1679234-5-james.clark@arm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      9d5da30e
    • James Clark's avatar
      perf test: Add a test for the new Arm CPU ID comparison behavior · 81f7da54
      James Clark authored
      Now that variant and revision fields are taken into account the behavior
      is slightly more complicated so add a test to ensure that this behaves
      as expected.
      Reviewed-by: default avatarJohn Garry <john.g.garry@oracle.com>
      Signed-off-by: default avatarJames Clark <james.clark@arm.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Eduard Zingerman <eddyz87@gmail.com>
      Cc: Haixin Yu <yuhaixin.yhx@linux.alibaba.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jing Zhang <renyu.zj@linux.alibaba.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nick Forrington <nick.forrington@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Rob Herring <robh@kernel.org>
      Cc: Sohom Datta <sohomdatta1@gmail.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/20230816114841.1679234-3-james.clark@arm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      81f7da54
    • James Clark's avatar
      perf arm64: Allow version comparisons of CPU IDs · c3e1e8cf
      James Clark authored
      Currently variant and revision fields are masked out of the MIDR so
      it's not possible to compare different versions of the same CPU.
      In a later commit a workaround will be removed just for N2 r0p3, so
      enable comparisons on version.
      
      This has the side effect of changing the MIDR stored in the header of
      the perf.data file to no longer have masked version fields. It also
      affects the lookups in mapfile.csv, but as that currently only has
      zeroed version fields, it has no actual effect. The mapfile.csv
      documentation also states to zero the version fields, so unless this
      isn't done it will continue to have no effect.
      
      There is an existing weak default strcmp_cpuid_str() function, and an
      x86 version. This adds another version for arm64.
      Signed-off-by: default avatarJames Clark <james.clark@arm.com>
      Reviewed-by: default avatarJohn Garry <john.g.garry@oracle.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andrii Nakryiko <andrii@kernel.org>
      Cc: Eduard Zingerman <eddyz87@gmail.com>
      Cc: Haixin Yu <yuhaixin.yhx@linux.alibaba.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jing Zhang <renyu.zj@linux.alibaba.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nick Forrington <nick.forrington@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Rob Herring <robh@kernel.org>
      Cc: Sohom Datta <sohomdatta1@gmail.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/20230816114841.1679234-2-james.clark@arm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      c3e1e8cf
  2. 16 Aug, 2023 17 commits
    • Arnaldo Carvalho de Melo's avatar
      perf bpf_skel augmented_raw_syscalls: Cap the socklen parameter using &= sizeof(saddr) · 18364804
      Arnaldo Carvalho de Melo authored
      This works with:
      
        $ clang -v
        clang version 14.0.5 (Fedora 14.0.5-2.fc36)
        $
      
      But not with:
      
        $ clang -v
        clang version 16.0.6 (Fedora 16.0.6-2.fc38)
        $
      
        [root@quaco ~]# perf trace -e connect*,sendto* ping -c 10 localhost
        libbpf: prog 'sys_enter_sendto': BPF program load failed: Permission denied
        libbpf: prog 'sys_enter_sendto': -- BEGIN PROG LOAD LOG --
        reg type unsupported for arg#0 function sys_enter_sendto#59
        0: R1=ctx(off=0,imm=0) R10=fp0
        ; int sys_enter_sendto(struct syscall_enter_args *args)
        0: (bf) r6 = r1                       ; R1=ctx(off=0,imm=0) R6_w=ctx(off=0,imm=0)
        1: (b7) r1 = 0                        ; R1_w=0
        ; int key = 0;
        2: (63) *(u32 *)(r10 -4) = r1         ; R1_w=0 R10=fp0 fp-8=0000????
        3: (bf) r2 = r10                      ; R2_w=fp0 R10=fp0
        ;
        4: (07) r2 += -4                      ; R2_w=fp-4
        ; return bpf_map_lookup_elem(&augmented_args_tmp, &key);
        5: (18) r1 = 0xffff8de5a5b8bc00       ; R1_w=map_ptr(off=0,ks=4,vs=8272,imm=0)
        7: (85) call bpf_map_lookup_elem#1    ; R0_w=map_value_or_null(id=1,off=0,ks=4,vs=8272,imm=0)
        8: (bf) r7 = r0                       ; R0_w=map_value_or_null(id=1,off=0,ks=4,vs=8272,imm=0) R7_w=map_value_or_null(id=1,off=0,ks=4,vs=8272,imm=0)
        9: (b7) r0 = 1                        ; R0_w=1
        ; if (augmented_args == NULL)
        10: (15) if r7 == 0x0 goto pc+25      ; R7_w=map_value(off=0,ks=4,vs=8272,imm=0)
        ; unsigned int socklen = args->args[5];
        11: (79) r1 = *(u64 *)(r6 +56)        ; R1_w=scalar() R6_w=ctx(off=0,imm=0)
        ;
        12: (bf) r2 = r1                      ; R1_w=scalar(id=2) R2_w=scalar(id=2)
        13: (67) r2 <<= 32                    ; R2_w=scalar(smax=9223372032559808512,umax=18446744069414584320,var_off=(0x0; 0xffffffff00000000),s32_min=0,s32_max=0,u32_max=0)
        14: (77) r2 >>= 32                    ; R2_w=scalar(umax=4294967295,var_off=(0x0; 0xffffffff))
        15: (b7) r8 = 128                     ; R8=128
        ; if (socklen > sizeof(augmented_args->saddr))
        16: (25) if r2 > 0x80 goto pc+1       ; R2=scalar(umax=128,var_off=(0x0; 0xff))
        17: (bf) r8 = r1                      ; R1=scalar(id=2) R8_w=scalar(id=2)
        ; const void *sockaddr_arg = (const void *)args->args[4];
        18: (79) r3 = *(u64 *)(r6 +48)        ; R3_w=scalar() R6=ctx(off=0,imm=0)
        ; bpf_probe_read(&augmented_args->saddr, socklen, sockaddr_arg);
        19: (bf) r1 = r7                      ; R1_w=map_value(off=0,ks=4,vs=8272,imm=0) R7=map_value(off=0,ks=4,vs=8272,imm=0)
        20: (07) r1 += 64                     ; R1_w=map_value(off=64,ks=4,vs=8272,imm=0)
        ; bpf_probe_read(&augmented_args->saddr, socklen, sockaddr_arg);
        21: (bf) r2 = r8                      ; R2_w=scalar(id=2) R8_w=scalar(id=2)
        22: (85) call bpf_probe_read#4
        R2 min value is negative, either use unsigned or 'var &= const'
        processed 22 insns (limit 1000000) max_states_per_insn 0 total_states 1 peak_states 1 mark_read 1
        -- END PROG LOAD LOG --
        libbpf: prog 'sys_enter_sendto': failed to load: -13
        libbpf: failed to load object 'augmented_raw_syscalls_bpf'
        libbpf: failed to load BPF skeleton 'augmented_raw_syscalls_bpf': -13
      
      So use the suggested &= variant since sizeof(saddr) == 128 bytes.
      
      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>
      18364804
    • Kajol Jain's avatar
      perf vendor events: Update metric events for power10 platform · 5ceb8b5b
      Kajol Jain authored
      Update JSON/events for power10 platform with additional metrics.
      Signed-off-by: default avatarKajol Jain <kjain@linux.ibm.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Disha Goel <disgoel@linux.ibm.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: linuxppc-dev@lists.ozlabs.org
      Link: https://lore.kernel.org/r/20230814112803.1508296-7-kjain@linux.ibm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      5ceb8b5b
    • Kajol Jain's avatar
      perf vendor events: Update metric event names for power10 platform · edd65d2b
      Kajol Jain authored
      Update metric event name for some of the JSON/metric events for
      power10 platform.
      
      Fixes: 3ca3af7d ("perf vendor events power10: Add metric events JSON file for power10 platform")
      Signed-off-by: default avatarKajol Jain <kjain@linux.ibm.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Disha Goel <disgoel@linux.ibm.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: linuxppc-dev@lists.ozlabs.org
      Link: https://lore.kernel.org/r/20230814112803.1508296-6-kjain@linux.ibm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      edd65d2b
    • Kajol Jain's avatar
      perf vendor events: Update JSON/events for power10 platform · 426c804b
      Kajol Jain authored
      Update JSON/events for power10 platform with additional events.
      Signed-off-by: default avatarKajol Jain <kjain@linux.ibm.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Disha Goel <disgoel@linux.ibm.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: linuxppc-dev@lists.ozlabs.org
      Link: https://lore.kernel.org/r/20230814112803.1508296-5-kjain@linux.ibm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      426c804b
    • Kajol Jain's avatar
      perf vendor events: Move JSON/events to appropriate files for power10 platform · 7d473f47
      Kajol Jain authored
      Move some of the power10 JSON/events to appropriate files.
      
      Fixes: 32daa5d7 ("perf vendor events: Initial JSON/events list for power10 platform")
      Signed-off-by: default avatarKajol Jain <kjain@linux.ibm.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Disha Goel <disgoel@linux.ibm.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: linuxppc-dev@lists.ozlabs.org
      Link: https://lore.kernel.org/r/20230814112803.1508296-4-kjain@linux.ibm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      7d473f47
    • Kajol Jain's avatar
      perf vendor events: Drop STORES_PER_INST metric event for power10 platform · 4836b9a8
      Kajol Jain authored
      Drop STORES_PER_INST metric event for the power10 platform, as the
      metric expression of STORES_PER_INST metric event using dropped event
      PM_ST_FIN.
      
      Fixes: 3ca3af7d ("perf vendor events power10: Add metric events JSON file for power10 platform")
      Signed-off-by: default avatarKajol Jain <kjain@linux.ibm.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Disha Goel <disgoel@linux.ibm.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: linuxppc-dev@lists.ozlabs.org
      Link: https://lore.kernel.org/r/20230814112803.1508296-3-kjain@linux.ibm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      4836b9a8
    • Kajol Jain's avatar
      perf vendor events: Drop some of the JSON/events for power10 platform · e104df97
      Kajol Jain authored
      Drop some of the JSON/events for power10 platform due to counter
      data mismatch.
      
      Fixes: 32daa5d7 ("perf vendor events: Initial JSON/events list for power10 platform")
      Signed-off-by: default avatarKajol Jain <kjain@linux.ibm.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Disha Goel <disgoel@linux.ibm.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: linuxppc-dev@lists.ozlabs.org
      Link: https://lore.kernel.org/r/20230814112803.1508296-2-kjain@linux.ibm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      e104df97
    • Kajol Jain's avatar
      perf vendor events: Update the JSON/events descriptions for power10 platform · 3286f88f
      Kajol Jain authored
      Update the description for some of the JSON/events for power10 platform.
      
      Fixes: 32daa5d7 ("perf vendor events: Initial JSON/events list for power10 platform")
      Signed-off-by: default avatarKajol Jain <kjain@linux.ibm.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Disha Goel <disgoel@linux.ibm.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: linuxppc-dev@lists.ozlabs.org
      Link: https://lore.kernel.org/r/20230814112803.1508296-1-kjain@linux.ibm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      3286f88f
    • Alexandre Ghiti's avatar
      perf tests mmap-basic: Adapt for riscv · 10da1b8e
      Alexandre Ghiti authored
      riscv now supports mmaping hardware counters to userspace so adapt the
      test to run on this architecture.
      Reviewed-by: default avatarAndrew Jones <ajones@ventanamicro.com>
      Reviewed-by: default avatarAtish Patra <atishp@rivosinc.com>
      Reviewed-by: default avatarIan Rogers <irogers@google.com>
      Signed-off-by: default avatarAlexandre Ghiti <alexghiti@rivosinc.com>
      Cc: Albert Ou <aou@eecs.berkeley.edu>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Anup Patel <anup@brainfault.org>
      Cc: Atish Patra <atishp@atishpatra.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Palmer Dabbelt <palmer@dabbelt.com>
      Cc: Paul Walmsley <paul.walmsley@sifive.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Rob Herring <robh@kernel.org>
      Cc: Rémi Denis-Courmont <remi@remlab.net>
      Cc: Will Deacon <will@kernel.org>
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: linux-doc@vger.kernel.org
      Cc: linux-riscv@lists.infradead.org
      Link: https://lore.kernel.org/r/20230802080328.1213905-11-alexghiti@rivosinc.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      10da1b8e
    • Alexandre Ghiti's avatar
      libperf: Implement riscv mmap support · 159a8bb0
      Alexandre Ghiti authored
      riscv now supports mmaping hardware counters so add what's needed to
      take advantage of that in libperf.
      Reviewed-by: default avatarAndrew Jones <ajones@ventanamicro.com>
      Reviewed-by: default avatarAtish Patra <atishp@rivosinc.com>
      Reviewed-by: default avatarIan Rogers <irogers@google.com>
      Signed-off-by: default avatarAlexandre Ghiti <alexghiti@rivosinc.com>
      Cc: Albert Ou <aou@eecs.berkeley.edu>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Anup Patel <anup@brainfault.org>
      Cc: Atish Patra <atishp@atishpatra.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Palmer Dabbelt <palmer@dabbelt.com>
      Cc: Paul Walmsley <paul.walmsley@sifive.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Rob Herring <robh@kernel.org>
      Cc: Rémi Denis-Courmont <remi@remlab.net>
      Cc: Will Deacon <will@kernel.org>
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: linux-doc@vger.kernel.org
      Cc: linux-riscv@lists.infradead.org
      Link: https://lore.kernel.org/r/20230802080328.1213905-10-alexghiti@rivosinc.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      159a8bb0
    • Leo Yan's avatar
      perf parse-regs: Move out arch specific header from util/perf_regs.h · ff382c1c
      Leo Yan authored
      util/perf_regs.h includes another perf_regs.h:
      
        #include <perf_regs.h>
      
      Here it includes architecture specific header, for example, if we build
      arm64 target, the header tools/perf/arch/arm64/include/perf_regs.h is
      included.
      
      We use this implicit way to include architecture specific header, which
      is not directive; furthermore, util/perf_regs.c is coupled with the
      architecture specific definitions.
      
      This patch moves out arch specific header from util/perf_regs.h for
      generalizing the 'util' folder, as a result, the source files in 'arch'
      folder explicitly include architecture's perf_regs.h.
      Signed-off-by: default avatarLeo Yan <leo.yan@linaro.org>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Albert Ou <aou@eecs.berkeley.edu>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Eric Lin <eric.lin@sifive.com>
      Cc: Fangrui Song <maskray@google.com>
      Cc: Guo Ren <guoren@kernel.org>
      Cc: Huacai Chen <chenhuacai@kernel.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Ivan Babrou <ivan@cloudflare.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Ming Wang <wangming01@loongson.cn>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Palmer Dabbelt <palmer@dabbelt.com>
      Cc: Paul Walmsley <paul.walmsley@sifive.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Sandipan Das <sandipan.das@amd.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: linux-csky@vger.kernel.org
      Cc: linux-riscv@lists.infradead.org
      Link: https://lore.kernel.org/r/20230606014559.21783-7-leo.yan@linaro.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      ff382c1c
    • Leo Yan's avatar
      perf parse-regs: Remove PERF_REGS_{MAX|MASK} from common code · 856caabf
      Leo Yan authored
      The macros PERF_REGS_MAX and PERF_REGS_MASK are architecture specific,
      let's remove them from the common file util/perf_regs.c.
      
      As a side effect, the weak functions arch__intr_reg_mask() and
      arch__user_reg_mask() just return zeros, every arch defines its own
      functions in the 'arch' folder for returning right values.
      
      Note, we don't need to return intr/user register masks dynamically, this
      is because these two functions are invoked during recording phase but
      not decoding phase, they are always invoked on the native environment,
      thus we don't need to parse them dynamically.
      Signed-off-by: default avatarLeo Yan <leo.yan@linaro.org>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Albert Ou <aou@eecs.berkeley.edu>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Eric Lin <eric.lin@sifive.com>
      Cc: Fangrui Song <maskray@google.com>
      Cc: Guo Ren <guoren@kernel.org>
      Cc: Huacai Chen <chenhuacai@kernel.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Ivan Babrou <ivan@cloudflare.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Ming Wang <wangming01@loongson.cn>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Palmer Dabbelt <palmer@dabbelt.com>
      Cc: Paul Walmsley <paul.walmsley@sifive.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Sandipan Das <sandipan.das@amd.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: linux-csky@vger.kernel.org
      Cc: linux-riscv@lists.infradead.org
      Link: https://lore.kernel.org/r/20230606014559.21783-6-leo.yan@linaro.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      856caabf
    • Leo Yan's avatar
      perf parse-regs: Remove unused macros PERF_REG_{IP|SP} · 6a87e0f0
      Leo Yan authored
      The macros PERF_REG_{IP|SP} have been replaced by using functions
      perf_arch_reg_{ip|sp}(), remove them!
      Signed-off-by: default avatarLeo Yan <leo.yan@linaro.org>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Albert Ou <aou@eecs.berkeley.edu>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Eric Lin <eric.lin@sifive.com>
      Cc: Fangrui Song <maskray@google.com>
      Cc: Guo Ren <guoren@kernel.org>
      Cc: Huacai Chen <chenhuacai@kernel.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Ivan Babrou <ivan@cloudflare.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Ming Wang <wangming01@loongson.cn>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Palmer Dabbelt <palmer@dabbelt.com>
      Cc: Paul Walmsley <paul.walmsley@sifive.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Sandipan Das <sandipan.das@amd.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: linux-csky@vger.kernel.org
      Cc: linux-riscv@lists.infradead.org
      Link: https://lore.kernel.org/r/20230606014559.21783-5-leo.yan@linaro.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      6a87e0f0
    • Leo Yan's avatar
      perf unwind: Use perf_arch_reg_{ip|sp}() to substitute macros · d8f69fb6
      Leo Yan authored
      We use perf_arch_reg_ip() and perf_arch_reg_sp() to substitute macros
      for obtaining the register numbers of SP and IP.  This modification
      enables cross analysis in the unwinding, therefore, the unwinding is
      not restricted to the predefined values by the macros.
      
      Consequently, the macros LIBUNWIND__ARCH_REG_{IP|SP} are removed since
      they are no longer used.
      
      Committer notes:
      
      Add missing "util/env.h" header to make sure we have the definition for
      perf_env__arch(), that when built with NO_LIBUNWIND=1 isn't available,
      i.e. it was being included by sheer luck.
      Signed-off-by: default avatarLeo Yan <leo.yan@linaro.org>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Albert Ou <aou@eecs.berkeley.edu>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Eric Lin <eric.lin@sifive.com>
      Cc: Fangrui Song <maskray@google.com>
      Cc: Guo Ren <guoren@kernel.org>
      Cc: Huacai Chen <chenhuacai@kernel.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Ivan Babrou <ivan@cloudflare.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Ming Wang <wangming01@loongson.cn>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Palmer Dabbelt <palmer@dabbelt.com>
      Cc: Paul Walmsley <paul.walmsley@sifive.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Sandipan Das <sandipan.das@amd.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: linux-csky@vger.kernel.org
      Cc: linux-riscv@lists.infradead.org
      Link: https://lore.kernel.org/r/20230606014559.21783-4-leo.yan@linaro.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      d8f69fb6
    • Leo Yan's avatar
      perf parse-regs: Introduce functions perf_arch_reg_{ip|sp}() · 34af56af
      Leo Yan authored
      The current code uses macros PERF_REG_IP and PERF_REG_SP for parsing
      registers and we build perf with these macros statically, which means it
      only can correctly analyze CPU registers for the native architecture and
      fails to support cross analysis (e.g. we build perf on x86 and cannot
      analyze Arm64's registers).
      
      We need to generalize util/perf_regs.c for support multi architectures,
      as a first step, this commit introduces new functions perf_arch_reg_ip()
      and perf_arch_reg_sp(), these two functions dynamically return IP and SP
      register index respectively according to the parameter "arch".
      
      Every architecture has its own functions (like __perf_reg_ip_arm64 and
      __perf_reg_sp_arm64), these architecture specific functions are defined
      in each arch source file under folder util/perf-regs-arch; at the end
      all of them are built into the tool for cross analysis.
      
      Committer notes:
      
      Make DWARF_MINIMAL_REGS() an inline function, so that we can use the
      __maybe_unused attribute for the 'arch' parameter, as this will avoid a
      build failure when that variable is unused in the callers. That happens
      when building on unsupported architectures, the ones without
      HAVE_PERF_REGS_SUPPORT defined.
      Signed-off-by: default avatarLeo Yan <leo.yan@linaro.org>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Albert Ou <aou@eecs.berkeley.edu>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Eric Lin <eric.lin@sifive.com>
      Cc: Fangrui Song <maskray@google.com>
      Cc: Guo Ren <guoren@kernel.org>
      Cc: Huacai Chen <chenhuacai@kernel.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Ivan Babrou <ivan@cloudflare.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Ming Wang <wangming01@loongson.cn>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Palmer Dabbelt <palmer@dabbelt.com>
      Cc: Paul Walmsley <paul.walmsley@sifive.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Sandipan Das <sandipan.das@amd.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: linux-csky@vger.kernel.org
      Cc: linux-riscv@lists.infradead.org
      Link: https://lore.kernel.org/r/20230606014559.21783-3-leo.yan@linaro.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      34af56af
    • Leo Yan's avatar
      perf parse-regs: Refactor arch register parsing functions · 5000e7f6
      Leo Yan authored
      Every architecture has a specific register parsing function for
      returning register name based on register index, to support cross
      analysis (e.g. we use perf x86 binary to parse Arm64's perf data), we
      build all these register parsing functions into the tool, this is why
      we place all related functions into util/perf_regs.c.
      
      Unfortunately, since util/perf_regs.c needs to include every arch's
      perf_regs.h, this easily introduces duplicated definitions coming from
      multiple headers, finally it's fragile for building and difficult for
      maintenance.
      
      We cannot simply move these register parsing functions into the
      corresponding 'arch' folder, the folder is only conditionally built
      based on the target architecture.
      
      Therefore, this commit creates a new folder util/perf-regs-arch/ and
      uses a dedicated source file to keep every architecture's register
      parsing function to avoid definition conflicts.
      
      This is only a refactoring, no functionality change is expected.
      
      Committer notes:
      
      Had to add util/perf-regs-arch/*.c to tools/perf/util/python-ext-sources
      to keep 'perf test python' passing.
      Signed-off-by: default avatarLeo Yan <leo.yan@linaro.org>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Albert Ou <aou@eecs.berkeley.edu>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Eric Lin <eric.lin@sifive.com>
      Cc: Fangrui Song <maskray@google.com>
      Cc: Guo Ren <guoren@kernel.org>
      Cc: Huacai Chen <chenhuacai@kernel.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Ivan Babrou <ivan@cloudflare.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Ming Wang <wangming01@loongson.cn>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Palmer Dabbelt <palmer@dabbelt.com>
      Cc: Paul Walmsley <paul.walmsley@sifive.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Sandipan Das <sandipan.das@amd.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: linux-csky@vger.kernel.org
      Cc: linux-riscv@lists.infradead.org
      Link: https://lore.kernel.org/r/20230606014559.21783-2-leo.yan@linaro.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      5000e7f6
    • Changbin Du's avatar
      perf docs: Fix format of unordered lists · a1ef3aaf
      Changbin Du authored
      Fix the format of unordered lists so the can wrap properly.
      Signed-off-by: default avatarChangbin Du <changbin.du@huawei.com>
      Acked-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20230718085242.3090797-1-changbin.du@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      a1ef3aaf
  3. 15 Aug, 2023 17 commits
    • James Clark's avatar
      perf vendor events arm64: Update scale units and descriptions of common topdown metrics · ab374400
      James Clark authored
      Metrics will be published here [1] going forwards, but they have
      slightly different scale units. To allow autogenerated metrics to be
      added more easily, update the scale units to match.
      
      The more detailed descriptions have also been taken and added to the
      common file.
      
      [1]: https://gitlab.arm.com/telemetry-solution/telemetry-solution/-/tree/main/data/pmu/cpu/Reviewed-by: default avatarJohn Garry <john.g.garry@oracle.com>
      Signed-off-by: default avatarJames Clark <james.clark@arm.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andrii Nakryiko <andrii@kernel.org>
      Cc: Eduard Zingerman <eddyz87@gmail.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jing Zhang <renyu.zj@linux.alibaba.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nick Forrington <nick.forrington@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Rob Herring <robh@kernel.org>
      Cc: Sohom Datta <sohomdatta1@gmail.com>
      Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: coresight@lists.linaro.org
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/20230811144017.491628-5-james.clark@arm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      ab374400
    • James Clark's avatar
      perf cs-etm: Don't duplicate FIELD_GET() · a4b6452a
      James Clark authored
      linux/bitfield.h can be included as long as linux/kernel.h is included
      first, so change the order of the includes and drop the duplicate macro.
      Reviewed-by: default avatarJohn Garry <john.g.garry@oracle.com>
      Signed-off-by: default avatarJames Clark <james.clark@arm.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andrii Nakryiko <andrii@kernel.org>
      Cc: Eduard Zingerman <eddyz87@gmail.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jing Zhang <renyu.zj@linux.alibaba.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nick Forrington <nick.forrington@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Rob Herring <robh@kernel.org>
      Cc: Sohom Datta <sohomdatta1@gmail.com>
      Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: coresight@lists.linaro.org
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/20230811144017.491628-2-james.clark@arm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      a4b6452a
    • Adrian Hunter's avatar
      perf dlfilter: Add al_cleanup() · 82b0a103
      Adrian Hunter authored
      Add perf_dlfilter_fns.al_cleanup() to do addr_location__exit() on data
      passed via perf_dlfilter_fns.resolve_address().
      
      Add dlfilter-test-api-v2 to the "dlfilter C API" test to test it.
      
      Update documentation, clarifying that data returned by APIs should not
      be dereferenced after filter_event() and filter_event_early() return.
      
      Fixes: 0dd5041c ("perf addr_location: Add init/exit/copy functions")
      Reviewed-by: default avatarIan Rogers <irogers@google.com>
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lore.kernel.org/r/20230731091857.10681-3-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      82b0a103
    • Arnaldo Carvalho de Melo's avatar
      perf dlfilter: Initialize addr_location before passing it to thread__find_symbol_fb() · 42c6dd9d
      Arnaldo Carvalho de Melo authored
      As thread__find_symbol_fb() will end up calling thread__find_map() and
      it in turn will call these on uninitialized memory:
      
              maps__zput(al->maps);
              map__zput(al->map);
              thread__zput(al->thread);
      
      Fixes: 0dd5041c ("perf addr_location: Add init/exit/copy functions")
      Reviewed-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Disha Goel <disgoel@linux.vnet.ibm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lore.kernel.org/r/20230731091857.10681-2-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      42c6dd9d
    • Adrian Hunter's avatar
      perf dlfilter: Add a test for resolve_address() · f178a76b
      Adrian Hunter authored
      Extend the "dlfilter C API" test to test
      perf_dlfilter_fns.resolve_address(). The test currently fails, but passes
      after a subsequent patch.
      Reviewed-by: default avatarIan Rogers <irogers@google.com>
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lore.kernel.org/r/20230731091857.10681-1-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      f178a76b
    • Wei Li's avatar
      perf scripts python: Update audit-libs package name for python3 · 41a37430
      Wei Li authored
      'audit-libs-python' is the package for python2, update it for python3.
      On Ubuntu and Fedora, the new package is 'python3-audit'.
      Signed-off-by: default avatarWei Li <liwei391@huawei.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Li Bin <huawei.libin@huawei.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20230815131805.1237491-1-liwei391@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      41a37430
    • Wei Li's avatar
      perf scripts python: Support syscall name parsing on arm64 · 708a3e8b
      Wei Li authored
      In the result of "perf script syscall-counts" on arm64, the syscall
      events are not resolved currently. Add "aarch64" to audit uname list to
      support name parsing.
      
      * After the patch:
      
        [root@localhost ~]# perf script syscall-counts sleep 1
        Press control+C to stop and show the summary
      
        syscall events:
      
        event                                          count
        ----------------------------------------  -----------
        mmap                                               6
        close                                              5
        mprotect                                           4
        brk                                                3
        newfstatat                                         3
        openat                                             3
        getrandom                                          1
        prlimit64                                          1
        munmap                                             1
        clock_nanosleep                                    1
        set_robust_list                                    1
        set_tid_address                                    1
        exit_group                                         1
        read                                               1
        faccessat                                          1
      Signed-off-by: default avatarWei Li <liwei391@huawei.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Li Bin <huawei.libin@huawei.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20230815131735.1237221-1-liwei391@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      708a3e8b
    • Yang Jihong's avatar
      perf evsel: Remove duplicate check for `field` in evsel__intval() · d095ad45
      Yang Jihong authored
      The `file` parameter in evsel__intval() is checked repeatedly, fix it.
      
      No functional change.
      Signed-off-by: default avatarYang Jihong <yangjihong1@huawei.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Sandipan Das <sandipan.das@amd.com>
      Link: https://lore.kernel.org/r/20230815221009.3641751-1-yangjihong1@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      d095ad45
    • Namhyung Kim's avatar
      perf test: Add perf record sample filtering test · 9575ecdd
      Namhyung Kim authored
        $ sudo ./perf test 'sample filter' -v
         94: perf record sample filtering (by BPF) tests                     :
        --- start ---
        test child forked, pid 3817527
        Checking BPF-filter privilege
        Basic bpf-filter test
        Basic bpf-filter test [Success]
        Failing bpf-filter test
        Error: task-clock event does not have PERF_SAMPLE_CPU
        Failing bpf-filter test [Success]
        Group bpf-filter test
        Error: task-clock event does not have PERF_SAMPLE_CPU
        Error: task-clock event does not have PERF_SAMPLE_CODE_PAGE_SIZE
        Group bpf-filter test [Success]
        test child finished with 0
        ---- end ----
        perf record sample filtering (by BPF) tests: Ok
      Reviewed-by: default avatarIan Rogers <irogers@google.com>
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20230811025822.3859771-2-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      9575ecdd
    • Namhyung Kim's avatar
      perf bpf-filter: Fix sample flag check with || · dc7f01f1
      Namhyung Kim authored
      For logical OR operator, the actual sample_flags are in the 'groups'
      list so it needs to check entries in the list instead.  Otherwise it
      would show the following error message.
      
        $ sudo perf record -a -e cycles:p --filter 'period > 100 || weight > 0' sleep 1
        Error: cycles:p event does not have sample flags 0
        failed to set filter "BPF" on event cycles:p with 2 (No such file or directory)
      
      Actually it should warn on 'weight' is used without WEIGHT flag.
      
        Error: cycles:p event does not have PERF_SAMPLE_WEIGHT
         Hint: please add -W option to perf record
        failed to set filter "BPF" on event cycles:p with 2 (No such file or directory)
      
      Fixes: 4310551b ("perf bpf filter: Show warning for missing sample flags")
      Reviewed-by: default avatarIan Rogers <irogers@google.com>
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20230811025822.3859771-1-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      dc7f01f1
    • Ian Rogers's avatar
      perf trace: Tidy comments related to BPF + syscall augmentation · cd2cece6
      Ian Rogers authored
      Now tools/perf/examples/bpf/augmented_syscalls.c is
      tools/perf/util/bpf_skel/augmented_syscalls.bpf.c and not enabled as a
      BPF event, tidy the comments to reflect this.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Andrii Nakryiko <andrii@kernel.org>
      Cc: Anshuman Khandual <anshuman.khandual@arm.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Carsten Haitzler <carsten.haitzler@arm.com>
      Cc: Eduard Zingerman <eddyz87@gmail.com>
      Cc: Fangrui Song <maskray@google.com>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Rob Herring <robh@kernel.org>
      Cc: Tiezhu Yang <yangtiezhu@loongson.cn>
      Cc: Tom Rix <trix@redhat.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Cc: Wang ShaoBo <bobo.shaobowang@huawei.com>
      Cc: Yang Jihong <yangjihong1@huawei.com>
      Cc: Yonghong Song <yhs@fb.com>
      Cc: YueHaibing <yuehaibing@huawei.com>
      Cc: bpf@vger.kernel.org
      Cc: llvm@lists.linux.dev
      Link: https://lore.kernel.org/r/20230810184853.2860737-5-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      cd2cece6
    • Ian Rogers's avatar
      perf bpf examples: With no BPF events remove examples · 5056c99e
      Ian Rogers authored
      The examples were used to give demonstrations of BPF events but such
      functionality is now subsumed by using --filter with 'perf record' or
      the direct use of BPF skeletons.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Andrii Nakryiko <andrii@kernel.org>
      Cc: Anshuman Khandual <anshuman.khandual@arm.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Carsten Haitzler <carsten.haitzler@arm.com>
      Cc: Eduard Zingerman <eddyz87@gmail.com>
      Cc: Fangrui Song <maskray@google.com>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Rob Herring <robh@kernel.org>
      Cc: Tiezhu Yang <yangtiezhu@loongson.cn>
      Cc: Tom Rix <trix@redhat.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Cc: Wang ShaoBo <bobo.shaobowang@huawei.com>
      Cc: Yang Jihong <yangjihong1@huawei.com>
      Cc: Yonghong Song <yhs@fb.com>
      Cc: YueHaibing <yuehaibing@huawei.com>
      Cc: bpf@vger.kernel.org
      Cc: llvm@lists.linux.dev
      Link: https://lore.kernel.org/r/20230810184853.2860737-4-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      5056c99e
    • Ian Rogers's avatar
      perf trace: Migrate BPF augmentation to use a skeleton · 5e6da6be
      Ian Rogers authored
      Previously a BPF event of augmented_raw_syscalls.c could be used to
      enable augmentation of syscalls by perf trace. As BPF events are no
      longer supported, switch to using a BPF skeleton which when attached
      explicitly opens the sysenter and sysexit tracepoints.
      
      The dump map is removed as debugging wasn't supported by the
      augmentation and bpf_printk can be used when necessary.
      
      Remove tools/perf/examples/bpf/augmented_raw_syscalls.c so that the
      rename/migration to a BPF skeleton captures that this was the source.
      
      Committer notes:
      
      Some minor stylistic changes to help visualizing the diff.
      
      Use libbpf_strerror when failing to load the augmented raw syscalls BPF.
      
      Use  bpf_object__for_each_program(prog, trace.skel->obj) to disable auto
      attachment for all but the sys_enter, sys_exit tracepoints, to avoid
      having to add extra lines as we go adding support for more pointer
      receiving syscalls.
      
      Committer testing:
      
        # perf trace -e open*  --max-events=10
           0.000 ( 0.022 ms): systemd-oomd/1151 openat(dfd: CWD, filename: "/proc/meminfo", flags: RDONLY|CLOEXEC)    = 11
         208.833 (         ): gnome-terminal/3223 openat(dfd: CWD, filename: "/proc/51250/cmdline")                  ...
         249.993 ( 0.024 ms): systemd-oomd/1151 openat(dfd: CWD, filename: "/proc/meminfo", flags: RDONLY|CLOEXEC)    = 11
         250.118 ( 0.030 ms): systemd-oomd/1151 openat(dfd: CWD, filename: "/sys/fs/cgroup/user.slice/user-1000.slice/user@1000.service/memory.pressure", flags: RDONLY|CLOEXEC) = 11
         250.205 ( 0.016 ms): systemd-oomd/1151 openat(dfd: CWD, filename: "/sys/fs/cgroup/user.slice/user-1000.slice/user@1000.service/memory.current", flags: RDONLY|CLOEXEC) = 11
         250.244 ( 0.014 ms): systemd-oomd/1151 openat(dfd: CWD, filename: "/sys/fs/cgroup/user.slice/user-1000.slice/user@1000.service/memory.min", flags: RDONLY|CLOEXEC) = 11
         250.282 ( 0.014 ms): systemd-oomd/1151 openat(dfd: CWD, filename: "/sys/fs/cgroup/user.slice/user-1000.slice/user@1000.service/memory.low", flags: RDONLY|CLOEXEC) = 11
         250.320 ( 0.014 ms): systemd-oomd/1151 openat(dfd: CWD, filename: "/sys/fs/cgroup/user.slice/user-1000.slice/user@1000.service/memory.swap.current", flags: RDONLY|CLOEXEC) = 11
         250.355 ( 0.014 ms): systemd-oomd/1151 openat(dfd: CWD, filename: "/sys/fs/cgroup/user.slice/user-1000.slice/user@1000.service/memory.stat", flags: RDONLY|CLOEXEC) = 11
         250.717 ( 0.016 ms): systemd-oomd/1151 openat(dfd: CWD, filename: "/sys/fs/cgroup/user.slice/user-1001.slice/user@1001.service/memory.pressure", flags: RDONLY|CLOEXEC) = 11
        #
        # perf trace -e *nanosleep*  --max-events=10
               ? (         ): SCTP timer/28304  ... [continued]: clock_nanosleep())                                  = 0
           0.007 (10.058 ms): SCTP timer/28304 clock_nanosleep(rqtp: { .tv_sec: 0, .tv_nsec: 10000000 }, rmtp: 0x7f0466b78de0) = 0
          10.069 (         ): SCTP timer/28304 clock_nanosleep(rqtp: { .tv_sec: 0, .tv_nsec: 10000000 }, rmtp: 0x7f0466b78de0) ...
          10.069 (10.056 ms): SCTP timer/28304  ... [continued]: clock_nanosleep())                                  = 0
          17.059 (         ): podman/3572 nanosleep(rqtp: 0x7fc4f4d75be0)                                    ...
          17.059 (10.061 ms): podman/3572  ... [continued]: nanosleep())                                        = 0
          20.131 (10.059 ms): SCTP timer/28304 clock_nanosleep(rqtp: { .tv_sec: 0, .tv_nsec: 10000000 }, rmtp: 0x7f0466b78de0) = 0
          30.195 (10.038 ms): SCTP timer/28304 clock_nanosleep(rqtp: { .tv_sec: 0, .tv_nsec: 10000000 }, rmtp: 0x7f0466b78de0) = 0
          40.238 (10.057 ms): SCTP timer/28304 clock_nanosleep(rqtp: { .tv_sec: 0, .tv_nsec: 10000000 }, rmtp: 0x7f0466b78de0) = 0
          50.301 (         ): SCTP timer/28304 clock_nanosleep(rqtp: { .tv_sec: 0, .tv_nsec: 10000000 }, rmtp: 0x7f0466b78de0) ...
        #
      
        # perf trace -e perf_event*  -- perf stat -e instructions,cycles,cache-misses sleep 0.1
           0.000 ( 0.011 ms): perf/51331 perf_event_open(attr_uptr: { type: 0 (PERF_TYPE_HARDWARE), size: 136, config: 0x1 (PERF_COUNT_HW_INSTRUCTIONS), sample_type: IDENTIFIER, read_format: TOTAL_TIME_ENABLED|TOTAL_TIME_RUNNING, disabled: 1, inherit: 1, enable_on_exec: 1, exclude_guest: 1 }, pid: 51332 (perf), cpu: -1, group_fd: -1, flags: FD_CLOEXEC) = 3
           0.013 ( 0.003 ms): perf/51331 perf_event_open(attr_uptr: { type: 0 (PERF_TYPE_HARDWARE), size: 136, config: 0 (PERF_COUNT_HW_CPU_CYCLES), sample_type: IDENTIFIER, read_format: TOTAL_TIME_ENABLED|TOTAL_TIME_RUNNING, disabled: 1, inherit: 1, enable_on_exec: 1, exclude_guest: 1 }, pid: 51332 (perf), cpu: -1, group_fd: -1, flags: FD_CLOEXEC) = 4
           0.017 ( 0.002 ms): perf/51331 perf_event_open(attr_uptr: { type: 0 (PERF_TYPE_HARDWARE), size: 136, config: 0x3 (PERF_COUNT_HW_CACHE_MISSES), sample_type: IDENTIFIER, read_format: TOTAL_TIME_ENABLED|TOTAL_TIME_RUNNING, disabled: 1, inherit: 1, enable_on_exec: 1, exclude_guest: 1 }, pid: 51332 (perf), cpu: -1, group_fd: -1, flags: FD_CLOEXEC) = 5
      
       Performance counter stats for 'sleep 0.1':
      
               1,495,051      instructions                     #    1.11  insn per cycle
               1,347,641      cycles
                  35,424      cache-misses
      
             0.100935279 seconds time elapsed
      
             0.000924000 seconds user
             0.000000000 seconds sys
      
        #
      
        # perf trace -e connect*  ssh localhost
             0.000 ( 0.012 ms): ssh/51346 connect(fd: 4, uservaddr: { .family: LOCAL, path: /var/lib/sss/pipes/nss }, addrlen: 110) = -1 ECONNREFUSED (Connection refused)
             0.118 ( 0.004 ms): ssh/51346 connect(fd: 6, uservaddr: { .family: LOCAL, path: /var/lib/sss/pipes/nss }, addrlen: 110) = -1 ECONNREFUSED (Connection refused)
             0.399 ( 0.007 ms): ssh/51346 connect(fd: 4, uservaddr: { .family: LOCAL, path: /var/lib/sss/pipes/nss }, addrlen: 110) = -1 ECONNREFUSED (Connection refused)
             0.426 ( 0.003 ms): ssh/51346 connect(fd: 4, uservaddr: { .family: LOCAL, path: /var/lib/sss/pipes/nss }, addrlen: 110) = -1 ECONNREFUSED (Connection refused)
             0.754 ( 0.009 ms): ssh/51346 connect(fd: 4, uservaddr: { .family: INET, port: 22, addr: 127.0.0.1 }, addrlen: 16) = 0
             0.771 ( 0.010 ms): ssh/51346 connect(fd: 4, uservaddr: { .family: INET6, port: 22, addr: ::1 }, addrlen: 28) = 0
             0.798 ( 0.053 ms): ssh/51346 connect(fd: 4, uservaddr: { .family: INET6, port: 22, addr: ::1 }, addrlen: 28) = 0
             0.870 ( 0.004 ms): ssh/51346 connect(fd: 5, uservaddr: { .family: LOCAL, path: /var/lib/sss/pipes/nss }, addrlen: 110) = -1 ECONNREFUSED (Connection refused)
             0.904 ( 0.003 ms): ssh/51346 connect(fd: 5, uservaddr: { .family: LOCAL, path: /var/lib/sss/pipes/nss }, addrlen: 110) = -1 ECONNREFUSED (Connection refused)
             0.930 ( 0.003 ms): ssh/51346 connect(fd: 5, uservaddr: { .family: LOCAL, path: /var/lib/sss/pipes/nss }, addrlen: 110) = -1 ECONNREFUSED (Connection refused)
             0.957 ( 0.003 ms): ssh/51346 connect(fd: 5, uservaddr: { .family: LOCAL, path: /var/lib/sss/pipes/nss }, addrlen: 110) = -1 ECONNREFUSED (Connection refused)
             0.981 ( 0.003 ms): ssh/51346 connect(fd: 5, uservaddr: { .family: LOCAL, path: /var/lib/sss/pipes/nss }, addrlen: 110) = -1 ECONNREFUSED (Connection refused)
             1.006 ( 0.004 ms): ssh/51346 connect(fd: 5, uservaddr: { .family: LOCAL, path: /var/lib/sss/pipes/nss }, addrlen: 110) = -1 ECONNREFUSED (Connection refused)
             1.036 ( 0.005 ms): ssh/51346 connect(fd: 5, uservaddr: { .family: LOCAL, path: /var/lib/sss/pipes/nss }, addrlen: 110) = -1 ECONNREFUSED (Connection refused)
            65.077 ( 0.022 ms): ssh/51346 connect(fd: 5, uservaddr: { .family: LOCAL, path: /var/run/.heim_org.h5l.kcm-socket }, addrlen: 110) = 0
            66.608 ( 0.014 ms): ssh/51346 connect(fd: 5, uservaddr: { .family: LOCAL, path: /var/run/.heim_org.h5l.kcm-socket }, addrlen: 110) = 0
        root@localhost's password:
        #
      
        # perf trace -e sendto*  ping -c 2 localhost
        PING localhost(localhost (::1)) 56 data bytes
        64 bytes from localhost (::1): icmp_seq=1 ttl=64 time=0.024 ms
             0.000 ( 0.011 ms): ping/51357 sendto(fd: 5, buff: 0x7ffcca35e620, len: 20, addr: { .family: NETLINK }, addr_len: 0xc) = 20
             0.135 ( 0.026 ms): ping/51357 sendto(fd: 4, buff: 0x5601398f7b20, len: 64, addr: { .family: INET6, port: 58, addr: ::1 }, addr_len: 0x1c) = 64
          1014.929 ( 0.050 ms): ping/51357 sendto(fd: 4, buff: 0x5601398f7b20, len: 64, flags: CONFIRM, addr: { .family: INET6, port: 58, addr: ::1 }, addr_len: 0x1c) = 64
        64 bytes from localhost (::1): icmp_seq=2 ttl=64 time=0.046 ms
      
        --- localhost ping statistics ---
        2 packets transmitted, 2 received, 0% packet loss, time 1015ms
        rtt min/avg/max/mdev = 0.024/0.035/0.046/0.011 ms
        #
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Andrii Nakryiko <andrii@kernel.org>
      Cc: Anshuman Khandual <anshuman.khandual@arm.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Carsten Haitzler <carsten.haitzler@arm.com>
      Cc: Eduard Zingerman <eddyz87@gmail.com>
      Cc: Fangrui Song <maskray@google.com>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Rob Herring <robh@kernel.org>
      Cc: Tiezhu Yang <yangtiezhu@loongson.cn>
      Cc: Tom Rix <trix@redhat.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Cc: Wang ShaoBo <bobo.shaobowang@huawei.com>
      Cc: Yang Jihong <yangjihong1@huawei.com>
      Cc: Yonghong Song <yhs@fb.com>
      Cc: YueHaibing <yuehaibing@huawei.com>
      Cc: bpf@vger.kernel.org
      Cc: llvm@lists.linux.dev
      Link: https://lore.kernel.org/r/20230810184853.2860737-3-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      5e6da6be
    • Ian Rogers's avatar
      perf parse-events: Remove BPF event support · 3d6dfae8
      Ian Rogers authored
      New features like the BPF --filter support in perf record have made the
      BPF event functionality somewhat redundant. As shown by commit
      fcb027c1a4f6 ("perf tools: Revert enable indices setting syntax for BPF
      map") and commit 14e4b9f4 ("perf trace: Raw augmented syscalls fix
      libbpf 1.0+ compatibility") the BPF event support hasn't been well
      maintained and it adds considerable complexity in areas like event
      parsing, not least as '/' is a separator for event modifiers as well as
      in paths.
      
      This patch removes support in the event parser for BPF events and then
      the associated functions are removed. This leads to the removal of whole
      source files like bpf-loader.c.  Removing support means that augmented
      syscalls in perf trace is broken, this will be fixed in a later commit
      adding support using BPF skeletons.
      
      The removal of BPF events causes an unused label warning from flex
      generated code, so update build to ignore it:
      
        ```
        util/parse-events-flex.c:2704:1: error: label ‘find_rule’ defined but not used [-Werror=unused-label]
        2704 | find_rule: /* we branch to this label when backing up */
        ```
      
      Committer notes:
      
      Extracted from a larger patch that was also removing the support for
      linking with libllvm and libclang, that were an alternative to using an
      external clang execution to compile the .c event source code into BPF
      bytecode.
      
      Testing it:
      
        # perf trace -e /home/acme/git/perf/tools/perf/examples/bpf/augmented_raw_syscalls.c
        event syntax error: '/home/acme/git/perf/tools/perf/examples/bpf/augmented_raw_syscalls.c'
                              \___ Bad event or PMU
      
        Unabled to find PMU or event on a PMU of 'home'
      
        Initial error:
        event syntax error: '/home/acme/git/perf/tools/perf/examples/bpf/augmented_raw_syscalls.c'
                              \___ Cannot find PMU `home'. Missing kernel support?
        Run 'perf list' for a list of valid events
      
         Usage: perf trace [<options>] [<command>]
            or: perf trace [<options>] -- <command> [<options>]
            or: perf trace record [<options>] [<command>]
            or: perf trace record [<options>] -- <command> [<options>]
      
            -e, --event <event>   event/syscall selector. use 'perf list' to list available events
        #
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Andrii Nakryiko <andrii@kernel.org>
      Cc: Anshuman Khandual <anshuman.khandual@arm.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Carsten Haitzler <carsten.haitzler@arm.com>
      Cc: Eduard Zingerman <eddyz87@gmail.com>
      Cc: Fangrui Song <maskray@google.com>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Rob Herring <robh@kernel.org>
      Cc: Tiezhu Yang <yangtiezhu@loongson.cn>
      Cc: Tom Rix <trix@redhat.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Cc: Wang ShaoBo <bobo.shaobowang@huawei.com>
      Cc: Yang Jihong <yangjihong1@huawei.com>
      Cc: Yonghong Song <yhs@fb.com>
      Cc: YueHaibing <yuehaibing@huawei.com>
      Cc: bpf@vger.kernel.org
      Cc: llvm@lists.linux.dev
      Link: https://lore.kernel.org/r/20230810184853.2860737-2-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      3d6dfae8
    • Ian Rogers's avatar
      perf bpf: Remove support for embedding clang for compiling BPF events (-e foo.c) · 56b11a21
      Ian Rogers authored
      This never was in the default build for perf, is difficult to maintain
      as it uses clang/llvm internals so ditch it, keeping, for now, the
      external compilation of .c BPF into .o bytecode and its subsequent
      loading, that is also going to be removed, do it separately to help
      bisection and to properly document what is being removed and why.
      
      Committer notes:
      
      Extracted from a larger patch and removed some leftovers, namely
      deleting these now unused feature tests:
      
          tools/build/feature/test-clang.cpp
          tools/build/feature/test-cxx.cpp
          tools/build/feature/test-llvm-version.cpp
          tools/build/feature/test-llvm.cpp
      
      Testing the use of BPF events after applying this patch:
      
      To use the external clang/llvm toolchain to compile a .c event and then
      use libbpf to load it, to get the syscalls:sys_enter_open* tracepoints
      and read the filename pointer, putting it into the ring buffer right
      after the usual tracepoint payload for 'perf trace' to then print it:
      
        [root@quaco ~]# perf trace -e /home/acme/git/perf-tools-next/tools/perf/examples/bpf/augmented_raw_syscalls.c,open* --max-events=10
           0.000 systemd-oomd/959 openat(dfd: CWD, filename: "/proc/meminfo", flags: RDONLY|CLOEXEC) = 12
           0.083 abrt-dump-jour/1453 openat(dfd: CWD, filename: "/var/log/journal/d6a97235307247e09f13f326fb607e3c/system.journal", flags: RDONLY|CLOEXEC|NONBLOCK) = 4
           0.063 abrt-dump-jour/1454 openat(dfd: CWD, filename: "/var/log/journal/d6a97235307247e09f13f326fb607e3c/system.journal", flags: RDONLY|CLOEXEC|NONBLOCK) = 4
           0.082 abrt-dump-jour/1455 openat(dfd: CWD, filename: "/var/log/journal/d6a97235307247e09f13f326fb607e3c/system.journal", flags: RDONLY|CLOEXEC|NONBLOCK) = 4
         250.124 systemd-oomd/959 openat(dfd: CWD, filename: "/proc/meminfo", flags: RDONLY|CLOEXEC) = 12
         250.521 systemd-oomd/959 openat(dfd: CWD, filename: "/sys/fs/cgroup/user.slice/user-1000.slice/user@1000.service/app.slice/memory.pressure", flags: RDONLY|CLOEXEC) = 12
         251.047 systemd-oomd/959 openat(dfd: CWD, filename: "/sys/fs/cgroup/user.slice/user-1000.slice/user@1000.service/app.slice/memory.current", flags: RDONLY|CLOEXEC) = 12
         251.162 systemd-oomd/959 openat(dfd: CWD, filename: "/sys/fs/cgroup/user.slice/user-1000.slice/user@1000.service/app.slice/memory.min", flags: RDONLY|CLOEXEC) = 12
         251.242 systemd-oomd/959 openat(dfd: CWD, filename: "/sys/fs/cgroup/user.slice/user-1000.slice/user@1000.service/app.slice/memory.low", flags: RDONLY|CLOEXEC) = 12
         251.353 systemd-oomd/959 openat(dfd: CWD, filename: "/sys/fs/cgroup/user.slice/user-1000.slice/user@1000.service/app.slice/memory.swap.current", flags: RDONLY|CLOEXEC) = 12
        [root@quaco ~]#
      
      Same thing, but with a prebuilt .o BPF bytecode:
      
        [root@quaco ~]# perf trace -e /home/acme/git/perf-tools-next/tools/perf/examples/bpf/augmented_raw_syscalls.o,open* --max-events=10
           0.000 systemd-oomd/959 openat(dfd: CWD, filename: "/proc/meminfo", flags: RDONLY|CLOEXEC) = 12
           0.083 abrt-dump-jour/1453 openat(dfd: CWD, filename: "/var/log/journal/d6a97235307247e09f13f326fb607e3c/system.journal", flags: RDONLY|CLOEXEC|NONBLOCK) = 4
           0.083 abrt-dump-jour/1455 openat(dfd: CWD, filename: "/var/log/journal/d6a97235307247e09f13f326fb607e3c/system.journal", flags: RDONLY|CLOEXEC|NONBLOCK) = 4
           0.062 abrt-dump-jour/1454 openat(dfd: CWD, filename: "/var/log/journal/d6a97235307247e09f13f326fb607e3c/system.journal", flags: RDONLY|CLOEXEC|NONBLOCK) = 4
         249.985 systemd-oomd/959 openat(dfd: CWD, filename: "/proc/meminfo", flags: RDONLY|CLOEXEC) = 12
         466.763 thermald/1234 openat(dfd: CWD, filename: "/sys/class/powercap/intel-rapl/intel-rapl:0/intel-rapl:0:2/energy_uj") = 13
         467.145 thermald/1234 openat(dfd: CWD, filename: "/sys/class/powercap/intel-rapl/intel-rapl:0/energy_uj") = 13
         467.311 thermald/1234 openat(dfd: CWD, filename: "/sys/class/thermal/thermal_zone2/temp") = 13
         500.040 cgroupify/24006 openat(dfd: 4, filename: ".", flags: RDONLY|CLOEXEC|DIRECTORY|NONBLOCK) = 5
         500.295 cgroupify/24006 openat(dfd: 4, filename: "24616/cgroup.procs") = 5
        [root@quaco ~]#
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Andrii Nakryiko <andrii@kernel.org>
      Cc: Anshuman Khandual <anshuman.khandual@arm.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Carsten Haitzler <carsten.haitzler@arm.com>
      Cc: Eduard Zingerman <eddyz87@gmail.com>
      Cc: Fangrui Song <maskray@google.com>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Rob Herring <robh@kernel.org>
      Cc: Tiezhu Yang <yangtiezhu@loongson.cn>
      Cc: Tom Rix <trix@redhat.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Cc: Wang ShaoBo <bobo.shaobowang@huawei.com>
      Cc: Yang Jihong <yangjihong1@huawei.com>
      Cc: Yonghong Song <yhs@fb.com>
      Cc: YueHaibing <yuehaibing@huawei.com>
      Link: https://lore.kernel.org/lkml/ZNZWsAXg2px1sm2h@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      56b11a21
    • Arnaldo Carvalho de Melo's avatar
      perf tests trace+probe_vfs_getname.sh: Accept quotes surrounding the filename · 6f769c34
      Arnaldo Carvalho de Melo authored
      With augmented_raw_syscalls transformed into a BPF skel made the output have a "
      around the filenames, which is not what the old perf probe vfs_getname
      method of obtaining filenames did, so accept the augmented way, with the
      quotes.
      
      At this point probably removing all the logic for the vfs_getname method
      is in order, will do it at some point.
      
      For now lets accept with/without quotes and make that test pass.
      
      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/lkml/Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      6f769c34
    • Arnaldo Carvalho de Melo's avatar
      perf test trace+probe_vfs_getname.sh: Remove stray \ before / · 7777ac3d
      Arnaldo Carvalho de Melo authored
      Running on fedora:38 in verbose mode I noticed:
      
        # perf test -v 117
        grep: warning: stray \ before /
        117: Check open filename arg using perf trace + vfs_getname          :
      
      Remove that \ before /.
      
      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/lkml/ZNvTDsSMO3nw9Tnp@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      7777ac3d