1. 23 6月, 2020 25 次提交
    • A
      perf evlist: Fix the class prefix for 'struct evlist' sample_type methods · b3c2cc2b
      Arnaldo Carvalho de Melo 提交于
      To differentiate from libperf's 'struct perf_evlist' methods.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      b3c2cc2b
    • A
      perf evlist: Fix the class prefix for 'struct evlist' strerror methods · d1f249ec
      Arnaldo Carvalho de Melo 提交于
      To differentiate from libperf's 'struct perf_evlist' methods.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      d1f249ec
    • A
      perf evlist: Fix the class prefix for 'struct evlist' 'add' evsel methods · e251abee
      Arnaldo Carvalho de Melo 提交于
      To differentiate from libperf's 'struct perf_evlist' methods.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      e251abee
    • J
      perf pmu: Improve CPU core PMU HW event list ordering · ce0dc7d2
      John Garry 提交于
      For perf list, the CPU core PMU HW event ordering is such that not all
      events may will be listed adjacent - consider this example:
      
        $ tools/perf/perf list
      
        List of pre-defined events (to be used in -e):
      
          duration_time                                      [Tool event]
      
          branch-instructions OR cpu/branch-instructions/    [Kernel PMU event]
          branch-misses OR cpu/branch-misses/                [Kernel PMU event]
          bus-cycles OR cpu/bus-cycles/                      [Kernel PMU event]
          cache-misses OR cpu/cache-misses/                  [Kernel PMU event]
          cache-references OR cpu/cache-references/          [Kernel PMU event]
          cpu-cycles OR cpu/cpu-cycles/                      [Kernel PMU event]
          cstate_core/c3-residency/                          [Kernel PMU event]
          cstate_core/c6-residency/                          [Kernel PMU event]
          cstate_core/c7-residency/                          [Kernel PMU event]
          cstate_pkg/c2-residency/                           [Kernel PMU event]
          cstate_pkg/c3-residency/                           [Kernel PMU event]
          cstate_pkg/c6-residency/                           [Kernel PMU event]
          cstate_pkg/c7-residency/                           [Kernel PMU event]
          cycles-ct OR cpu/cycles-ct/                        [Kernel PMU event]
          cycles-t OR cpu/cycles-t/                          [Kernel PMU event]
          el-abort OR cpu/el-abort/                          [Kernel PMU event]
          el-capacity OR cpu/el-capacity/                    [Kernel PMU event]
      
      Notice in the above example how the cstate_core PMU events are mixed in
      the middle of the CPU core events.
      
      For my arm64 platform, all the uncore events get mixed in, making the list
      very disorganised:
      
          page-faults OR faults                              [Software event]
          task-clock                                         [Software event]
          duration_time                                      [Tool event]
          L1-dcache-load-misses                              [Hardware cache event]
          L1-dcache-loads                                    [Hardware cache event]
          L1-icache-load-misses                              [Hardware cache event]
          L1-icache-loads                                    [Hardware cache event]
          branch-load-misses                                 [Hardware cache event]
          branch-loads                                       [Hardware cache event]
          dTLB-load-misses                                   [Hardware cache event]
          dTLB-loads                                         [Hardware cache event]
          iTLB-load-misses                                   [Hardware cache event]
          iTLB-loads                                         [Hardware cache event]
          br_mis_pred OR armv8_pmuv3_0/br_mis_pred/          [Kernel PMU event]
          br_mis_pred_retired OR armv8_pmuv3_0/br_mis_pred_retired/ [Kernel PMU event]
          br_pred OR armv8_pmuv3_0/br_pred/                  [Kernel PMU event]
          br_retired OR armv8_pmuv3_0/br_retired/            [Kernel PMU event]
          br_return_retired OR armv8_pmuv3_0/br_return_retired/ [Kernel PMU event]
          bus_access OR armv8_pmuv3_0/bus_access/            [Kernel PMU event]
          bus_cycles OR armv8_pmuv3_0/bus_cycles/            [Kernel PMU event]
          cid_write_retired OR armv8_pmuv3_0/cid_write_retired/ [Kernel PMU event]
          cpu_cycles OR armv8_pmuv3_0/cpu_cycles/            [Kernel PMU event]
          dtlb_walk OR armv8_pmuv3_0/dtlb_walk/              [Kernel PMU event]
          exc_return OR armv8_pmuv3_0/exc_return/            [Kernel PMU event]
          exc_taken OR armv8_pmuv3_0/exc_taken/              [Kernel PMU event]
          hisi_sccl1_ddrc0/act_cmd/                          [Kernel PMU event]
          hisi_sccl1_ddrc0/flux_rcmd/                        [Kernel PMU event]
          hisi_sccl1_ddrc0/flux_rd/                          [Kernel PMU event]
          hisi_sccl1_ddrc0/flux_wcmd/                        [Kernel PMU event]
          hisi_sccl1_ddrc0/flux_wr/                          [Kernel PMU event]
          hisi_sccl1_ddrc0/pre_cmd/                          [Kernel PMU event]
          hisi_sccl1_ddrc0/rnk_chg/                          [Kernel PMU event]
      
      ...
      
          hisi_sccl7_l3c21/wr_hit_cpipe/                     [Kernel PMU event]
          hisi_sccl7_l3c21/wr_hit_spipe/                     [Kernel PMU event]
          hisi_sccl7_l3c21/wr_spipe/                         [Kernel PMU event]
          inst_retired OR armv8_pmuv3_0/inst_retired/        [Kernel PMU event]
          inst_spec OR armv8_pmuv3_0/inst_spec/              [Kernel PMU event]
          itlb_walk OR armv8_pmuv3_0/itlb_walk/              [Kernel PMU event]
          l1d_cache OR armv8_pmuv3_0/l1d_cache/              [Kernel PMU event]
          l1d_cache_refill OR armv8_pmuv3_0/l1d_cache_refill/ [Kernel PMU event]
          l1d_cache_wb OR armv8_pmuv3_0/l1d_cache_wb/        [Kernel PMU event]
          l1d_tlb OR armv8_pmuv3_0/l1d_tlb/                  [Kernel PMU event]
          l1d_tlb_refill OR armv8_pmuv3_0/l1d_tlb_refill/    [Kernel PMU event]
      
      So the events are list alphabetically. However, CPU core event listing is
      special from commit dc098b35 ("perf list: List kernel supplied event
      aliases"), in that the alias and full event is shown (in that order).
      As such, the core events may become sparse.
      
      Improve this by grouping the CPU core events and ensure that they are
      listed first for kernel PMU events. For the first example, above, this
      now looks like:
      
          duration_time                                      [Tool event]
          branch-instructions OR cpu/branch-instructions/    [Kernel PMU event]
          branch-misses OR cpu/branch-misses/                [Kernel PMU event]
          bus-cycles OR cpu/bus-cycles/                      [Kernel PMU event]
          cache-misses OR cpu/cache-misses/                  [Kernel PMU event]
          cache-references OR cpu/cache-references/          [Kernel PMU event]
          cpu-cycles OR cpu/cpu-cycles/                      [Kernel PMU event]
          cycles-ct OR cpu/cycles-ct/                        [Kernel PMU event]
          cycles-t OR cpu/cycles-t/                          [Kernel PMU event]
          el-abort OR cpu/el-abort/                          [Kernel PMU event]
          el-capacity OR cpu/el-capacity/                    [Kernel PMU event]
          el-commit OR cpu/el-commit/                        [Kernel PMU event]
          el-conflict OR cpu/el-conflict/                    [Kernel PMU event]
          el-start OR cpu/el-start/                          [Kernel PMU event]
          instructions OR cpu/instructions/                  [Kernel PMU event]
          mem-loads OR cpu/mem-loads/                        [Kernel PMU event]
          mem-stores OR cpu/mem-stores/                      [Kernel PMU event]
          ref-cycles OR cpu/ref-cycles/                      [Kernel PMU event]
          topdown-fetch-bubbles OR cpu/topdown-fetch-bubbles/ [Kernel PMU event]
          topdown-recovery-bubbles OR cpu/topdown-recovery-bubbles/ [Kernel PMU event]
          topdown-slots-issued OR cpu/topdown-slots-issued/  [Kernel PMU event]
          topdown-slots-retired OR cpu/topdown-slots-retired/ [Kernel PMU event]
          topdown-total-slots OR cpu/topdown-total-slots/    [Kernel PMU event]
          tx-abort OR cpu/tx-abort/                          [Kernel PMU event]
          tx-capacity OR cpu/tx-capacity/                    [Kernel PMU event]
          tx-commit OR cpu/tx-commit/                        [Kernel PMU event]
          tx-conflict OR cpu/tx-conflict/                    [Kernel PMU event]
          tx-start OR cpu/tx-start/                          [Kernel PMU event]
          cstate_core/c3-residency/                          [Kernel PMU event]
          cstate_core/c6-residency/                          [Kernel PMU event]
          cstate_core/c7-residency/                          [Kernel PMU event]
          cstate_pkg/c2-residency/                           [Kernel PMU event]
          cstate_pkg/c3-residency/                           [Kernel PMU event]
          cstate_pkg/c6-residency/                           [Kernel PMU event]
          cstate_pkg/c7-residency/                           [Kernel PMU event]
      Signed-off-by: NJohn Garry <john.garry@huawei.com>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Acked-by: NNamhyung Kim <namhyung@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: linuxarm@huawei.com
      Link: http://lore.kernel.org/lkml/1592384514-119954-3-git-send-email-john.garry@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      ce0dc7d2
    • J
      perf pmu: List kernel supplied event aliases for arm64 · c1b4745b
      John Garry 提交于
      In commit dc098b35 ("perf list: List kernel supplied event aliases"),
      the aliases for events are supplied in addition to CPU event in perf list.
      
      This relies on the name of the core PMU being "cpu", which is not the case
      for arm64, so arm64 has always missed this. Use generic is_pmu_core()
      helper which takes account of arm64 to make this feature work for arm64
      (and possibly other archs).
      
      Sample, before:
      
        armv8_pmuv3_0/br_mis_pred/          [Kernel PMU event]
      
      after:
      
        br_mis_pred OR armv8_pmuv3_0/br_mis_pred/          [Kernel PMU event]
      Signed-off-by: NJohn Garry <john.garry@huawei.com>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Acked-by: NNamhyung Kim <namhyung@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: linuxarm@huawei.com
      Link: http://lore.kernel.org/lkml/1592384514-119954-2-git-send-email-john.garry@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      c1b4745b
    • M
      perf cs-etm: Allow no CoreSight sink to be specified on command line · 47446212
      Mike Leach 提交于
      Adjust the handling of the session sink selection to allow no sink to be
      selected on the command line. This then forwards the sink selection to
      the CoreSight infrastructure which will attempt to select a sink based
      on the default sink select priorities.
      Signed-off-by: NMike Leach <mike.leach@linaro.org>
      Tested-by: NLeo Yan <leo.yan@linaro.org>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: coresight@lists.linaro.org
      Cc: linux-arm-kernel@lists.infradead.org
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      47446212
    • I
      perf expr: Add < and > operators · ff1a12f9
      Ian Rogers 提交于
      These are broadly useful but required to handle TMA metrics. For example
      encoding Ports_Utilization from:
      
        https://download.01.org/perfmon/TMA_Metrics.csv
      
      requires '<'.
      
        {
          "BriefDescription": "This metric estimates fraction of cycles the CPU performance was potentially limited due to Core computation issues (non divider-related).  Two distinct categories can be attributed into this metric: (1) heavy data-dependency among contiguous instructions would manifest in this metric - such cases are often referred to as low Instruction Level Parallelism (ILP). (2) Contention on some hardware execution unit other than Divider. For example; when there are too many multiply operations.",
          "MetricExpr": "( ( cpu@EXE_ACTIVITY.EXE_BOUND_0_PORTS@ + cpu@EXE_ACTIVITY.1_PORTS_UTIL@ + ( cpu@EXE_ACTIVITY.2_PORTS_UTIL@ * ( ( ( cpu@UOPS_RETIRED.RETIRE_SLOTS@ ) / ( cpu@CPU_CLK_UNHALTED.THREAD@ ) ) / ( ( 4.000000 ) + 1.000000 ) ) ) ) / ( cpu@CPU_CLK_UNHALTED.THREAD@ ) if ( cpu@ARITH.DIVIDER_ACTIVE\\,cmask\\=1@ < cpu@EXE_ACTIVITY.EXE_BOUND_0_PORTS@ ) else ( ( cpu@EXE_ACTIVITY.EXE_BOUND_0_PORTS@ + cpu@EXE_ACTIVITY.1_PORTS_UTIL@ + ( cpu@EXE_ACTIVITY.2_PORTS_UTIL@ * ( ( ( cpu@UOPS_RETIRED.RETIRE_SLOTS@ ) / ( cpu@CPU_CLK_UNHALTED.THREAD@ ) ) / ( ( 4.000000 ) + 1.000000 ) ) ) ) - cpu@EXE_ACTIVITY.EXE_BOUND_0_PORTS@ ) / ( cpu@CPU_CLK_UNHALTED.THREAD@ ) )",
          "MetricGroup": "Topdown_Group_Ports_Utilization",
          "MetricName": "Topdown_Metric_Ports_Utilization"
        },
      Signed-off-by: NIan Rogers <irogers@google.com>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Clarke <pc@us.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20200610235823.52557-2-irogers@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      ff1a12f9
    • I
      perf expr: Add d_ratio operation · 3e21a28a
      Ian Rogers 提交于
      d_ratio avoids division by 0 yielding infinity, such as when a counter
      doesn't get scheduled. An example usage is:
      
        {
            "BriefDescription": "DCache L1 misses",
            "MetricExpr": "d_ratio(MEM_LOAD_RETIRED.L1_MISS, MEM_LOAD_RETIRED.L1_HIT + MEM_LOAD_RETIRED.L1_MISS + MEM_LOAD_RETIRED.FB_HIT)",
            "MetricGroup": "DCache;DCache_L1",
            "MetricName": "DCache_L1_Miss",
            "ScaleUnit": "100%",
        }
      Signed-off-by: NIan Rogers <irogers@google.com>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Clarke <pc@us.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20200610235823.52557-1-irogers@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      3e21a28a
    • A
      perf script: Fixup some evsel/evlist method names · afdd63f5
      Arnaldo Carvalho de Melo 提交于
      Fixups related to the introduction of libperf, where the
      perf_{evsel,evlist}__ prefix is reserved for functions operating on
      struct perf_{evsel,evlist}.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      afdd63f5
    • J
      perf tests: Add parse metric test for frontend metric · 218ca91d
      Jiri Olsa 提交于
      Adding new metric test for frontend metric. It's stolen from x86 pmu
      events.
      
      Committer testing:
      
        # perf test "Parse and process metrics"
        67: Parse and process metrics                             : Ok
        # perf test -v "Parse and process metrics"
        #
        67: Parse and process metrics                             :
        --- start ---
        test child forked, pid 104881
        metric expr inst_retired.any / cpu_clk_unhalted.thread for IPC
        found event inst_retired.any
        found event cpu_clk_unhalted.thread
        adding {inst_retired.any,cpu_clk_unhalted.thread}:W
        metric expr idq_uops_not_delivered.core / (4 * (( ( cpu_clk_unhalted.thread / 2 ) * ( 1 + cpu_clk_unhalted.one_thread_active / cpu_clk_unhalted.ref_xclk ) ))) for Frontend_Bound_SMT
        found event cpu_clk_unhalted.one_thread_active
        found event cpu_clk_unhalted.ref_xclk
        found event idq_uops_not_delivered.core
        found event cpu_clk_unhalted.thread
        adding {cpu_clk_unhalted.one_thread_active,cpu_clk_unhalted.ref_xclk,idq_uops_not_delivered.core,cpu_clk_unhalted.thread}:W
        test child finished with 0
        ---- end ----
        Parse and process metrics: Ok
        #
      
      Had to fix it to initialize that 'struct value' array sentinel with a
      named initializer to fix the build with some versions of clang:
      
        tests/parse-metric.c:154:7: error: missing field 'val' initializer [-Werror,-Wmissing-field-initializers]
                      { 0 },
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Acked-by: NIan Rogers <irogers@google.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20200602214741.1218986-14-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      218ca91d
    • J
      perf tests: Add parse metric test for ipc metric · 0a507af9
      Jiri Olsa 提交于
      Adding new test that process metrics code and checks the expected
      results. Starting with easy ipc metric.
      
      Committer testing:
      
        # perf test "Parse and process metrics"
        67: Parse and process metrics                             : Ok
        #
        # perf test -v "Parse and process metrics"
        67: Parse and process metrics                             :
        --- start ---
        test child forked, pid 103402
        metric expr inst_retired.any / cpu_clk_unhalted.thread for IPC
        found event inst_retired.any
        found event cpu_clk_unhalted.thread
        adding {inst_retired.any,cpu_clk_unhalted.thread}:W
        test child finished with 0
        ---- end ----
        Parse and process metrics: Ok
        #
      
      Had to fix it to initialize that 'struct value' array sentinel with a
      named initializer to fix the build with some versions of clang:
      
        tests/parse-metric.c:135:7: error: missing field 'val' initializer [-Werror,-Wmissing-field-initializers]
                      { 0 },
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Acked-by: NIan Rogers <irogers@google.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20200602214741.1218986-13-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      0a507af9
    • J
      perf tools: Add test_generic_metric function · 6d432c4c
      Jiri Olsa 提交于
      Adding test_generic_metric that prepares and runs given metric over the
      data from struct runtime_stat object.
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Acked-by: NIan Rogers <irogers@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20200602214741.1218986-12-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      6d432c4c
    • J
      perf tools: Release metric_events rblist · 9afe5658
      Jiri Olsa 提交于
      We don't release metric_events rblist, add the missing delete hook and
      call the release before leaving cmd_stat.
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Acked-by: NIan Rogers <irogers@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20200602214741.1218986-11-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      9afe5658
    • J
      perf tools: Factor out prepare_metric function · 2cfaa853
      Jiri Olsa 提交于
      Factoring out prepare_metric function so it can be used in test
      interface coming in following changes.
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Acked-by: NIan Rogers <irogers@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20200602214741.1218986-10-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      2cfaa853
    • J
      perf tools: Add metricgroup__parse_groups_test function · f78ac00a
      Jiri Olsa 提交于
      Add the metricgroup__parse_groups_test function. It will be used as
      test's interface to metric parsing in following changes.
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Acked-by: NIan Rogers <irogers@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20200602214741.1218986-9-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      f78ac00a
    • J
      perf tools: Add map to parse_groups() function · 1381396b
      Jiri Olsa 提交于
      For testing purposes we need to pass our own map of events from
      parse_groups() through metricgroup__add_metric.
      Acked-by: NIan Rogers <irogers@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20200602214741.1218986-8-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      1381396b
    • J
      perf tools: Add fake_pmu to parse_group() function · 68173bda
      Jiri Olsa 提交于
      Allow to pass fake_pmu in parse_groups function so it can be used in
      parse_events call.
      
      It's will be passed by the upcoming metricgroup__parse_groups_test
      function.
      
      Committer notes:
      
      Made it a 'struct perf_pmu' pointer, in line with the changes at the
      start of this patchkit to avoid statics deep down in library code.
      Acked-by: NIan Rogers <irogers@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20200602214741.1218986-6-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      68173bda
    • J
      perf parse: Factor out parse_groups() function · 8b4468a2
      Jiri Olsa 提交于
      Factor out the parse_groups function, it will be used for new test
      interface coming in following changes.
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Acked-by: NIan Rogers <irogers@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20200602214741.1218986-6-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      8b4468a2
    • J
      perf tests: Add another metric parsing test · e1c92a7f
      Jiri Olsa 提交于
      The test goes through all metrics compiled for arch within pmu events
      and try to parse them.
      
      This test is different from 'test_parsing' in that we go through all the
      events in the current arch, not just one defined for current CPU model.
      Using 'fake_pmu' to parse events which do not have PMUs defined in the
      system.
      
      Say there's bad change in ivybridge metrics file, like:
      
        - a/tools/perf/pmu-events/arch/x86/ivybridge/ivb-metrics.json
        + b/tools/perf/pmu-events/arch/x86/ivybridge/ivb-metrics.json
        @@ -8,7 +8,7 @@
        -        "MetricExpr": "IDQ_UOPS_NOT_DELIVERED.CORE / (4 * ((
        +        "MetricExpr": "IDQ_UOPS_NOT_DELIVERED.CORE / / (4 *
      
      the test fails with (on my kabylake laptop):
      
        $ perf test 'Parsing of PMU event table metrics with fake PMUs' -v
        parsing 'idq_uops_not_delivered.core / / (4 * (( ( cpu_clk_unh...
        syntax error, line 1
        expr__parse failed
        test child finished with -1
        ...
      
      The test also defines its own list of metrics and tries to parse them.
      It's handy for developing.
      
      Committer notes:
      
      Testing it:
      
        $ perf test fake
        10: PMU events                                            :
        10.4: Parsing of PMU event table metrics with fake PMUs   : FAILED!
        $ perf test -v fake |& tail
        parsing '(unc_p_freq_trans_cycles / unc_p_clockticks) * 100.'
        parsing '(unc_m_power_channel_ppd / unc_m_clockticks) * 100.'
        parsing '(unc_m_power_critical_throttle_cycles / unc_m_clockticks) * 100.'
        parsing '(unc_m_power_self_refresh / unc_m_clockticks) * 100.'
        parsing 'idq_uops_not_delivered.core / * (4 * cycles)'
        syntax error
        expr__parse failed
        test child finished with -1
        ---- end ----
        PMU events subtest 4: FAILED!
        $
      
      And fix this error:
      
        tests/pmu-events.c:437:40: error: missing field 'idx' initializer [-Werror,-Wmissing-field-initializers]
              struct parse_events_error error = { 0 };
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20200602214741.1218986-5-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      e1c92a7f
    • A
      perf pmu: Add a perf_pmu__fake object to use with __parse_events() · e46fc8d9
      Arnaldo Carvalho de Melo 提交于
      When wanting to use the support in __parse_events() for fake pmus, just
      pass it.
      
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      e46fc8d9
    • A
      perf parse: Provide a way to pass a fake_pmu to parse_events() · 3bf91aa5
      Arnaldo Carvalho de Melo 提交于
      This is an alternative patch to what Jiri sent that instead of changing
      all callers to parse_events() for allowing to pass a fake_pmu, provide
      another function specifically for that.
      
      From Jiri's patch:
      
      This way it's possible to parse events from PMUs which are not present
      in the system. It's available only for testing purposes coming in
      following changes, so all the current users set fake_pmu argument as
      false.
      Based-on-a-patch-by: NJiri Olsa <jolsa@kernel.org>
      Link: http://lore.kernel.org/lkml/20200602214741.1218986-3-jolsa@kernel.orgAcked-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Stephane Eranian <eranian@google.com>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      3bf91aa5
    • J
      perf tests: Factor check_parse_id function · 34bacc95
      Jiri Olsa 提交于
      Separating the generic part of check_parse_id function,
      so it can be used in following changes for the new test.
      
      Committer notes:
      
      Fix this error:
      
        tests/pmu-events.c:413:40: error: missing field 'idx' initializer [-Werror,-Wmissing-field-initializers]
              struct parse_events_error error = { 0 };
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Acked-by: NIan Rogers <irogers@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20200602214741.1218986-4-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      34bacc95
    • J
      perf tools: Add fake pmu support · 387ad33f
      Jiri Olsa 提交于
      Add a way to create a pmu event without the actual PMU being in place.
      
      This way we can test metrics defined for any processor.
      
      The interface is to define fake_pmu in struct parse_events_state data.
      It will be used only in tests via special interface function added in
      following changes.
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Acked-by: NIan Rogers <irogers@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20200602214741.1218986-2-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      387ad33f
    • J
      perf annotate: Remove unneeded conversion to bool · a1f8bc95
      Jason Yan 提交于
      The '>' expression itself is bool, no need to convert it to bool again.
      This fixes the following coccicheck warning:
      
        tools/perf/ui/browsers/annotate.c:212:30-35: WARNING: conversion to bool
        not needed here
      Signed-off-by: NJason Yan <yanaijie@huawei.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lore.kernel.org/lkml/20200420123528.11655-1-yanaijie@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      a1f8bc95
    • A
      perf flamegraph: Explicitly set utf-8 encoding · c42ad5d4
      Andreas Gerstmayr 提交于
      On some platforms the default encoding is not utf-8, which causes an
      UnicodeDecodeError when reading the flamegraph template and writing the
      flamegraph
      Signed-off-by: NAndreas Gerstmayr <agerstmayr@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lore.kernel.org/lkml/20200619153232.203537-1-agerstmayr@redhat.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      c42ad5d4
  2. 18 6月, 2020 2 次提交
    • T
      perf build: Fix error message when asking for -fsanitize=address without required libraries · 6a1515c9
      Tiezhu Yang 提交于
      When build perf with ASan or UBSan, if libasan or libubsan can not find,
      the feature-glibc is 0 and there exists the following error log which is
      wrong, because we can find gnu/libc-version.h in /usr/include,
      glibc-devel is also installed.
      
        [yangtiezhu@linux perf]$ make DEBUG=1 EXTRA_CFLAGS='-fno-omit-frame-pointer -fsanitize=address'
          BUILD:   Doing 'make -j4' parallel build
          HOSTCC   fixdep.o
          HOSTLD   fixdep-in.o
          LINK     fixdep
        <stdin>:1:0: warning: -fsanitize=address and -fsanitize=kernel-address are not supported for this target
        <stdin>:1:0: warning: -fsanitize=address not supported for this target
      
        Auto-detecting system features:
        ...                         dwarf: [ OFF ]
        ...            dwarf_getlocations: [ OFF ]
        ...                         glibc: [ OFF ]
        ...                          gtk2: [ OFF ]
        ...                      libaudit: [ OFF ]
        ...                        libbfd: [ OFF ]
        ...                        libcap: [ OFF ]
        ...                        libelf: [ OFF ]
        ...                       libnuma: [ OFF ]
        ...        numa_num_possible_cpus: [ OFF ]
        ...                       libperl: [ OFF ]
        ...                     libpython: [ OFF ]
        ...                     libcrypto: [ OFF ]
        ...                     libunwind: [ OFF ]
        ...            libdw-dwarf-unwind: [ OFF ]
        ...                          zlib: [ OFF ]
        ...                          lzma: [ OFF ]
        ...                     get_cpuid: [ OFF ]
        ...                           bpf: [ OFF ]
        ...                        libaio: [ OFF ]
        ...                       libzstd: [ OFF ]
        ...        disassembler-four-args: [ OFF ]
      
        Makefile.config:393: *** No gnu/libc-version.h found, please install glibc-dev[el].  Stop.
        Makefile.perf:224: recipe for target 'sub-make' failed
        make[1]: *** [sub-make] Error 2
        Makefile:69: recipe for target 'all' failed
        make: *** [all] Error 2
        [yangtiezhu@linux perf]$ ls /usr/include/gnu/libc-version.h
        /usr/include/gnu/libc-version.h
      
      After install libasan and libubsan, the feature-glibc is 1 and the build
      process is success, so the cause is related with libasan or libubsan, we
      should check them and print an error log to reflect the reality.
      
      Committer testing:
      
        $ rm -rf /tmp/build/perf ; mkdir -p /tmp/build/perf
        $ make DEBUG=1 EXTRA_CFLAGS='-fno-omit-frame-pointer -fsanitize=address' O=/tmp/build/perf -C tools/perf/ install-bin
        make: Entering directory '/home/acme/git/perf/tools/perf'
          BUILD:   Doing 'make -j12' parallel build
          HOSTCC   /tmp/build/perf/fixdep.o
          HOSTLD   /tmp/build/perf/fixdep-in.o
          LINK     /tmp/build/perf/fixdep
      
        Auto-detecting system features:
        ...                         dwarf: [ OFF ]
        ...            dwarf_getlocations: [ OFF ]
        ...                         glibc: [ OFF ]
        ...                          gtk2: [ OFF ]
        ...                        libbfd: [ OFF ]
        ...                        libcap: [ OFF ]
        ...                        libelf: [ OFF ]
        ...                       libnuma: [ OFF ]
        ...        numa_num_possible_cpus: [ OFF ]
        ...                       libperl: [ OFF ]
        ...                     libpython: [ OFF ]
        ...                     libcrypto: [ OFF ]
        ...                     libunwind: [ OFF ]
        ...            libdw-dwarf-unwind: [ OFF ]
        ...                          zlib: [ OFF ]
        ...                          lzma: [ OFF ]
        ...                     get_cpuid: [ OFF ]
        ...                           bpf: [ OFF ]
        ...                        libaio: [ OFF ]
        ...                       libzstd: [ OFF ]
        ...        disassembler-four-args: [ OFF ]
      
        Makefile.config:401: *** No libasan found, please install libasan.  Stop.
        make[1]: *** [Makefile.perf:231: sub-make] Error 2
        make: *** [Makefile:70: all] Error 2
        make: Leaving directory '/home/acme/git/perf/tools/perf'
        $
        $
        $ sudo dnf install libasan
        <SNIP>
        Installed:
          libasan-9.3.1-2.fc31.x86_64
        $
        $
        $ make DEBUG=1 EXTRA_CFLAGS='-fno-omit-frame-pointer -fsanitize=address' O=/tmp/build/perf -C tools/perf/ install-bin
        make: Entering directory '/home/acme/git/perf/tools/perf'
          BUILD:   Doing 'make -j12' parallel build
      
        Auto-detecting system features:
        ...                         dwarf: [ on  ]
        ...            dwarf_getlocations: [ on  ]
        ...                         glibc: [ on  ]
        ...                          gtk2: [ on  ]
        ...                        libbfd: [ on  ]
        ...                        libcap: [ on  ]
        ...                        libelf: [ on  ]
        ...                       libnuma: [ on  ]
        ...        numa_num_possible_cpus: [ on  ]
        ...                       libperl: [ on  ]
        ...                     libpython: [ on  ]
        ...                     libcrypto: [ on  ]
        ...                     libunwind: [ on  ]
        ...            libdw-dwarf-unwind: [ on  ]
        ...                          zlib: [ on  ]
        ...                          lzma: [ on  ]
        ...                     get_cpuid: [ on  ]
        ...                           bpf: [ on  ]
        ...                        libaio: [ on  ]
        ...                       libzstd: [ on  ]
        ...        disassembler-four-args: [ on  ]
         <SNIP>
          CC       /tmp/build/perf/util/pmu-flex.o
          FLEX     /tmp/build/perf/util/expr-flex.c
          CC       /tmp/build/perf/util/expr-bison.o
          CC       /tmp/build/perf/util/expr.o
          CC       /tmp/build/perf/util/expr-flex.o
          CC       /tmp/build/perf/util/parse-events-flex.o
          CC       /tmp/build/perf/util/parse-events.o
          LD       /tmp/build/perf/util/intel-pt-decoder/perf-in.o
          LD       /tmp/build/perf/util/perf-in.o
          LD       /tmp/build/perf/perf-in.o
          LINK     /tmp/build/perf/perf
        <SNIP>
          INSTALL  python-scripts
          INSTALL  perf_completion-script
          INSTALL  perf-tip
        make: Leaving directory '/home/acme/git/perf/tools/perf'
        $ ldd ~/bin/perf | grep asan
        	libasan.so.5 => /lib64/libasan.so.5 (0x00007f0904164000)
        $
      
      And if we rebuild without -fsanitize-address:
      
        $ rm -rf /tmp/build/perf ; mkdir -p /tmp/build/perf
        $ make O=/tmp/build/perf -C tools/perf/ install-bin
        make: Entering directory '/home/acme/git/perf/tools/perf'
          BUILD:   Doing 'make -j12' parallel build
          HOSTCC   /tmp/build/perf/fixdep.o
          HOSTLD   /tmp/build/perf/fixdep-in.o
          LINK     /tmp/build/perf/fixdep
      
        Auto-detecting system features:
        ...                         dwarf: [ on  ]
        ...            dwarf_getlocations: [ on  ]
        ...                         glibc: [ on  ]
        ...                          gtk2: [ on  ]
        ...                        libbfd: [ on  ]
        ...                        libcap: [ on  ]
        ...                        libelf: [ on  ]
        ...                       libnuma: [ on  ]
        ...        numa_num_possible_cpus: [ on  ]
        ...                       libperl: [ on  ]
        ...                     libpython: [ on  ]
        ...                     libcrypto: [ on  ]
        ...                     libunwind: [ on  ]
        ...            libdw-dwarf-unwind: [ on  ]
        ...                          zlib: [ on  ]
        ...                          lzma: [ on  ]
        ...                     get_cpuid: [ on  ]
        ...                           bpf: [ on  ]
        ...                        libaio: [ on  ]
        ...                       libzstd: [ on  ]
        ...        disassembler-four-args: [ on  ]
      
          GEN      /tmp/build/perf/common-cmds.h
          CC       /tmp/build/perf/exec-cmd.o
        <SNIP>
          INSTALL  perf_completion-script
          INSTALL  perf-tip
        make: Leaving directory '/home/acme/git/perf/tools/perf'
        $ ldd ~/bin/perf | grep asan
        $
      Signed-off-by: NTiezhu Yang <yangtiezhu@loongson.cn>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: tiezhu yang <yangtiezhu@loongson.cn>
      Cc: xuefeng li <lixuefeng@loongson.cn>
      Link: http://lore.kernel.org/lkml/1592445961-28044-1-git-send-email-yangtiezhu@loongson.cnSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      6a1515c9
    • M
      perf script: Initialize zstd_data · b13b04d9
      Milian Wolff 提交于
      Fixes segmentation fault when trying to interpret zstd-compressed data
      with perf script:
      
      ```
        $ perf record -z ls
        ...
        [ perf record: Captured and wrote 0,010 MB perf.data, compressed (original 0,001 MB, ratio is 2,190) ]
        $ memcheck perf script
        ...
        ==67911== Invalid read of size 4
        ==67911==    at 0x5568188: ZSTD_decompressStream (in /usr/lib/libzstd.so.1.4.5)
        ==67911==    by 0x6E726B: zstd_decompress_stream (zstd.c:100)
        ==67911==    by 0x65729C: perf_session__process_compressed_event (session.c:72)
        ==67911==    by 0x6598E8: perf_session__process_user_event (session.c:1583)
        ==67911==    by 0x65BA59: reader__process_events (session.c:2177)
        ==67911==    by 0x65BA59: __perf_session__process_events (session.c:2234)
        ==67911==    by 0x65BA59: perf_session__process_events (session.c:2267)
        ==67911==    by 0x5A7397: __cmd_script (builtin-script.c:2447)
        ==67911==    by 0x5A7397: cmd_script (builtin-script.c:3840)
        ==67911==    by 0x5FE9D2: run_builtin (perf.c:312)
        ==67911==    by 0x711627: handle_internal_command (perf.c:364)
        ==67911==    by 0x711627: run_argv (perf.c:408)
        ==67911==    by 0x711627: main (perf.c:538)
        ==67911==  Address 0x71d8 is not stack'd, malloc'd or (recently) free'd
      ```
      Signed-off-by: NMilian Wolff <milian.wolff@kdab.com>
      Acked-by: NAlexey Budankov <alexey.budankov@linux.intel.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      LPU-Reference: 20200612230333.72140-1-milian.wolff@kdab.com
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      b13b04d9
  3. 10 6月, 2020 1 次提交
  4. 09 6月, 2020 8 次提交
    • I
      perf parse-events: Fix an old style declaration · ffaecd7d
      Ian Rogers 提交于
      Fixes: a26e4716 (perf tools: Move ALLOC_LIST into a function)
      Signed-off-by: NIan Rogers <irogers@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20200609053610.206588-2-irogers@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      ffaecd7d
    • I
      perf parse-events: Fix an incompatible pointer · c2412fae
      Ian Rogers 提交于
      Arrays are pointer types and don't need their address taking.
      
      Fixes: 8255718f (perf pmu: Expand PMU events by prefix match)
      Signed-off-by: NIan Rogers <irogers@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20200609053610.206588-1-irogers@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      c2412fae
    • S
      perf bpf: Fix bpf prologue generation · d38c692f
      Sumanth Korikkar 提交于
      Issue:
      
      bpf_probe_read() is no longer available for architecture which has
      overlapping address space. Hence bpf prologue generation fails
      
      Fix:
      
      Use bpf_probe_read_kernel for kernel member access. For user attribute
      access in kprobes, use bpf_probe_read_user.
      
      Other:
      
      @user attribute was introduced in commit 1e032f7c ("perf-probe: Add
      user memory access attribute support")
      
      Test:
      
      1. ulimit -l 128 ; ./perf record -e tests/bpf_sched_setscheduler.c
      2. cat tests/bpf_sched_setscheduler.c
      
      static void (*bpf_trace_printk)(const char *fmt, int fmt_size, ...) =
              (void *) 6;
      static int (*bpf_probe_read_user)(void *dst, __u32 size,
                                        const void *unsafe_ptr) = (void *) 112;
      static int (*bpf_probe_read_kernel)(void *dst, __u32 size,
              const void *unsafe_ptr) = (void *) 113;
      
      SEC("func=do_sched_setscheduler  pid policy param->sched_priority@user")
      int bpf_func__setscheduler(void *ctx, int err, pid_t pid, int policy,
                                 int param)
      {
              char fmt[] = "prio: %ld";
              bpf_trace_printk(fmt, sizeof(fmt), param);
              return 1;
      }
      
      char _license[] SEC("license") = "GPL";
      int _version SEC("version") = LINUX_VERSION_CODE;
      
      3. ./perf script
         sched 305669 [000] 1614458.838675: perf_bpf_probe:func: (2904e508)
         pid=261614 policy=2 sched_priority=1
      
      4. cat /sys/kernel/debug/tracing/trace
         <...>-309956 [006] .... 1616098.093957: 0: prio: 1
      
      Committer testing:
      
      I had to add some missing headers in the bpf_sched_setscheduler.c test
      proggie, then instead of using record+script I used 'perf trace' to
      drive everything in one go:
      
        # cat bpf_sched_setscheduler.c
        #include <linux/types.h>
        #include <bpf.h>
      
        static void (*bpf_trace_printk)(const char *fmt, int fmt_size, ...) = (void *) 6;
        static int (*bpf_probe_read_user)(void *dst, __u32 size, const void *unsafe_ptr) = (void *) 112;
        static int (*bpf_probe_read_kernel)(void *dst, __u32 size, const void *unsafe_ptr) = (void *) 113;
      
        SEC("func=do_sched_setscheduler  pid policy param->sched_priority@user")
        int bpf_func__setscheduler(void *ctx, int err, pid_t pid, int policy, int param)
        {
                char fmt[] = "prio: %ld";
                bpf_trace_printk(fmt, sizeof(fmt), param);
                return 1;
        }
      
        char _license[] SEC("license") = "GPL";
        int _version SEC("version") = LINUX_VERSION_CODE;
        #
        #
        # perf trace -e bpf_sched_setscheduler.c chrt -f 42 sleep 1
           0.000 chrt/80125 perf_bpf_probe:func(__probe_ip: -1676607808, policy: 1, sched_priority: 42)
        #
      
      And even with backtraces :-)
      
        # perf trace -e bpf_sched_setscheduler.c/max-stack=8/ chrt -f 42 sleep 1
             0.000 chrt/79805 perf_bpf_probe:func(__probe_ip: -1676607808, policy: 1, sched_priority: 42)
                                               do_sched_setscheduler ([kernel.kallsyms])
                                               __x64_sys_sched_setscheduler ([kernel.kallsyms])
                                               do_syscall_64 ([kernel.kallsyms])
                                               entry_SYSCALL_64 ([kernel.kallsyms])
                                               __GI___sched_setscheduler (/usr/lib64/libc-2.30.so)
        #
      Signed-off-by: NSumanth Korikkar <sumanthk@linux.ibm.com>
      Reviewed-by: NThomas Richter <tmricht@linux.ibm.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Ilya Leoshkevich <iii@linux.ibm.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: bpf@vger.kernel.org
      LPU-Reference: 20200609081019.60234-3-sumanthk@linux.ibm.com
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      d38c692f
    • S
      perf probe: Fix user attribute access in kprobes · 9256c303
      Sumanth Korikkar 提交于
      Issue:
      
        # perf probe -a 'do_sched_setscheduler pid policy param->sched_priority@user'
      
      did not work before.
      
      Fix:
      
      Make:
      
        # perf probe -a 'do_sched_setscheduler pid policy param->sched_priority@user'
      
      output equivalent to ftrace:
      
        # echo 'p:probe/do_sched_setscheduler _text+517384 pid=%r2:s32 policy=%r3:s32 sched_priority=+u0(%r4):s32' > /sys/kernel/debug/tracing/kprobe_events
      
      Other:
      
      1. Right now, __match_glob() does not handle [u]<offset>. For now, use
        *u]<offset>.
      
      2. @user attribute was introduced in commit 1e032f7c ("perf-probe:
         Add user memory access attribute support")
      
      Test:
      1. perf probe -a 'do_sched_setscheduler  pid policy
         param->sched_priority@user'
      
      2 ./perf script
         sched 305669 [000] 1614458.838675: perf_bpf_probe:func: (2904e508)
         pid=261614 policy=2 sched_priority=1
      
      3. cat /sys/kernel/debug/tracing/trace
         <...>-309956 [006] .... 1616098.093957: 0: prio: 1
      
      Committer testing:
      
      Before:
      
        # perf probe -a 'do_sched_setscheduler pid policy param->sched_priority@user'
        param(type:sched_param) has no member sched_priority@user.
          Error: Failed to add events.
        # pahole sched_param
        struct sched_param {
        	int                        sched_priority;       /*     0     4 */
      
        	/* size: 4, cachelines: 1, members: 1 */
        	/* last cacheline: 4 bytes */
        };
        #
      
      After:
      
        # perf probe -a 'do_sched_setscheduler pid policy param->sched_priority@user'
        Added new event:
          probe:do_sched_setscheduler (on do_sched_setscheduler with pid policy sched_priority=param->sched_priority)
      
        You can now use it in all perf tools, such as:
      
        	perf record -e probe:do_sched_setscheduler -aR sleep 1
      
        # cat /sys/kernel/debug/tracing/kprobe_events
        p:probe/do_sched_setscheduler _text+1113792 pid=%di:s32 policy=%si:s32 sched_priority=+u0(%dx):s32
        #
      
      Fixes: 1e032f7c ("perf-probe: Add user memory access attribute support")
      Signed-off-by: NSumanth Korikkar <sumanthk@linux.ibm.com>
      Reviewed-by: NThomas Richter <tmricht@linux.ibm.com>
      Acked-by: NMasami Hiramatsu <mhiramat@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Ilya Leoshkevich <iii@linux.ibm.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Cc: bpf@vger.kernel.org
      LPU-Reference: 20200609081019.60234-2-sumanthk@linux.ibm.com
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      9256c303
    • H
      perf stat: Fix NULL pointer dereference · c0c652fc
      Hongbo Yao 提交于
      If config->aggr_map is NULL and config->aggr_get_id is not NULL,
      the function print_aggr() will still calling arrg_update_shadow(),
      which can result in accessing the invalid pointer.
      
      Fixes: 088519f3 ("perf stat: Move the display functions to stat-display.c")
      Signed-off-by: NHongbo Yao <yaohongbo@huawei.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wei Li <liwei391@huawei.com>
      Link: https://lore.kernel.org/lkml/20200608163625.GC3073@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      c0c652fc
    • G
      perf report: Fix NULL pointer dereference in hists__fprintf_nr_sample_events() · 11b6e548
      Gaurav Singh 提交于
      The 'evname' variable can be NULL, as it is checked a few lines back,
      check it before using.
      
      Fixes: 9e207ddf ("perf report: Show call graph from reference events")
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lore.kernel.org/lkml/Signed-off-by: NGaurav Singh <gaurav1086@gmail.com>
      11b6e548
    • A
      perf beauty: Add support to STATX_MNT_ID in the 'statx' syscall 'mask' argument · 5d33cbfe
      Arnaldo Carvalho de Melo 提交于
      Introduced in:
      
        fa2fcf4f ("statx: add mount ID")
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Miklos Szeredi <mszeredi@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      5d33cbfe
    • A
      tools headers API: Update faccessat2 affected files · 6c3c184f
      Arnaldo Carvalho de Melo 提交于
      Update the copies of files affected by:
      
        c8ffd8bc ("vfs: add faccessat2 syscall")
      
      To address this perf build warning:
      
        Warning: Kernel ABI header at 'tools/include/uapi/linux/fcntl.h' differs from latest version at 'include/uapi/linux/fcntl.h'
        diff -u tools/include/uapi/linux/fcntl.h include/uapi/linux/fcntl.h
        Warning: Kernel ABI header at 'tools/include/uapi/asm-generic/unistd.h' differs from latest version at 'include/uapi/asm-generic/unistd.h'
        diff -u tools/include/uapi/asm-generic/unistd.h include/uapi/asm-generic/unistd.h
        Warning: Kernel ABI header at 'tools/perf/arch/x86/entry/syscalls/syscall_64.tbl' differs from latest version at 'arch/x86/entry/syscalls/syscall_64.tbl'
        diff -u tools/perf/arch/x86/entry/syscalls/syscall_64.tbl arch/x86/entry/syscalls/syscall_64.tbl
      
      Which results in 'perf trace' gaining support for the 'faccessat2'
      syscall, now one can use:
      
        # perf trace -e faccessat2
      
      And have system wide tracing of this syscall. And this also will include
      it;
      
        # perf trace -e faccess*
      
      Together with the other variants.
      
      How it affects building/usage (on an x86_64 system):
      
        $ cp /tmp/build/perf/arch/x86/include/generated/asm/syscalls_64.c /tmp/syscalls_64.c.before
        $
        [root@five ~]# perf trace -e faccessat2
        event syntax error: 'faccessat2'
                             \___ parser error
        Run 'perf list' for a list of valid events
      
         Usage: perf trace [<options>] [<command>]
            or: perf trace [<options>] -- <command> [<options>]
            or: perf trace record [<options>] [<command>]
            or: perf trace record [<options>] -- <command> [<options>]
      
            -e, --event <event>   event/syscall selector. use 'perf list' to list available events
        [root@five ~]#
        $ cp arch/x86/entry/syscalls/syscall_64.tbl tools/perf/arch/x86/entry/syscalls/syscall_64.tbl
        $ git diff
        diff --git a/tools/perf/arch/x86/entry/syscalls/syscall_64.tbl b/tools/perf/arch/x86/entry/syscalls/syscall_64.tbl
        index 37b844f839bc..78847b32e137 100644
        --- a/tools/perf/arch/x86/entry/syscalls/syscall_64.tbl
        +++ b/tools/perf/arch/x86/entry/syscalls/syscall_64.tbl
        @@ -359,6 +359,7 @@
         435    common  clone3                  sys_clone3
         437    common  openat2                 sys_openat2
         438    common  pidfd_getfd             sys_pidfd_getfd
        +439    common  faccessat2              sys_faccessat2
      
         #
         # x32-specific system call numbers start at 512 to avoid cache impact
        $
      
        $ make -C tools/perf O=/tmp/build/perf/ install-bin
        <SNIP>
        CC       /tmp/build/perf/util/syscalltbl.o
        LD       /tmp/build/perf/util/perf-in.o
        LD       /tmp/build/perf/perf-in.o
        LINK     /tmp/build/perf/perf
        <SNIP>
        [root@five ~]# perf trace -e faccessat2
        ^C[root@five ~]#
      
      Cc: Miklos Szeredi <mszeredi@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      6c3c184f
  5. 02 6月, 2020 3 次提交
    • T
      perf tools: Remove some duplicated includes · 3e9b26dc
      Tiezhu Yang 提交于
      There exists some duplicated includes in tools/perf, remove them.
      Signed-off-by: NTiezhu Yang <yangtiezhu@loongson.cn>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: xuefeng li <lixuefeng@loongson.cn>
      Link: http://lore.kernel.org/lkml/1591071304-19338-2-git-send-email-yangtiezhu@loongson.cnSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      3e9b26dc
    • A
      perf symbols: Fix kernel maps for kcore and eBPF · 0affd0e5
      Adrian Hunter 提交于
      Adjust 'map->pgoff' also when moving a map's start address.
      
      Example with v5.4.34 based kernel:
      
        Before:
      
          $ sudo tools/perf/perf record -a --kcore -e intel_pt//k sleep 1
          [ perf record: Woken up 1 times to write data ]
          [ perf record: Captured and wrote 1.958 MB perf.data ]
          $ sudo tools/perf/perf script --itrace=e >/dev/null
          Warning:
          961 instruction trace errors
      
        After:
      
          $ sudo tools/perf/perf script --itrace=e >/dev/null
          $
      
      Committer testing:
      
        # uname -a
        Linux seventh 5.6.10-100.fc30.x86_64 #1 SMP Mon May 4 15:36:44 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
        #
      
      Before:
      
        # perf record -a --kcore -e intel_pt//k sleep 1
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.923 MB perf.data ]
        # perf script --itrace=e >/dev/null
        Warning:
        295 instruction trace errors
        #
      
      After:
      
        # perf record -a --kcore -e intel_pt//k sleep 1
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.919 MB perf.data ]
        # perf script --itrace=e >/dev/null
        #
      
      Fixes: fb5a88d4 ("perf tools: Preserve eBPF maps when loading kcore")
      Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: stable@vger.kernel.org
      Link: http://lore.kernel.org/lkml/20200602112505.1406-1-adrian.hunter@intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      0affd0e5
    • J
      perf stat: Ensure group is defined on top of the same cpu mask · a9a17902
      Jiri Olsa 提交于
      Jin Yao reported the issue (and posted first versions of this change)
      with groups being defined over events with different cpu mask.
      
      This causes assert aborts in get_group_fd, like:
      
        # perf stat -M "C2_Pkg_Residency" -a -- sleep 1
        perf: util/evsel.c:1464: get_group_fd: Assertion `!(fd == -1)' failed.
        Aborted
      
      All the events in the group have to be defined over the same cpus so the
      group_fd can be found for every leader/member pair.
      
      Adding check to ensure this condition is met and removing the group
      (with warning) if we detect mixed cpus, like:
      
        $ sudo perf stat -e '{power/energy-cores/,cycles},{instructions,power/energy-cores/}'
        WARNING: event cpu maps do not match, disabling group:
          anon group { power/energy-cores/, cycles }
          anon group { instructions, power/energy-cores/ }
      
      Ian asked also for cpu maps details, it's displayed in verbose mode:
      
        $ sudo perf stat -e '{cycles,power/energy-cores/}' -v
        WARNING: group events cpu maps do not match, disabling group:
          anon group { power/energy-cores/, cycles }
             power/energy-cores/: 0
             cycles: 0-7
          anon group { instructions, power/energy-cores/ }
             instructions: 0-7
             power/energy-cores/: 0
      
      Committer testing:
      
        [root@seventh ~]# perf stat -e '{power/energy-cores/,cycles},{instructions,power/energy-cores/}'
        WARNING: grouped events cpus do not match, disabling group:
          anon group { power/energy-cores/, cycles }
          anon group { instructions, power/energy-cores/ }
        ^C
         Performance counter stats for 'system wide':
      
                     12.62 Joules power/energy-cores/
               106,920,637        cycles
                80,228,899        instructions              #    0.75  insn per cycle
                     12.62 Joules power/energy-cores/
      
              14.514476987 seconds time elapsed
      
        [root@seventh ~]#
      
      But if we put compatible events in each group it works:
      
        [root@seventh ~]# perf stat -e '{power/energy-cores/,power/energy-ram/},{instructions,cycles}' -a sleep 2
      
         Performance counter stats for 'system wide':
      
                      1.95 Joules power/energy-cores/
                      0.92 Joules power/energy-ram/
                29,305,715        instructions              #    1.03  insn per cycle
                28,423,338        cycles
      
               2.001438142 seconds time elapsed
      
        [root@seventh ~]#
      
      This needs improvement tho:
      
        [root@seventh ~]# perf stat -e '{power/energy-cores/,power/energy-ram/},{instructions,cycles}' sleep 2
        Error:
        The sys_perf_event_open() syscall returned with 22 (Invalid argument) for event (power/energy-cores/).
        /bin/dmesg | grep -i perf may provide additional information.
      
        [root@seventh ~]#
      
      We need to emit a better message, one stating that the power/ events
      can't be used for a specific workload, instead it is per-cpu or system
      wide.
      
      Fixes: 6a4bb04c ("perf tools: Enable grouping logic for parsed events")
      Co-developed-by: NJin Yao <yao.jin@linux.intel.com>
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Acked-by: NIan Rogers <irogers@google.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20200602101736.GE1112120@kravaSigned-off-by: NJin Yao <yao.jin@linux.intel.com>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      a9a17902
  6. 01 6月, 2020 1 次提交