1. 27 Nov, 2023 9 commits
    • zhaimingbing's avatar
      perf lock: Fix a memory leak on an error path · 4a18ab46
      zhaimingbing authored
      if a strdup-ed string is NULL,the allocated memory needs freeing.
      Signed-off-by: default avatarzhaimingbing <zhaimingbing@cmss.chinamobile.com>
      Acked-by: default avatarIngo Molnar <mingo@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Li Dong <lidong@vivo.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Sean Christopherson <seanjc@google.com>
      Link: https://lore.kernel.org/r/20231124092657.10392-1-zhaimingbing@cmss.chinamobile.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      4a18ab46
    • Ian Rogers's avatar
      perf parse-events: Make legacy events lower priority than sysfs/JSON · a24d9d9d
      Ian Rogers authored
      The perf tool has previously made legacy events the priority so with
      or without a PMU the legacy event would be opened:
      
        $ perf stat -e cpu-cycles,cpu/cpu-cycles/ true
        Using CPUID GenuineIntel-6-8D-1
        intel_pt default config: tsc,mtc,mtc_period=3,psb_period=3,pt,branch
        Attempting to add event pmu 'cpu' with 'cpu-cycles,' that may result in non-fatal errors
        After aliases, add event pmu 'cpu' with 'cpu-cycles,' that may result in non-fatal errors
        Control descriptor is not initialized
        ------------------------------------------------------------
        perf_event_attr:
          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
        ------------------------------------------------------------
        sys_perf_event_open: pid 833967  cpu -1  group_fd -1  flags 0x8 = 3
        ------------------------------------------------------------
        perf_event_attr:
          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
        ------------------------------------------------------------
        ...
      
      Fixes to make hybrid/BIG.little PMUs behave correctly, ie as core PMUs
      capable of opening legacy events on each, removing hard coded "cpu_core"
      and "cpu_atom" Intel PMU names, etc. caused a behavioral difference on
      Apple/ARM due to latent issues in the PMU driver reported in:
      https://lore.kernel.org/lkml/08f1f185-e259-4014-9ca4-6411d5c1bc65@marcan.st/
      
      As part of that report Mark Rutland <mark.rutland@arm.com> requested
      that legacy events not be higher in priority when a PMU is specified
      reversing what has until this change been perf's default behavior. With
      this change the above becomes:
      
        $ perf stat -e cpu-cycles,cpu/cpu-cycles/ true
        Using CPUID GenuineIntel-6-8D-1
        Attempt to add: cpu/cpu-cycles=0/
        ..after resolving event: cpu/event=0x3c/
        Control descriptor is not initialized
        ------------------------------------------------------------
        perf_event_attr:
          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
        ------------------------------------------------------------
        sys_perf_event_open: pid 827628  cpu -1  group_fd -1  flags 0x8 = 3
        ------------------------------------------------------------
        perf_event_attr:
          type                             4 (PERF_TYPE_RAW)
          size                             136
          config                           0x3c
          sample_type                      IDENTIFIER
          read_format                      TOTAL_TIME_ENABLED|TOTAL_TIME_RUNNING
          disabled                         1
          inherit                          1
          enable_on_exec                   1
          exclude_guest                    1
        ------------------------------------------------------------
        ...
      
      So the second event has become a raw event as
      /sys/devices/cpu/events/cpu-cycles exists.
      
      A fix was necessary to config_term_pmu in parse-events.c as check_alias
      expansion needs to happen after config_term_pmu, and config_term_pmu may
      need calling a second time because of this.
      
      config_term_pmu is updated to not use the legacy event when the PMU has
      such a named event (either from JSON or sysfs).
      
      The bulk of this change is updating all of the parse-events test
      expectations so that if a sysfs/JSON event exists for a PMU the test
      doesn't fail - a further sign, if it were needed, that the legacy event
      priority was a known and tested behavior of the perf tool.
      Reported-by: default avatarHector Martin <marcan@marcan.st>
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Tested-by: default avatarHector Martin <marcan@marcan.st>
      Tested-by: default avatarMarc Zyngier <maz@kernel.org>
      Acked-by: default avatarMark Rutland <mark.rutland@arm.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.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: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20231123042922.834425-1-irogers@google.com
      [ Initialize the 'alias_rewrote_terms' variable to false to address a clang warning ]
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      a24d9d9d
    • Leo Yan's avatar
      perf cs-etm: Enable itrace option 'T' · a4271827
      Leo Yan authored
      Prior to Armv8.4, the feature FEAT_TRF is not supported by Arm CPUs.
      Consequently, the sysfs node 'ts_source' will not be set as 1 by the
      CoreSight ETM driver.  On the other hand, the perf tool relies on the
      'ts_source' node to determine whether the kernel timestamp is traced.
      Since the 'ts_source' is not set for Arm CPUs prior to Armv8.4,
      platforms in this case cannot utilize the traced timestamp as the kernel
      time.
      
      This patch enables the 'T' itrace option, which forcibly utilizes the
      traced timestamp as the kernel time.  If users are aware that their
      working platform's Arm CoreSight shares the same counter with the kernel
      time, they can specify 'T' option to decode the traced timestamp as the
      kernel time.
      
      An usage example is:
      
        # perf record -e cs_etm// -- test_program
        # perf script --itrace=i10ibT
        # perf report --itrace=i10ibT
      Reviewed-by: default avatarJames Clark <james.clark@arm.com>
      Signed-off-by: default avatarLeo Yan <leo.yan@linaro.org>
      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: John Garry <john.g.garry@oracle.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      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/20231014074513.1668000-3-leo.yan@linaro.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      a4271827
    • Leo Yan's avatar
      perf auxtrace: Add 'T' itrace option for timestamp trace · 26218331
      Leo Yan authored
      An AUX trace can contain timestamp, but in some situations, the hardware
      trace module (e.g. Arm CoreSight) cannot decide the traced timestamp is
      the same source with CPU's time, thus the decoder can not use the
      timestamp trace for samples.
      
      This patch introduces 'T' itrace option. If users know the platforms
      they are working on have the same time counter with CPUs, users can
      use this new option to tell a decoder for using timestamp trace as
      kernel time.
      Signed-off-by: default avatarLeo Yan <leo.yan@linaro.org>
      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: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      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/20231014074513.1668000-2-leo.yan@linaro.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      26218331
    • James Clark's avatar
      perf cs-etm: Bump minimum OpenCSD version to ensure a bugfix is present · 2dbba30f
      James Clark authored
      Since commit d927ef50 ("perf cs-etm: Add exception level consistency
      check"), the exception that was added to Perf will be triggered unless
      the following bugfix from OpenCSD is present:
      
       - _Version 1.2.1_:
        - __Bugfix__:
          ETM4x / ETE - output of context elements to client can in some
          circumstances be delayed until after subsequent atoms have been
          processed leading to incorrect memory decode access via the client
          callbacks. Fixed to flush context elements immediately they are
          committed.
      
      Rather than remove the assert and silently fail, just increase the
      minimum version requirement to avoid hard to debug issues and
      regressions.
      Reviewed-by: default avatarIan Rogers <irogers@google.com>
      Signed-off-by: default avatarJames Clark <james.clark@arm.com>
      Tested-by: default avatarLeo Yan <leo.yan@linaro.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/20230901133716.677499-1-james.clark@arm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      2dbba30f
    • Kan Liang's avatar
      perf test: Basic branch counter support · 69757962
      Kan Liang authored
      Add a basic test for the branch counter feature.
      
      The test verifies that
      - The new filter can be successfully applied on the supported platforms.
      - The counter value can be outputted via the perf report -D
      Signed-off-by: default avatarKan Liang <kan.liang@linux.intel.com>
      Tested-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Tinghao Zhang <tinghao.zhang@intel.com>
      Link: https://lore.kernel.org/r/20231107184020.1497571-1-kan.liang@linux.intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      69757962
    • zhaimingbing's avatar
      perf script perl: Fail check on dynamic allocation · cd38d6b5
      zhaimingbing authored
      Return ENOMEM when dynamic allocation failed.
      Reviewed-by: default avatarIan Rogers <irogers@google.com>
      Signed-off-by: default avatarzhaimingbing <zhaimingbing@cmss.chinamobile.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Li Dong <lidong@vivo.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Sean Christopherson <seanjc@google.com>
      Link: https://lore.kernel.org/r/20231120112356.8652-1-zhaimingbing@cmss.chinamobile.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      cd38d6b5
    • Paran Lee's avatar
      perf script python: Fail check on dynamic allocation · b457c526
      Paran Lee authored
      Add PyList_New() Fail check in get_field_numeric_entry()
      function and dynamic allocation checking for
      set_regs_in_dict(), python_start_script().
      Reviewed-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Reviewed-by: default avatarMichelleJin <shjy180909@gmail.com>
      Signed-off-by: default avatarParan Lee <p4ranlee@gmail.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Austin Kim <austindh.kim@gmail.com>
      Cc: Honggyu Kim <honggyu.kp@gmail.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Li Dong <lidong@vivo.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Sean Christopherson <seanjc@google.com>
      Link: https://lore.kernel.org/r/20231120223218.9036-1-p4ranlee@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      b457c526
    • Nick Forrington's avatar
      perf test: Remove atomics from test_loop to avoid test failures · 72b4ca7e
      Nick Forrington authored
      The current use of atomics can lead to test failures, as tests (such as
      tests/shell/record.sh) search for samples with "test_loop" as the
      top-most stack frame, but find frames related to the atomic operation
      (e.g. __aarch64_ldadd4_relax).
      
      This change simply removes the "count" variable, as it is not necessary.
      
      Fixes: 1962ab6f ("perf test workload thloop: Make count increments atomic")
      Reviewed-by: default avatarJames Clark <james.clark@arm.com>
      Signed-off-by: default avatarNick Forrington <nick.forrington@arm.com>
      Acked-by: default avatarLeo Yan <leo.yan@linaro.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lore.kernel.org/r/20231102162225.50028-1-nick.forrington@arm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      72b4ca7e
  2. 23 Nov, 2023 1 commit
    • Benjamin Gray's avatar
      perf tools: Address python 3.6 DeprecationWarning for string scapes · 280b4e4a
      Benjamin Gray authored
      Python 3.6 introduced a DeprecationWarning for invalid escape sequences.
      This is upgraded to a SyntaxWarning in Python 3.12, and will eventually
      be a syntax error.
      
      Fix these now to get ahead of it before it's an error.
      Signed-off-by: default avatarBenjamin Gray <bgray@linux.ibm.com>
      Acked-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andrii Nakryiko <andrii@kernel.org>
      Cc: Hartley Sweeten <hsweeten@visionengravers.com>
      Cc: Ian Abbott <abbotti@mev.co.uk>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jan Kiszka <jan.kiszka@siemens.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: Kieran Bingham <kbingham@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mykola Lysenko <mykolal@fb.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Shuah Khan <shuah@kernel.org>
      Cc: Todd E Brandt <todd.e.brandt@linux.intel.com>
      Cc: Tom Rix <trix@redhat.com>
      Cc: linux-doc@vger.kernel.org
      Cc: linux-ia64@vger.kernel.org
      Cc: linux-kselftest@vger.kernel.org
      Cc: linux-pm@vger.kernel.org
      Cc: llvm@lists.linux.dev
      Link: https://lore.kernel.org/r/20230912060801.95533-6-bgray@linux.ibm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      280b4e4a
  3. 15 Nov, 2023 2 commits
    • Ji Sheng Teoh's avatar
      perf vendor events riscv: Add StarFive Dubhe-80 JSON file · acbf6de6
      Ji Sheng Teoh authored
      StarFive's Dubhe-80 supports raw event id 0x00 - 0x22.  The raw events
      are enabled through PMU node of DT binding.  Besides raw event, add
      standard RISC-V firmware events to support monitoring of firmware event.
      
      Example of PMU DT node:
      
        pmu {
        	compatible = "riscv,pmu";
        	riscv,raw-event-to-mhpmcounters =
        		/* Event ID 1-31 */
        		<0x00 0x00 0xFFFFFFFF 0xFFFFFFE0 0x00007FF8>,
        		/* Event ID 32-33 */
        		<0x00 0x20 0xFFFFFFFF 0xFFFFFFFE 0x00007FF8>,
        		/* Event ID 34 */
        		<0x00 0x22 0xFFFFFFFF 0xFFFFFF22 0x00007FF8>;
        };
      
      Example of 'perf stat' output:
      
        [root@user]# perf stat -a \
        	-e access_mmu_stlb \
        	-e miss_mmu_stlb \
        	-e access_mmu_pte_c \
        	-e rob_flush \
        	-e btb_prediction_miss \
        	-e itlb_miss \
        	-e sync_del_fetch_g \
        	-e icache_miss \
        	-e bpu_br_retire \
        	-e bpu_br_miss \
        	-e ret_ins_retire \
        	-e ret_ins_miss \
        	-- openssl speed rsa2048
      
        Doing 2048 bits private rsa's for 10s: 39 2048 bits private RSA's in
        10.14s
        Doing 2048 bits public rsa's for 10s: 1563 2048 bits public RSA's in
        10.00s
        version: 3.0.11
        built on: Tue Sep 19 13:02:31 2023 UTC
        options: bn(64,64)
        CPUINFO: N/A
                          sign    verify    sign/s verify/s
        rsa 2048 bits 0.260000s 0.006398s      3.8    156.3
      
         Performance counter stats for 'system wide':
      
                   1338350      access_mmu_stlb
                   1154025      miss_mmu_stlb
                   1162691      access_mmu_pte_c
                     34067      rob_flush
                  11212384      btb_prediction_miss
                   1256242      itlb_miss
                 652523491      sync_del_fetch_g
                    384465      icache_miss
                  64635789      bpu_br_retire
                    323440      bpu_br_miss
                   8785143      ret_ins_retire
                     31236      ret_ins_miss
      
              20.760822480 seconds time elapsed
      Reviewed-by: default avatarIan Rogers <irogers@google.com>
      Signed-off-by: default avatarJi Sheng Teoh <jisheng.teoh@starfivetech.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Albert Ou <aou@eecs.berkeley.edu>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Ley Foon Tan <leyfoon.tan@starfivetech.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nikita Shubin <n.shubin@yadro.com>
      Cc: Palmer Dabbelt <palmer@dabbelt.com>
      Cc: Paul Walmsley <paul.walmsley@sifive.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: linux-riscv@lists.infradead.org
      Link: https://lore.kernel.org/r/20231103082441.1389842-1-jisheng.teoh@starfivetech.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      acbf6de6
    • Thomas Richter's avatar
      perf report: Add s390 raw data interpretation for PAI counters · b539deaf
      Thomas Richter authored
      Commit 39d62336 ("s390/pai: add support for cryptography
      counters") added support for Processor Activity Instrumentation Facility
      (PAI) counters.  These counters values are added as raw data with the
      perf sample during 'perf record'.
      
      Now add support to display these counters in the 'perf report' command.
      
      The counter number, its assigned name and value is now printed in
      addition to the hexadecimal output.
      
      Output before:
      
        # perf report -D
      
        6 514766399626050 0x7b058 [0x48]: PERF_RECORD_SAMPLE(IP, 0x1):
       				303977/303977: 0 period: 1 addr: 0
        ... thread: paitest:303977
        ...... dso: <not found>
      
        0x7b0a0@/root/perf.data.paicrypto [0x48]: event: 9
        .
        . ... raw event: size 72 bytes
        . 0000:  00 00 00 09 00 01 00 48 00 00 00 00 00 00 00 00  .......H........
        . 0010:  00 04 a3 69 00 04 a3 69 00 01 d4 2d 76 de a0 bb  ...i...i...-v...
        . 0020:  00 00 00 00 00 01 5c 53 00 00 00 06 00 00 00 00  ......\S........
        . 0030:  00 00 00 00 00 00 00 01 00 00 00 0c 00 07 00 00  ................
        . 0040:  00 00 00 53 96 af 00 00                          ...S....
      
      Output after:
      
        # perf report -D
      
        6 514766399626050 0x7b058 [0x48]: PERF_RECORD_SAMPLE(IP, 0x1):
       				303977/303977: 0 period: 1 addr: 0
        ... thread: paitest:303977
        ...... dso: <not found>
      
        0x7b0a0@/root/perf.data.paicrypto [0x48]: event: 9
        .
        . ... raw event: size 72 bytes
        . 0000:  00 00 00 09 00 01 00 48 00 00 00 00 00 00 00 00  .......H........
        . 0010:  00 04 a3 69 00 04 a3 69 00 01 d4 2d 76 de a0 bb  ...i...i...-v...
        . 0020:  00 00 00 00 00 01 5c 53 00 00 00 06 00 00 00 00  ......\S........
        . 0030:  00 00 00 00 00 00 00 01 00 00 00 0c 00 07 00 00  ................
        . 0040:  00 00 00 53 96 af 00 00                          ...S....
      
              Counter:007 km_aes_128 Value:0x00000000005396af     <--- new
      
      Committer notes:
      
      Had to add ignore pragmas for that __packed function:
      
        +#pragma GCC diagnostic ignored "-Wpacked"
        +#pragma GCC diagnostic ignored "-Wattributes"
      
      Otherwise this doesn't build in things like debian experimentao cross
      building to mips64, etc.
      Signed-off-by: default avatarThomas Richter <tmricht@linux.ibm.com>
      Tested-by: default avatarSumanth Korikkar <sumanthk@linux.ibm.com>
      Acked-by: default avatarSumanth Korikkar <sumanthk@linux.ibm.com>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Sven Schnelle <svens@linux.ibm.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Link: https://lore.kernel.org/r/20231110110908.2312308-1-tmricht@linux.ibm.com
      [ Corrected non-existent commit referred to the right one: 39d62336 ]
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      b539deaf
  4. 10 Nov, 2023 10 commits
  5. 09 Nov, 2023 17 commits
    • Arnaldo Carvalho de Melo's avatar
      tools: Disable __packed attribute compiler warning due to -Werror=attributes · a399ee67
      Arnaldo Carvalho de Melo authored
      Noticed on several perf tools cross build test containers:
      
        [perfbuilder@five ~]$ grep FAIL ~/dm.log/summary
          19    10.18 debian:experimental-x-mips    : FAIL gcc version 12.3.0 (Debian 12.3.0-6)
          20    11.21 debian:experimental-x-mips64  : FAIL gcc version 12.3.0 (Debian 12.3.0-6)
          21    11.30 debian:experimental-x-mipsel  : FAIL gcc version 12.3.0 (Debian 12.3.0-6)
          37    12.07 ubuntu:18.04-x-arm            : FAIL gcc version 7.5.0 (Ubuntu/Linaro 7.5.0-3ubuntu1~18.04)
          42    11.91 ubuntu:18.04-x-riscv64        : FAIL gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04)
          44    13.17 ubuntu:18.04-x-sh4            : FAIL gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04)
          45    12.09 ubuntu:18.04-x-sparc64        : FAIL gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04)
        [perfbuilder@five ~]$
      
        In file included from util/intel-pt-decoder/intel-pt-pkt-decoder.c:10:
        /tmp/perf-6.6.0-rc1/tools/include/asm-generic/unaligned.h: In function 'get_unaligned_le16':
        /tmp/perf-6.6.0-rc1/tools/include/asm-generic/unaligned.h:13:29: error: packed attribute causes inefficient alignment for 'x' [-Werror=attributes]
           13 |         const struct { type x; } __packed *__pptr = (typeof(__pptr))(ptr);      \
              |                             ^
        /tmp/perf-6.6.0-rc1/tools/include/asm-generic/unaligned.h:27:28: note: in expansion of macro '__get_unaligned_t'
           27 |         return le16_to_cpu(__get_unaligned_t(__le16, p));
              |                            ^~~~~~~~~~~~~~~~~
      
      This comes from the kernel, where the -Wattributes and -Wpacked isn't
      used, -Wpacked is already disabled, do it for the attributes as well.
      
      Fixes: a91c9872 ("perf tools: Add get_unaligned_leNN()")
      Suggested-by: default avatarAdrian 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/7c5b626c-1de9-4c12-a781-e44985b4a797@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      a399ee67
    • Ian Rogers's avatar
      perf bpf: Don't synthesize BPF events when disabled · 6512b6aa
      Ian Rogers authored
      If BPF sideband events are disabled on the command line, don't
      synthesize BPF events too.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Acked-by: default avatarSong Liu <song@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: Athira Jajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Changbin Du <changbin.du@huawei.com>
      Cc: Colin Ian King <colin.i.king@gmail.com>
      Cc: Dmitrii Dolgov <9erthalion6@gmail.com>
      Cc: German Gomez <german.gomez@arm.com>
      Cc: Huacai Chen <chenhuacai@kernel.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: K Prateek Nayak <kprateek.nayak@amd.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Li Dong <lidong@vivo.com>
      Cc: Liam Howlett <liam.howlett@oracle.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Miguel Ojeda <ojeda@kernel.org>
      Cc: Ming Wang <wangming01@loongson.cn>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nick Terrell <terrelln@fb.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Sandipan Das <sandipan.das@amd.com>
      Cc: Sean Christopherson <seanjc@google.com>
      Cc: Steinar H. Gunderson <sesse@google.com>
      Cc: Vincent Whitchurch <vincent.whitchurch@axis.com>
      Cc: Wenyu Liu <liuwenyu7@huawei.com>
      Cc: Yang Jihong <yangjihong1@huawei.com>
      Link: https://lore.kernel.org/r/20231102175735.2272696-13-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      6512b6aa
    • James Clark's avatar
      perf test: Add support for setting objdump binary via perf config · 6aad765d
      James Clark authored
      Add a 'perf config' variable that does the same thing as "perf test
      --objdump <x>".
      
      Also update the man page.
      
      Committer testing:
      
        # perf config test.objdump
        # perf test "object code reading"
         26: Object code reading                                             : Ok
        # perf config test.objdump=blah
        # perf config test.objdump
        test.objdump=blah
        # perf test "object code reading"
         26: Object code reading                                             : FAILED!
        # perf test -v "object code reading"
         26: Object code reading                                             :
        --- start ---
        test child forked, pid 600599
        Looking at the vmlinux_path (8 entries long)
        Using /proc/kcore for kernel data
        Using /proc/kallsyms for symbols
        Parsing event 'cycles'
        Using CPUID AuthenticAMD-25-21-0
        mmap size 528384B
        Reading object code for memory address: 0x4d9a02
        File is: /home/acme/bin/perf
        On file address is: 0xd9a02
        Objdump command is: blah -z -d --start-address=0x4d9a02 --stop-address=0x4d9a82 /home/acme/bin/perf
        objdump read too few bytes: 128
        Bytes read differ from those read by objdump
        buf1 (dso):
        0x48 0x85 0xff 0x74 0x29 0xe8 0x94 0xdf 0x07 0x00 0x8b 0x73 0x1c 0x48 0x8b 0x43
        0x08 0xeb 0xa5 0x0f 0x1f 0x00 0x48 0x8b 0x45 0xe8 0x64 0x48 0x2b 0x04 0x25 0x28
        0x00 0x00 0x00 0x75 0x0f 0x48 0x8b 0x5d 0xf8 0xc9 0xc3 0x0f 0x1f 0x00 0x48 0x8b
        0x43 0x08 0xeb 0x84 0xe8 0xc5 0x3e 0xf3 0xff 0x0f 0x1f 0x44 0x00 0x00 0x55 0x48
        0x89 0xe5 0x41 0x56 0x41 0x55 0x49 0x89 0xd5 0x41 0x54 0x49 0x89 0xfc 0x53 0x48
        0x89 0xf3 0x48 0x83 0xec 0x30 0x48 0x8b 0x7e 0x20 0x64 0x48 0x8b 0x04 0x25 0x28
        0x00 0x00 0x00 0x48 0x89 0x45 0xd8 0x31 0xc0 0x48 0x89 0x75 0xb0 0x48 0xc7 0x45
        0xb8 0x00 0x00 0x00 0x00 0x48 0xc7 0x45 0xc0 0x00 0x00 0x00 0x00 0xe8 0xad 0xfa
      
        buf2 (objdump):
        0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
        0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
        0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
        0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
        0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
        0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
        0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
        0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
      
        test child finished with -1
        ---- end ----
        Object code reading: FAILED!
        # perf config test.objdump=/usr/bin/objdump
        # perf config test.objdump
        test.objdump=/usr/bin/objdump
        # perf test "object code reading"
         26: Object code reading                                             : Ok
        #
      Signed-off-by: default avatarJames Clark <james.clark@arm.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: Athira Jajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Fangrui Song <maskray@google.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: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Tom Rix <trix@redhat.com>
      Cc: Yang Jihong <yangjihong1@huawei.com>
      Cc: Yonghong Song <yhs@fb.com>
      Cc: llvm@lists.linux.dev
      Link: https://lore.kernel.org/r/20231106151051.129440-3-james.clark@arm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      6aad765d
    • James Clark's avatar
      perf test: Add option to change objdump binary · 33ce9fc4
      James Clark authored
      All of the other Perf subcommands that use objdump have an option to
      specify the binary, so add the same option to 'perf test'.
      
      This is useful if you have built the kernel with a different toolchain
      to the system one, where the system objdump may fail to disassemble
      vmlinux.
      
      Now this can be fixed with something like this:
      
        $ perf test --objdump llvm-objdump "object code reading"
      Reviewed-by: default avatarIan Rogers <irogers@google.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: Athira Jajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Fangrui Song <maskray@google.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Tom Rix <trix@redhat.com>
      Cc: Yang Jihong <yangjihong1@huawei.com>
      Cc: llvm@lists.linux.dev
      Link: https://lore.kernel.org/r/20231106151051.129440-2-james.clark@arm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      33ce9fc4
    • Thomas Richter's avatar
      perf tests offcpu: Adjust test case perf record offcpu profiling tests for s390 · b861fd7e
      Thomas Richter authored
      On s390 using linux-next the test case:
      
          87: perf record offcpu profiling tests
      
      fails. The root cause is this command
      
        # ./perf  record --off-cpu -e dummy -- ./perf bench sched messaging -l 10
        # Running 'sched/messaging' benchmark:
        # 20 sender and receiver processes per group
        # 10 groups == 400 processes run
      
           Total time: 0.231 [sec]
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.077 MB perf.data (401 samples) ]
        #
      
      It does not generate 800+ sample entries, on s390 usually around
      40[1-9], sometimes a few more, but never more than 450. The higher the
      number of CPUs the lower the number of samples.
      
      Looking at function chain:
      
        bench_sched_messaging()
        +--> group()
      
      the senders and receiver threads are created. The senders and receivers
      call function ready() which writes one bytes and wait for a reply using
      poll system() call.
      
      As context switches are counted, the function ready() will trigger a
      context switch when no input data is available after the write system
      call. The write system call does not trigger context switches when the
      data size is small. And writing 1000 bytes (10 iterations with
      100 bytes) is not much and certainly won't block.
      
      The 400+ context switch on s390 occur when the some receiver/sender
      threads call ready() and wait for the response from function
      bench_sched_messaging() being kicked off.
      
      Lower the number of expected context switches to 400 to succeed on s390.
      Suggested-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Signed-off-by: default avatarIlya Leoshkevich <iii@linux.ibm.com>
      Signed-off-by: default avatarThomas Richter <tmricht@linux.ibm.com>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Sumanth Korikkar <sumanthk@linux.ibm.com>
      Cc: Sven Schnelle <svens@linux.ibm.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Co-developed-by: default avatarIlya Leoshkevich <iii@linux.ibm.com>
      Link: https://lore.kernel.org/r/20231106091627.2022530-1-tmricht@linux.ibm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      b861fd7e
    • Yang Jihong's avatar
      perf tools: Add the python_ext_build directory to .gitignore · 36c70e44
      Yang Jihong authored
      `python_ext_build` is the build directory for python.so, ignore it for
      cleaner git status.
      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: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20231030111438.1357962-2-yangjihong1@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      36c70e44
    • zhaimingbing's avatar
      perf tests attr: Fix spelling mistake "whic" to "which" · 4a5aaaf3
      zhaimingbing authored
      There is a spelling mistake, Please fix it.
      Reviewed-by: default avatarIan Rogers <irogers@google.com>
      Signed-off-by: default avatarzhaimingbing <zhaimingbing@cmss.chinamobile.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: kernel-janitors@vger.kernel.org
      Link: https://lore.kernel.org/r/20231030075825.3701-1-zhaimingbing@cmss.chinamobile.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      4a5aaaf3
    • Namhyung Kim's avatar
      perf annotate: Move offsets array from 'struct annotation' to 'struct annotated_source' · b753d48f
      Namhyung Kim authored
      The offsets array keeps pointers to 'struct annotation_line' entries
      which are available in the 'struct annotated_source'.  Let's move it to
      there.
      Reviewed-by: default avatarIan Rogers <irogers@google.com>
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20231103191907.54531-6-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      b753d48f
    • Namhyung Kim's avatar
      perf annotate: Move some source code related fields from 'struct annotation'... · 0aae4c99
      Namhyung Kim authored
      perf annotate: Move some source code related fields from 'struct annotation' to 'struct annotated_source'
      
      Some fields in the 'struct annotation' are only used with 'struct
      annotated_source' so better to be moved there in order to reduce memory
      consumption for other symbols.
      Reviewed-by: default avatarIan Rogers <irogers@google.com>
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20231103191907.54531-5-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      0aae4c99
    • Namhyung Kim's avatar
      perf annotate: Move max_coverage from 'struct annotation' to 'struct annotated_branch' · 2b215ec7
      Namhyung Kim authored
      The max_coverage field is only used when branch stack info is available
      so it'd be natural to move to 'struct annotated_branch'.
      Reviewed-by: default avatarIan Rogers <irogers@google.com>
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20231103191907.54531-4-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      2b215ec7
    • Namhyung Kim's avatar
      perf annotate: Split branch stack cycles info from 'struct annotation' · b7f87e32
      Namhyung Kim authored
      The cycles info is only meaningful when sample has branch stacks.  To
      save the memory for normal cases, move those fields to a new 'struct
      annotated_branch' and dynamically allocate it when needed.  Also move
      cycles_hist from annotated_source as it's related here.
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
      Cc: Ian Rogers <irogers@google.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/20231103191907.54531-3-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      b7f87e32
    • Namhyung Kim's avatar
      perf annotate: Split branch stack cycles information out of 'struct annotation_line' · de2c7eb5
      Namhyung Kim authored
      The cycles info is used only when branch stack is provided.  Separate
      them from 'struct annotation_line' into a separate struct and lazy
      allocate them to save some memory.
      
      Committer notes:
      
      Make annotation__compute_ipc() check if the lazy allocation works,
      bailing out if so, its callers already do error checking and
      propagation.
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
      Cc: Ian Rogers <irogers@google.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/20231103191907.54531-2-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      de2c7eb5
    • Namhyung Kim's avatar
      perf test: Simplify "object code reading" test · 89d5c48c
      Namhyung Kim authored
      It tries cycles (or cpu-clock on s390) event with exclude_kernel bit to
      open.  But other arch on a VM can fail with the hardware event and need
      to fallback to the software event in the same way.
      
      So let's get rid of the cpuid check and use generic fallback mechanism
      using an array of event candidates.  Now event in the odd index excludes
      the kernel so use that for the return value.
      Reviewed-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Tested-by: default avatarJames Clark <james.clark@arm.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Richter <tmricht@linux.ibm.com>
      Link: https://lore.kernel.org/r/20231103195541.67788-1-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      89d5c48c
    • Ian Rogers's avatar
      perf machine thread: Remove exited threads by default · 9ffa6c75
      Ian Rogers authored
      'struct thread' values hold onto references to mmaps, DSOs, etc. When a
      thread exits it is necessary to clean all of this memory up by removing
      the thread from the machine's threads. Some tools require this doesn't
      happen, such as auxtrace events, 'perf report' if offcpu events exist or
      if a task list is being generated, so add a 'struct symbol_conf' member
      to make the behavior optional. When an exited thread is left in the
      machine's threads, mark it as exited.
      
      This change relates to commit 40826c45 ("perf thread: Remove
      notion of dead threads") . Dead threads were removed as they had a
      reference count of 0 and were difficult to reason about with the
      reference count checker. Here a thread is removed from threads when it
      exits, unless via symbol_conf the exited thread isn't remove and is
      marked as exited. Reference counting behaves as it normally does.
      Reviewed-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Athira Jajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Changbin Du <changbin.du@huawei.com>
      Cc: Colin Ian King <colin.i.king@gmail.com>
      Cc: Dmitrii Dolgov <9erthalion6@gmail.com>
      Cc: German Gomez <german.gomez@arm.com>
      Cc: Huacai Chen <chenhuacai@kernel.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: K Prateek Nayak <kprateek.nayak@amd.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Li Dong <lidong@vivo.com>
      Cc: Liam Howlett <liam.howlett@oracle.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Miguel Ojeda <ojeda@kernel.org>
      Cc: Ming Wang <wangming01@loongson.cn>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nick Terrell <terrelln@fb.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Sandipan Das <sandipan.das@amd.com>
      Cc: Sean Christopherson <seanjc@google.com>
      Cc: Steinar H. Gunderson <sesse@google.com>
      Cc: Vincent Whitchurch <vincent.whitchurch@axis.com>
      Cc: Wenyu Liu <liuwenyu7@huawei.com>
      Cc: Yang Jihong <yangjihong1@huawei.com>
      Link: https://lore.kernel.org/r/20231102175735.2272696-6-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      9ffa6c75
    • Ian Rogers's avatar
      perf record: Lazy load kernel symbols · 1a27fc01
      Ian Rogers authored
      Commit 5b7ba82a ("perf symbols: Load kernel maps before using")
      changed it so that loading a kernel DSO would cause the symbols for the
      DSO to be eagerly loaded.
      
      For 'perf record' this is overhead as the symbols won't be used. Add a
      field to 'struct symbol_conf' to control the behavior and disable it for
      'perf record' and 'perf inject'.
      Reviewed-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Athira Jajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Changbin Du <changbin.du@huawei.com>
      Cc: Colin Ian King <colin.i.king@gmail.com>
      Cc: Dmitrii Dolgov <9erthalion6@gmail.com>
      Cc: German Gomez <german.gomez@arm.com>
      Cc: Huacai Chen <chenhuacai@kernel.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: K Prateek Nayak <kprateek.nayak@amd.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Li Dong <lidong@vivo.com>
      Cc: Liam Howlett <liam.howlett@oracle.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Miguel Ojeda <ojeda@kernel.org>
      Cc: Ming Wang <wangming01@loongson.cn>
      Cc: Nick Terrell <terrelln@fb.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Sandipan Das <sandipan.das@amd.com>
      Cc: Sean Christopherson <seanjc@google.com>
      Cc: Steinar H. Gunderson <sesse@google.com>
      Cc: Vincent Whitchurch <vincent.whitchurch@axis.com>
      Cc: Wenyu Liu <liuwenyu7@huawei.com>
      Cc: Yang Jihong <yangjihong1@huawei.com>
      Link: https://lore.kernel.org/r/20231102175735.2272696-3-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      1a27fc01
    • Colin Ian King's avatar
      perf tools: Fix spelling mistake "parametrized" -> "parameterized" · 7ff7b7af
      Colin Ian King authored
      There are spelling mistakes in comments and a pr_debug message. Fix them.
      Reviewed-by: default avatarAthira Jajeev <atrajeev@linux.vnet.ibm.com>
      Reviewed-by: default avatarIan Rogers <irogers@google.com>
      Signed-off-by: default avatarColin Ian King <colin.i.king@gmail.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: kernel-janitors@vger.kernel.org
      Link: https://lore.kernel.org/r/20231003074911.220216-1-colin.i.king@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      7ff7b7af
    • Kan Liang's avatar
      perf tools: Add branch counter knob · 9fbb4b02
      Kan Liang authored
      Add a new branch filter, "counter", for the branch counter option. It is
      used to mark the events which should be logged in the branch. If it is
      applied with the -j option, the counters of all the events should be
      logged in the branch. If the legacy kernel doesn't support the new
      branch sample type, switching off the branch counter filter.
      
      The stored counter values in each branch are displayed right after the
      regular branch stack information via perf report -D.
      
      Usage examples:
      
        # perf record -e "{branch-instructions,branch-misses}:S" -j any,counter
      
      Only the first event, branch-instructions, collect the LBR. Both
      branch-instructions and branch-misses are marked as logged events.  The
      occurrences information of them can be found in the branch stack
      extension space of each branch.
      
        # perf record -e "{cpu/branch-instructions,branch_type=any/,cpu/branch-misses,branch_type=counter/}"
      
      Only the first event, branch-instructions, collect the LBR. Only the
      branch-misses event is marked as a logged event.
      
      Committer notes:
      
      I noticed 'perf test "Sample parsing"' failing, reported to the list and
      Kan provided a patch that checks if the evsel has a leader and that
      evsel->evlist is set, the comment in the source code further explains
      it.
      Reviewed-by: default avatarIan Rogers <irogers@google.com>
      Signed-off-by: default avatarKan Liang <kan.liang@linux.intel.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Bayduraev <alexey.v.bayduraev@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.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>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Tinghao Zhang <tinghao.zhang@intel.com>
      Link: https://lore.kernel.org/r/20231025201626.3000228-8-kan.liang@linux.intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      9fbb4b02
  6. 06 Nov, 2023 1 commit