1. 08 11月, 2021 1 次提交
  2. 26 10月, 2021 1 次提交
    • J
      perf list: Display hybrid PMU events with cpu type · 0e0ae874
      Jin Yao 提交于
      Add a new option '--cputype' to 'perf list' to display core-only PMU
      events or atom-only PMU events.
      
      Each hybrid PMU event has been assigned with a PMU name, this patch
      compares the PMU name before listing the result.
      
      For example:
      
        perf list --cputype atom
        ...
        cache:
          core_reject_l2q.any
               [Counts the number of request that were not accepted into the L2Q because the L2Q is FULL. Unit: cpu_atom]
        ...
      
      The "Unit: cpu_atom" is displayed in the brief description section
      to indicate this is an atom event.
      Signed-off-by: NJin Yao <yao.jin@linux.intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jin Yao <yao.jin@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lore.kernel.org/lkml/20210903025239.22754-1-yao.jin@linux.intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      0e0ae874
  3. 20 10月, 2021 13 次提交
    • I
      perf metric: Allow modifiers on metrics · b85a4d61
      Ian Rogers 提交于
      By allowing modifiers on metrics we can, for example, gather the
      same metric for kernel and user mode. On a SkylakeX with
      TopDownL1 this gives:
      
        $ perf stat -M TopDownL1:u,TopDownL1:k -a sleep 2
      
         Performance counter stats for 'system wide':
      
               849,855,577    uops_issued.any:k         #     0.06 Bad_Speculation:k
                                                        #     0.51 Backend_Bound:k          (16.71%)
             1,995,257,996    cycles:k
                                                        # 7981031984.00 SLOTS:k
                                                        #     0.35 Frontend_Bound:k
                                                        #     0.08 Retiring:k               (16.71%)
             2,791,940,753    idq_uops_not_delivered.core:k                                 (16.71%)
               641,961,928    uops_retired.retire_slots:k                                   (16.71%)
                72,239,337    int_misc.recovery_cycles:k                                    (16.71%)
             2,294,413,647    uops_issued.any:u         #     0.04 Bad_Speculation:u
                                                        #     0.39 Backend_Bound:u          (16.78%)
             1,333,248,940    cycles:u
                                                        # 5332995760.00 SLOTS:u
                                                        #     0.16 Frontend_Bound:u
                                                        #     0.40 Retiring:u               (16.78%)
               858,517,081    idq_uops_not_delivered.core:u                                 (16.78%)
             2,153,789,582    uops_retired.retire_slots:u                                   (16.78%)
                19,373,627    int_misc.recovery_cycles:u                                    (16.78%)
                31,503,661    cpu_clk_unhalted.one_thread_active:k #     0.18 CoreIPC_SMT:k (16.73%)
               315,454,104    inst_retired.any:k        # 315454104.00 Instructions:k       (16.73%)
                42,533,729    cpu_clk_unhalted.ref_xclk:k                                   (16.73%)
             2,043,119,037    cpu_clk_unhalted.thread:k                                     (16.73%)
                28,843,803    cpu_clk_unhalted.one_thread_active:u #     1.55 CoreIPC_SMT:u (16.60%)
             2,153,353,869    inst_retired.any:u        # 2153353869.00 Instructions:u      (16.60%)
                28,844,743    cpu_clk_unhalted.ref_xclk:u                                   (16.60%)
             1,387,544,378    cpu_clk_unhalted.thread:u                                     (16.60%)
               308,031,603    inst_retired.any:k        #     0.15 CoreIPC:k                (33.19%)
             2,036,774,753    cycles:k                                                      (33.19%)
             1,994,344,281    inst_retired.any:u        #     1.59 CoreIPC:u                (33.18%)
             1,251,538,227    cycles:u                                                      (33.18%)
      
               2.000342948 seconds time elapsed
      
      Modifiers are naively copy and pasted on to events, this can yield errors like:
      
        $ perf stat -M Kernel_Utilization:k -a sleep 2
        event syntax error: '..d.thread:k/kk,cpu_clk_unhalted.thread/metric-id=cpu_clk_unhalted.thread/k..'
                                          \___ Bad modifier
      
         Usage: perf stat [<options>] [<command>]
      
            -M, --metrics <metric/metric group list>
                                  monitor specified metrics or metric groups (separated by ,)
      
      When modifiers are present with constraints, from --metric-no-group or
      the NMI watchdog, they are no longer placed in the same set - which may
      miss deduplicating events.
      Signed-off-by: NIan Rogers <irogers@google.com>
      Acked-by: NAndi Kleen <ak@linux.intel.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Antonov <alexander.antonov@linux.intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andrew Kilroy <andrew.kilroy@arm.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Changbin Du <changbin.du@intel.com>
      Cc: Denys Zagorui <dzagorui@cisco.com>
      Cc: Fabian Hemmer <copy@copy.sh>
      Cc: Felix Fietkau <nbd@nbd.name>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jacob Keller <jacob.e.keller@intel.com>
      Cc: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Joakim Zhang <qiangqing.zhang@nxp.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Kees Kook <keescook@chromium.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nicholas Fraser <nfraser@codeweavers.com>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Paul Clarke <pc@us.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Riccardo Mancini <rickyman7@gmail.com>
      Cc: Sami Tolvanen <samitolvanen@google.com>
      Cc: ShihCheng Tu <mrtoastcheng@gmail.com>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Sumanth Korikkar <sumanthk@linux.ibm.com>
      Cc: Thomas Richter <tmricht@linux.ibm.com>
      Cc: Wan Jiabing <wanjiabing@vivo.com>
      Cc: Zhen Lei <thunder.leizhen@huawei.com>
      Link: https://lore.kernel.org/r/20211015172132.1162559-22-irogers@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      b85a4d61
    • I
      perf metric: Switch fprintf() to pr_err() · e068c256
      Ian Rogers 提交于
      There's no clear reason for the inconsistency that stems from the
      initial commit.
      Signed-off-by: NIan Rogers <irogers@google.com>
      Acked-by: NAndi Kleen <ak@linux.intel.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Antonov <alexander.antonov@linux.intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andrew Kilroy <andrew.kilroy@arm.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Changbin Du <changbin.du@intel.com>
      Cc: Denys Zagorui <dzagorui@cisco.com>
      Cc: Fabian Hemmer <copy@copy.sh>
      Cc: Felix Fietkau <nbd@nbd.name>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jacob Keller <jacob.e.keller@intel.com>
      Cc: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Joakim Zhang <qiangqing.zhang@nxp.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Kees Kook <keescook@chromium.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nicholas Fraser <nfraser@codeweavers.com>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Paul Clarke <pc@us.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Riccardo Mancini <rickyman7@gmail.com>
      Cc: Sami Tolvanen <samitolvanen@google.com>
      Cc: ShihCheng Tu <mrtoastcheng@gmail.com>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Sumanth Korikkar <sumanthk@linux.ibm.com>
      Cc: Thomas Richter <tmricht@linux.ibm.com>
      Cc: Wan Jiabing <wanjiabing@vivo.com>
      Cc: Zhen Lei <thunder.leizhen@huawei.com>
      Link: https://lore.kernel.org/r/20211015172132.1162559-20-irogers@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      e068c256
    • I
      perf metrics: Modify setup and deduplication · 5ecd5a0c
      Ian Rogers 提交于
      Previously find_evsel_group was trying to share events while
      mark-sweeping to eliminate unused events, this was complicated and had
      issues around uncore events and grouped sharing.
      
      This was further complicated by the event string being created while
      metrics and metric groups were being added, with the string affecting
      the evlist order.
      
      This change moves deduplication before event parsing.  Ungrouped events
      are placed in a single combined set. Groups are checked to see if an
      earlier (larger) group can support their events.
      
      As the deduplication and sharing detection is done on metric IDs before
      parsing, wildcard expansion problems with uncore events are avoided.
      
      Overall the code is simpler while working better.
      
      An example of failing to deduplicate can be seen with a list of metrics
      like the following, where in the after case multiplexing has been
      avoided:
      
      Before:
      
        $ perf stat -M Bad_Speculation,Backend_Bound,Frontend_Bound,Retiring -a sleep 2
      
         Performance counter stats for 'system wide':
      
               959,620,872      uops_issued.any           #     0.06 Bad_Speculation    (50.03%)
             2,163,072,261      cycles
                                                          #     0.09 Retiring           (50.03%)
               735,827,436      uops_retired.retire_slots                               (50.03%)
                74,676,484      int_misc.recovery_cycles                                (50.03%)
               987,062,794      uops_issued.any           #     0.50 Backend_Bound      (49.97%)
             2,203,734,187      cycles
                                                          #     0.35 Frontend_Bound     (49.97%)
             3,085,016,091      idq_uops_not_delivered.core                             (49.97%)
               758,599,232      uops_retired.retire_slots                               (49.97%)
                75,807,526      int_misc.recovery_cycles                                (49.97%)
      
               2.002103760 seconds time elapsed
      
      After:
      
        $ sudo perf stat -M Bad_Speculation,Backend_Bound,Frontend_Bound,Retiring -a sleep 2
      
         Performance counter stats for 'system wide':
      
               769,694,676      uops_issued.any           #     0.08 Bad_Speculation
                                                          #     0.41 Backend_Bound
             1,087,548,633      cycles
                                                          #     0.38 Frontend_Bound
                                                          #     0.14 Retiring
             1,642,085,777      idq_uops_not_delivered.core
               603,112,590      uops_retired.retire_slots
                43,787,854      int_misc.recovery_cycles
      
               2.003844383 seconds time elapsed
      Signed-off-by: NIan Rogers <irogers@google.com>
      Acked-by: NAndi Kleen <ak@linux.intel.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Antonov <alexander.antonov@linux.intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andrew Kilroy <andrew.kilroy@arm.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Changbin Du <changbin.du@intel.com>
      Cc: Denys Zagorui <dzagorui@cisco.com>
      Cc: Fabian Hemmer <copy@copy.sh>
      Cc: Felix Fietkau <nbd@nbd.name>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jacob Keller <jacob.e.keller@intel.com>
      Cc: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Joakim Zhang <qiangqing.zhang@nxp.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Kees Kook <keescook@chromium.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nicholas Fraser <nfraser@codeweavers.com>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Paul Clarke <pc@us.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Riccardo Mancini <rickyman7@gmail.com>
      Cc: Sami Tolvanen <samitolvanen@google.com>
      Cc: ShihCheng Tu <mrtoastcheng@gmail.com>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Sumanth Korikkar <sumanthk@linux.ibm.com>
      Cc: Thomas Richter <tmricht@linux.ibm.com>
      Cc: Wan Jiabing <wanjiabing@vivo.com>
      Cc: Zhen Lei <thunder.leizhen@huawei.com>
      Link: https://lore.kernel.org/r/20211015172132.1162559-19-irogers@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      5ecd5a0c
    • I
      perf metric: Encode and use metric-id as qualifier · ec5c5b3d
      Ian Rogers 提交于
      For a metric like IPC a group of events like {instructions,cycles}:W
      would be formed.
      
      If the events names were changed in parsing then the metric expression
      parser would fail to find them.
      
      This change makes the event encoding be something like:
      
        {instructions/metric-id=instructions/, cycles/metric-id=cycles/}
      
      and then uses the evsel's stable metric-id value to locate the events.
      
      This fixes the case that an event is restricted to user because of the
      paranoia setting:
      
        $ echo 2 > /proc/sys/kernel/perf_event_paranoid
        $ perf stat -M IPC /bin/true
         Performance counter stats for '/bin/true':
      
                   150,298      inst_retired.any:u        #      0.77 IPC
                   187,095      cpu_clk_unhalted.thread:u
      
               0.002042731 seconds time elapsed
      
               0.000000000 seconds user
               0.002377000 seconds sys
      
      Adding the metric-id as a qualifier has a complication in that
      qualifiers will become embedded in qualifiers.
      
      For example, msr/tsc/ could become msr/tsc,metric-id=msr/tsc// which
      will fail parse-events.
      
      To solve this problem the metric is encoded and decoded for the
      metric-id with !<num> standing in for an encoded value.
      
      Previously ! wasn't parsed.
      
      With this msr/tsc/ becomes msr/tsc,metric-id=msr!3tsc!3/
      
      The metric expression parser is changed so that @ isn't changed to /,
      instead this is done when the ID is encoded for parse events.
      
      metricgroup__add_metric_non_group() and metricgroup__add_metric_weak_group()
      need to inject the metric-id qualifier, so to avoid repetition they are
      merged into a single metricgroup__build_event_string with error codes
      more rigorously checked.
      
      stat-shadow's prepare_metric() uses the metric-id to match the metricgroup
      code.
      
      As "metric-id=..." is added to all events, it is adding during testing
      with the fake PMU.
      
      This complicates pmu_str_check code as PE_PMU_EVENT_FAKE won't match as
      part of a configuration.
      
      The testing fake PMU case is fixed so that if a known qualifier with an
      ! is parsed then it isn't reported as a fake PMU.
      
      This is sufficient to pass all testing but it and the original mechanism
      are somewhat brittle.
      Signed-off-by: NIan Rogers <irogers@google.com>
      Acked-by: NAndi Kleen <ak@linux.intel.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Antonov <alexander.antonov@linux.intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andrew Kilroy <andrew.kilroy@arm.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Changbin Du <changbin.du@intel.com>
      Cc: Denys Zagorui <dzagorui@cisco.com>
      Cc: Fabian Hemmer <copy@copy.sh>
      Cc: Felix Fietkau <nbd@nbd.name>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jacob Keller <jacob.e.keller@intel.com>
      Cc: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Joakim Zhang <qiangqing.zhang@nxp.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Kees Kook <keescook@chromium.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nicholas Fraser <nfraser@codeweavers.com>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Paul Clarke <pc@us.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Riccardo Mancini <rickyman7@gmail.com>
      Cc: Sami Tolvanen <samitolvanen@google.com>
      Cc: ShihCheng Tu <mrtoastcheng@gmail.com>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Sumanth Korikkar <sumanthk@linux.ibm.com>
      Cc: Thomas Richter <tmricht@linux.ibm.com>
      Cc: Wan Jiabing <wanjiabing@vivo.com>
      Cc: Zhen Lei <thunder.leizhen@huawei.com>
      Link: https://lore.kernel.org/r/20211015172132.1162559-17-irogers@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      ec5c5b3d
    • I
      perf metric: Simplify metric_refs calculation · 46bdc0bf
      Ian Rogers 提交于
      Don't build a list and then turn to an array, just directly build the
      array.
      
      The size of the array is known due to the search for a duplicate.
      Signed-off-by: NIan Rogers <irogers@google.com>
      Acked-by: NAndi Kleen <ak@linux.intel.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Antonov <alexander.antonov@linux.intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andrew Kilroy <andrew.kilroy@arm.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Changbin Du <changbin.du@intel.com>
      Cc: Denys Zagorui <dzagorui@cisco.com>
      Cc: Fabian Hemmer <copy@copy.sh>
      Cc: Felix Fietkau <nbd@nbd.name>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jacob Keller <jacob.e.keller@intel.com>
      Cc: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Joakim Zhang <qiangqing.zhang@nxp.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Kees Kook <keescook@chromium.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nicholas Fraser <nfraser@codeweavers.com>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Paul Clarke <pc@us.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Riccardo Mancini <rickyman7@gmail.com>
      Cc: Sami Tolvanen <samitolvanen@google.com>
      Cc: ShihCheng Tu <mrtoastcheng@gmail.com>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Sumanth Korikkar <sumanthk@linux.ibm.com>
      Cc: Thomas Richter <tmricht@linux.ibm.com>
      Cc: Wan Jiabing <wanjiabing@vivo.com>
      Cc: Zhen Lei <thunder.leizhen@huawei.com>
      Link: https://lore.kernel.org/r/20211015172132.1162559-13-irogers@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      46bdc0bf
    • I
      perf metric: Document the internal 'struct metric' · 485fcaed
      Ian Rogers 提交于
      Add documentation as part of code tidying.
      Signed-off-by: NIan Rogers <irogers@google.com>
      Acked-by: NAndi Kleen <ak@linux.intel.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Antonov <alexander.antonov@linux.intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andrew Kilroy <andrew.kilroy@arm.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Changbin Du <changbin.du@intel.com>
      Cc: Denys Zagorui <dzagorui@cisco.com>
      Cc: Fabian Hemmer <copy@copy.sh>
      Cc: Felix Fietkau <nbd@nbd.name>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jacob Keller <jacob.e.keller@intel.com>
      Cc: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Joakim Zhang <qiangqing.zhang@nxp.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Kees Kook <keescook@chromium.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nicholas Fraser <nfraser@codeweavers.com>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Paul Clarke <pc@us.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Riccardo Mancini <rickyman7@gmail.com>
      Cc: Sami Tolvanen <samitolvanen@google.com>
      Cc: ShihCheng Tu <mrtoastcheng@gmail.com>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Sumanth Korikkar <sumanthk@linux.ibm.com>
      Cc: Thomas Richter <tmricht@linux.ibm.com>
      Cc: Wan Jiabing <wanjiabing@vivo.com>
      Cc: Zhen Lei <thunder.leizhen@huawei.com>
      Link: https://lore.kernel.org/r/20211015172132.1162559-12-irogers@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      485fcaed
    • I
      perf metric: Modify resolution and recursion check · 80be6434
      Ian Rogers 提交于
      Modify resolution. Rather than resolving a list of metrics, resolve a
      metric immediately after it is added.
      
      This simplifies knowing the root of the metric's tree so that IDs may be
      associated with it.
      
      A bug in the current implementation is that all the IDs were placed on
      the first metric in a metric group.
      
      Rather than maintain data on IDs' parents to detect cycles, maintain
      a list of visited metrics and detect cycles if the same metric is
      visited twice.
      
      Only place the root metric onto the list of metrics.
      Signed-off-by: NIan Rogers <irogers@google.com>
      Acked-by: NAndi Kleen <ak@linux.intel.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Antonov <alexander.antonov@linux.intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andrew Kilroy <andrew.kilroy@arm.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Changbin Du <changbin.du@intel.com>
      Cc: Denys Zagorui <dzagorui@cisco.com>
      Cc: Fabian Hemmer <copy@copy.sh>
      Cc: Felix Fietkau <nbd@nbd.name>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jacob Keller <jacob.e.keller@intel.com>
      Cc: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Joakim Zhang <qiangqing.zhang@nxp.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Kees Kook <keescook@chromium.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nicholas Fraser <nfraser@codeweavers.com>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Paul Clarke <pc@us.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Riccardo Mancini <rickyman7@gmail.com>
      Cc: Sami Tolvanen <samitolvanen@google.com>
      Cc: ShihCheng Tu <mrtoastcheng@gmail.com>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Sumanth Korikkar <sumanthk@linux.ibm.com>
      Cc: Thomas Richter <tmricht@linux.ibm.com>
      Cc: Wan Jiabing <wanjiabing@vivo.com>
      Cc: Zhen Lei <thunder.leizhen@huawei.com>
      Link: https://lore.kernel.org/r/20211015172132.1162559-10-irogers@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      80be6434
    • I
      perf metric: Only add a referenced metric once · a3de7690
      Ian Rogers 提交于
      If a metric references other metrics then the same other metrics may be
      referenced more than once, but the events and metric ref are only needed
      once.
      
      An example of this is in tests/parse-metric.c where DCache_L2_Hits
      references the metric DCache_L2_All_Hits twice, once directly and once
      through DCache_L2_All.
      Signed-off-by: NIan Rogers <irogers@google.com>
      Acked-by: NAndi Kleen <ak@linux.intel.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Antonov <alexander.antonov@linux.intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andrew Kilroy <andrew.kilroy@arm.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Changbin Du <changbin.du@intel.com>
      Cc: Denys Zagorui <dzagorui@cisco.com>
      Cc: Fabian Hemmer <copy@copy.sh>
      Cc: Felix Fietkau <nbd@nbd.name>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jacob Keller <jacob.e.keller@intel.com>
      Cc: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Joakim Zhang <qiangqing.zhang@nxp.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Kees Kook <keescook@chromium.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nicholas Fraser <nfraser@codeweavers.com>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Paul Clarke <pc@us.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Riccardo Mancini <rickyman7@gmail.com>
      Cc: Sami Tolvanen <samitolvanen@google.com>
      Cc: ShihCheng Tu <mrtoastcheng@gmail.com>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Sumanth Korikkar <sumanthk@linux.ibm.com>
      Cc: Thomas Richter <tmricht@linux.ibm.com>
      Cc: Wan Jiabing <wanjiabing@vivo.com>
      Cc: Zhen Lei <thunder.leizhen@huawei.com>
      Link: https://lore.kernel.org/r/20211015172132.1162559-9-irogers@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      a3de7690
    • I
      perf metric: Add metric new() and free() methods · 3d81d761
      Ian Rogers 提交于
      Metrics are complex enough that a new/free reduces the risk of memory
      leaks. Move static functions used in new.
      Reviewed-by: NJohn Garry <john.garry@huawei.com>
      Signed-off-by: NIan Rogers <irogers@google.com>
      Acked-by: NAndi Kleen <ak@linux.intel.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Antonov <alexander.antonov@linux.intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andrew Kilroy <andrew.kilroy@arm.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Changbin Du <changbin.du@intel.com>
      Cc: Denys Zagorui <dzagorui@cisco.com>
      Cc: Fabian Hemmer <copy@copy.sh>
      Cc: Felix Fietkau <nbd@nbd.name>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jacob Keller <jacob.e.keller@intel.com>
      Cc: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Joakim Zhang <qiangqing.zhang@nxp.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Kees Kook <keescook@chromium.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nicholas Fraser <nfraser@codeweavers.com>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Paul Clarke <pc@us.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Riccardo Mancini <rickyman7@gmail.com>
      Cc: Sami Tolvanen <samitolvanen@google.com>
      Cc: ShihCheng Tu <mrtoastcheng@gmail.com>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Sumanth Korikkar <sumanthk@linux.ibm.com>
      Cc: Thomas Richter <tmricht@linux.ibm.com>
      Cc: Wan Jiabing <wanjiabing@vivo.com>
      Cc: Zhen Lei <thunder.leizhen@huawei.com>
      Link: https://lore.kernel.org/r/20211015172132.1162559-8-irogers@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      3d81d761
    • I
      perf metric: Add documentation and rename a variable. · 68074811
      Ian Rogers 提交于
      Documentation to make current functionality clearer.
      
      Rename a variable called 'metric' to 'metric_name' as it can be
      ambiguous as to whether a string is the name of a metric or the
      expression.
      Signed-off-by: NIan Rogers <irogers@google.com>
      Acked-by: NAndi Kleen <ak@linux.intel.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Antonov <alexander.antonov@linux.intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andrew Kilroy <andrew.kilroy@arm.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Changbin Du <changbin.du@intel.com>
      Cc: Denys Zagorui <dzagorui@cisco.com>
      Cc: Fabian Hemmer <copy@copy.sh>
      Cc: Felix Fietkau <nbd@nbd.name>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jacob Keller <jacob.e.keller@intel.com>
      Cc: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Joakim Zhang <qiangqing.zhang@nxp.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Kees Kook <keescook@chromium.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nicholas Fraser <nfraser@codeweavers.com>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Paul Clarke <pc@us.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Riccardo Mancini <rickyman7@gmail.com>
      Cc: Sami Tolvanen <samitolvanen@google.com>
      Cc: ShihCheng Tu <mrtoastcheng@gmail.com>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Sumanth Korikkar <sumanthk@linux.ibm.com>
      Cc: Thomas Richter <tmricht@linux.ibm.com>
      Cc: Wan Jiabing <wanjiabing@vivo.com>
      Cc: Zhen Lei <thunder.leizhen@huawei.com>
      Link: https://lore.kernel.org/r/20211015172132.1162559-7-irogers@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      68074811
    • I
      perf metric: Move runtime value to the expr context · fa831fbb
      Ian Rogers 提交于
      The runtime value is needed when recursively parsing metrics, currently
      a value of 1 is passed which is incorrect.
      
      Rather than add more arguments to the bison parser, add runtime to the
      context.
      
      Fix call sites not to pass a value. The runtime value is defaulted to 0,
      which is arbitrary. In some places this replaces a value of 1, which was
      also arbitrary.
      
      This shouldn't affect anything other than PPC.
      
      The use of 0 or 1 shouldn't matter as a proper runtime value would be
      needed in a case that it did matter.
      Signed-off-by: NIan Rogers <irogers@google.com>
      Acked-by: NAndi Kleen <ak@linux.intel.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Antonov <alexander.antonov@linux.intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andrew Kilroy <andrew.kilroy@arm.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Changbin Du <changbin.du@intel.com>
      Cc: Denys Zagorui <dzagorui@cisco.com>
      Cc: Fabian Hemmer <copy@copy.sh>
      Cc: Felix Fietkau <nbd@nbd.name>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jacob Keller <jacob.e.keller@intel.com>
      Cc: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Joakim Zhang <qiangqing.zhang@nxp.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Kees Kook <keescook@chromium.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nicholas Fraser <nfraser@codeweavers.com>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Paul Clarke <pc@us.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Riccardo Mancini <rickyman7@gmail.com>
      Cc: Sami Tolvanen <samitolvanen@google.com>
      Cc: ShihCheng Tu <mrtoastcheng@gmail.com>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Sumanth Korikkar <sumanthk@linux.ibm.com>
      Cc: Thomas Richter <tmricht@linux.ibm.com>
      Cc: Wan Jiabing <wanjiabing@vivo.com>
      Cc: Zhen Lei <thunder.leizhen@huawei.com>
      Link: https://lore.kernel.org/r/20211015172132.1162559-6-irogers@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      fa831fbb
    • I
      perf pmu: Make pmu_event tables const. · 47f572aa
      Ian Rogers 提交于
      Make lookup nature of data structures clearer through their type. Reduce
      scope of architecture specific pmu_event tables by making them static.
      Suggested-by: NJohn Garry <john.garry@huawei.com>
      Reviewed-by: NJohn Garry <john.garry@huawei.com>
      Signed-off-by: NIan Rogers <irogers@google.com>
      Acked-by: NAndi Kleen <ak@linux.intel.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Antonov <alexander.antonov@linux.intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andrew Kilroy <andrew.kilroy@arm.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Changbin Du <changbin.du@intel.com>
      Cc: Denys Zagorui <dzagorui@cisco.com>
      Cc: Fabian Hemmer <copy@copy.sh>
      Cc: Felix Fietkau <nbd@nbd.name>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jacob Keller <jacob.e.keller@intel.com>
      Cc: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Joakim Zhang <qiangqing.zhang@nxp.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Kees Kook <keescook@chromium.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nicholas Fraser <nfraser@codeweavers.com>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Paul Clarke <pc@us.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Riccardo Mancini <rickyman7@gmail.com>
      Cc: Sami Tolvanen <samitolvanen@google.com>
      Cc: ShihCheng Tu <mrtoastcheng@gmail.com>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Sumanth Korikkar <sumanthk@linux.ibm.com>
      Cc: Thomas Richter <tmricht@linux.ibm.com>
      Cc: Wan Jiabing <wanjiabing@vivo.com>
      Cc: Zhen Lei <thunder.leizhen@huawei.com>
      Link: https://lore.kernel.org/r/20211015172132.1162559-5-irogers@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      47f572aa
    • I
      perf pmu: Add const to pmu_events_map. · 0ec43c08
      Ian Rogers 提交于
      The pmu_events_map is generated at compile time and used for lookup. For
      testing purposes we need to swap the map being used.
      
      Having the pmu_events_map be non-const is misleading as it may be an out
      argument.
      
      Make it const and update uses so they work on const too.
      Reviewed-by: NJohn Garry <john.garry@huawei.com>
      Signed-off-by: NIan Rogers <irogers@google.com>
      Acked-by: NAndi Kleen <ak@linux.intel.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Antonov <alexander.antonov@linux.intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andrew Kilroy <andrew.kilroy@arm.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Changbin Du <changbin.du@intel.com>
      Cc: Denys Zagorui <dzagorui@cisco.com>
      Cc: Fabian Hemmer <copy@copy.sh>
      Cc: Felix Fietkau <nbd@nbd.name>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jacob Keller <jacob.e.keller@intel.com>
      Cc: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Joakim Zhang <qiangqing.zhang@nxp.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Kees Kook <keescook@chromium.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nicholas Fraser <nfraser@codeweavers.com>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Paul Clarke <pc@us.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Riccardo Mancini <rickyman7@gmail.com>
      Cc: Sami Tolvanen <samitolvanen@google.com>
      Cc: ShihCheng Tu <mrtoastcheng@gmail.com>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Sumanth Korikkar <sumanthk@linux.ibm.com>
      Cc: Thomas Richter <tmricht@linux.ibm.com>
      Cc: Wan Jiabing <wanjiabing@vivo.com>
      Cc: Zhen Lei <thunder.leizhen@huawei.com>
      Link: https://lore.kernel.org/r/20211015172132.1162559-3-irogers@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      0ec43c08
  4. 30 9月, 2021 3 次提交
  5. 09 9月, 2021 1 次提交
  6. 10 7月, 2021 2 次提交
  7. 19 6月, 2021 2 次提交
    • J
      perf metricgroup: Return error code from metricgroup__add_metric_sys_event_iter() · fe7a98b9
      John Garry 提交于
      The error code is not set at all in the sys event iter function.
      
      This may lead to an uninitialized value of "ret" in
      metricgroup__add_metric() when no CPU metric is added.
      
      Fix by properly setting the error code.
      
      It is not necessary to init "ret" to 0 in metricgroup__add_metric(), as
      if we have no CPU or sys event metric matching, then "has_match" should
      be 0 and "ret" is set to -EINVAL.
      
      However gcc cannot detect that it may not have been set after the
      map_for_each_metric() loop for CPU metrics, which is strange.
      
      Fixes: be335ec2 ("perf metricgroup: Support adding metrics for system PMUs")
      Signed-off-by: NJohn Garry <john.garry@huawei.com>
      Acked-by: NIan Rogers <irogers@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Kajol Jain <kjain@linux.ibm.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/1623335580-187317-3-git-send-email-john.garry@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      fe7a98b9
    • J
      perf metricgroup: Fix find_evsel_group() event selector · fc96ec4d
      John Garry 提交于
      The following command segfaults on my x86 broadwell:
      
        $ ./perf stat  -M frontend_bound,retiring,backend_bound,bad_speculation sleep 1
        WARNING: grouped events cpus do not match, disabling group:
          anon group { raw 0x10e }
          anon group { raw 0x10e }
        perf: util/evsel.c:1596: get_group_fd: Assertion `!(!leader->core.fd)' failed.
        Aborted (core dumped)
      
      The issue shows itself as a use-after-free in evlist__check_cpu_maps(),
      whereby the leader of an event selector (evsel) has been deleted (yet we
      still attempt to verify for an evsel).
      
      Fundamentally the problem comes from metricgroup__setup_events() ->
      find_evsel_group(), and has developed from the previous fix attempt in
      commit 9c880c24 ("perf metricgroup: Fix for metrics containing
      duration_time").
      
      The problem now is that the logic in checking if an evsel is in the same
      group is subtly broken for the "cycles" event. For the "cycles" event,
      the pmu_name is NULL; however the logic in find_evsel_group() may set an
      event matched against "cycles" as used, when it should not be.
      
      This leads to a condition where an evsel is set, yet its leader is not.
      
      Fix the check for evsel pmu_name by not matching evsels when either has a
      NULL pmu_name.
      
      There is still a pre-existing metric issue whereby the ordering of the
      metrics may break the 'stat' function, as discussed at:
      https://lore.kernel.org/lkml/49c6fccb-b716-1bf0-18a6-cace1cdb66b9@huawei.com/
      
      Fixes: 9c880c24 ("perf metricgroup: Fix for metrics containing duration_time")
      Signed-off-by: NJohn Garry <john.garry@huawei.com>
      Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> # On a Thinkpad T450S
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Kajol Jain <kjain@linux.ibm.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/1623335580-187317-2-git-send-email-john.garry@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      fc96ec4d
  8. 09 4月, 2021 2 次提交
  9. 24 3月, 2021 1 次提交
  10. 18 2月, 2021 1 次提交
  11. 22 1月, 2021 2 次提交
    • J
      perf metricgroup: Fix system PMU metrics · 3d6e79ee
      John Garry 提交于
      Joakim reports that getting "perf stat" for multiple system PMU metrics
      segfaults:
      
        $ perf stat -a -I 1000 -M imx8mm_ddr_write.all,imx8mm_ddr_write.all
        Segmentation fault
        $
      
      While the same works without issue for a single metric.
      
      The logic in metricgroup__add_metric_sys_event_iter() is broken, in that
      add_metric() @m argument should be NULL for each new metric. Fix by not
      passing a holder for that, and rather make local in
      metricgroup__add_metric_sys_event_iter().
      
      Fixes: be335ec2 ("perf metricgroup: Support adding metrics for system PMUs")
      Reported-by: NJoakim Zhang <qiangqing.zhang@nxp.com>
      Signed-off-by: NJohn Garry <john.garry@huawei.com>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: linuxarm@openeuler.org
      Link: https://lore.kernel.org/r/1611050655-44020-1-git-send-email-john.garry@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      3d6e79ee
    • J
      perf metricgroup: Fix for metrics containing duration_time · 9c880c24
      John Garry 提交于
      Metrics containing duration_time cause a segfault:
      
        $ perf stat -v -M L1D_Cache_Fill_BW sleep 1
        Using CPUID GenuineIntel-6-3D-4
        metric expr 64 * l1d.replacement / 1000000000 / duration_time for L1D_Cache_Fill_BW
        found event duration_time
        found event l1d.replacement
        adding {l1d.replacement}:W,duration_time
        l1d.replacement -> cpu/umask=0x1,(null)=0x1e8483,event=0x51/
        Segmentation fault
        $
      
      In commit c2337d67 ("perf metricgroup: Fix metrics using aliases
      covering multiple PMUs"), the logic in find_evsel_group() when iter'ing
      events was changed to not only select events in same group, but also for
      aliased PMUs.
      
      Checking whether events were for aliased PMUs was done by comparing the
      event PMU name. This was not safe for duration_time event, which has no
      associated PMU (and no PMU name), so fix by checking if the event PMU name
      is set also.
      
      Committer testing:
      
      Reproduced the bug, then, on a:
      
        $ grep -m1 ^'model name' /proc/cpuinfo
        model name	: Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz
        $
      
      We now get:
      
        $ perf stat -M L1D_Cache_Fill_BW sleep 1
      
         Performance counter stats for 'sleep 1':
      
                     4,141      l1d.replacement:u
             1,001,285,107 ns   duration_time:u
      
               1.001285107 seconds time elapsed
      
               0.000000000 seconds user
               0.001119000 seconds sys
      
        $
      
      Detais from -v:
      
        Using CPUID GenuineIntel-6-8E-A
        metric expr 64 * l1d.replacement / 1000000000 / duration_time for L1D_Cache_Fill_BW
        found event duration_time
        found event l1d.replacement
        adding {l1d.replacement}:W,duration_time
        l1d.replacement -> cpu/(null)=0x1e8483,umask=0x1,event=0x51/
        Control descriptor is not initialized
        Warning:
        kernel.perf_event_paranoid=2, trying to fall back to excluding kernel and hypervisor  samples
        Warning:
        kernel.perf_event_paranoid=2, trying to fall back to excluding kernel and hypervisor  samples
        l1d.replacement:u: 4592 612201 612201
        duration_time:u: 1001478621 1001478621 1001478621
      
      Fixes: c2337d67 ("perf metricgroup: Fix metrics using aliases covering multiple PMUs")
      Reported-by: NJoakim Zhang <qiangqing.zhang@nxp.com>
      Signed-off-by: NJohn Garry <john.garry@huawei.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Tested-by: NJiri Olsa <jolsa@redhat.com>
      Acked-by: NIan Rogers <irogers@google.com>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: linuxarm@openeuler.org
      Link: https://lore.kernel.org/r/1611159518-226883-1-git-send-email-john.garry@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      9c880c24
  12. 18 12月, 2020 4 次提交
    • J
      perf metricgroup: Support adding metrics for system PMUs · be335ec2
      John Garry 提交于
      Currently adding metrics for core- or uncore-based events matched by CPUID
      is supported.
      
      Extend this for system events.
      Signed-off-by: NJohn Garry <john.garry@huawei.com>
      Acked-by: NKajol Jain <kjain@linux.ibm.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Joakim Zhang <qiangqing.zhang@nxp.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Kim Phillips <kim.phillips@amd.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Shaokun Zhang <zhangshaokun@hisilicon.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: linuxarm@huawei.com
      Link: http://lore.kernel.org/lkml/1607080216-36968-10-git-send-email-john.garry@huawei.com
      [ Reorder 'struct metricgroup_add_iter_data' field to avoid alignment holes ]
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      be335ec2
    • J
      perf metricgroup: Support printing metric groups for system PMUs · a36fadb1
      John Garry 提交于
      Currently printing metricgroups for core- or uncore-based events matched
      by CPUID is supported.
      
      Extend this for system events.
      Signed-off-by: NJohn Garry <john.garry@huawei.com>
      Acked-by: NKajol Jain <kjain@linux.ibm.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Joakim Zhang <qiangqing.zhang@nxp.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Kim Phillips <kim.phillips@amd.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Shaokun Zhang <zhangshaokun@hisilicon.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: linuxarm@huawei.com
      Link: http://lore.kernel.org/lkml/1607080216-36968-9-git-send-email-john.garry@huawei.com
      [ Reorder 'struct metricgroup_print_sys_idata' field to avoid alignment holes ]
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      a36fadb1
    • J
      perf metricgroup: Split up metricgroup__print() · f6fe1e48
      John Garry 提交于
      To aid supporting system event metric groups, break up the function
      metricgroup__print() into a part which iterates metrics and a part which
      actually "prints" the metric.
      
      No functional change intended.
      Signed-off-by: NJohn Garry <john.garry@huawei.com>
      Acked-by: NKajol Jain <kjain@linux.ibm.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Joakim Zhang <qiangqing.zhang@nxp.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Kim Phillips <kim.phillips@amd.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Shaokun Zhang <zhangshaokun@hisilicon.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: linuxarm@huawei.com
      Link: http://lore.kernel.org/lkml/1607080216-36968-8-git-send-email-john.garry@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      f6fe1e48
    • J
      perf metricgroup: Fix metrics using aliases covering multiple PMUs · c2337d67
      John Garry 提交于
      Support for metric expressions using aliases which cover multiple PMUs
      is broken. Consider the following test metric expression:
      
        "MetricExpr": "UNC_CBO_XSNP_RESPONSE.MISS_XCORE * UNC_CBO_XSNP_RESPONSE.MISS_EVICTION"
      
      When used on my broadwell, "perf stat" gives:
      
        unc_cbo_xsnp_response.miss_eviction -> uncore_cbox_1/umask=0x81,event=0x22/
        unc_cbo_xsnp_response.miss_eviction -> uncore_cbox_0/umask=0x81,event=0x22/
        unc_cbo_xsnp_response.miss_xcore -> uncore_cbox_1/umask=0x41,event=0x22/
        unc_cbo_xsnp_response.miss_xcore -> uncore_cbox_0/umask=0x41,event=0x22/
        Control descriptor is not initialized
        unc_cbo_xsnp_response.miss_eviction: 3645925 1000850523 1000850523
        unc_cbo_xsnp_response.miss_xcore: 106850 1000850523 1000850523
      
         Performance counter stats for 'system wide':
      
                 3,645,925      unc_cbo_xsnp_response.miss_eviction # 389567086250.00 test_metric_inc
                   106,850      unc_cbo_xsnp_response.miss_xcore
      
               1.000883096 seconds time elapsed
      
      Notice that only the results from one PMU are included. Fix the logic of
      find_evsel_group() to enable events which apply to multiple PMUs, by
      checking if the event pmu_name matches that of the metric event.
      
      With that, "perf stat" now gives:
      
        unc_cbo_xsnp_response.miss_eviction -> uncore_cbox_1/umask=0x81,event=0x22/
        unc_cbo_xsnp_response.miss_eviction -> uncore_cbox_0/umask=0x81,event=0x22/
        unc_cbo_xsnp_response.miss_xcore -> uncore_cbox_1/umask=0x41,event=0x22/
        unc_cbo_xsnp_response.miss_xcore -> uncore_cbox_0/umask=0x41,event=0x22/
        Control descriptor is not initialized
        unc_cbo_xsnp_response.miss_eviction: 4237983 1000904100 1000904100
        unc_cbo_xsnp_response.miss_xcore: 218643 1000904100 1000904100
        unc_cbo_xsnp_response.miss_eviction: 4254148 1000902629 1000902629
        unc_cbo_xsnp_response.miss_xcore: 213352 1000902629 1000902629
      
         Performance counter stats for 'system wide':
      
                 4,237,983      unc_cbo_xsnp_response.miss_eviction # 3668558131345.00 test_metric_inc
                   218,643      unc_cbo_xsnp_response.miss_xcore
                 4,254,148      unc_cbo_xsnp_response.miss_eviction
                   213,352      unc_cbo_xsnp_response.miss_xcore
      
               1.000938151 seconds time elapsed
      Signed-off-by: NJohn Garry <john.garry@huawei.com>
      Acked-by: NKajol Jain <kjain@linux.ibm.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Joakim Zhang <qiangqing.zhang@nxp.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Kim Phillips <kim.phillips@amd.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Shaokun Zhang <zhangshaokun@hisilicon.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: linuxarm@huawei.com
      Link: http://lore.kernel.org/lkml/1607080216-36968-7-git-send-email-john.garry@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      c2337d67
  13. 17 11月, 2020 1 次提交
  14. 28 9月, 2020 1 次提交
  15. 18 9月, 2020 1 次提交
    • I
      perf metricgroup: Fix uncore metric expressions · dcc81be0
      Ian Rogers 提交于
      A metric like DRAM_BW_Use has on SkylakeX events uncore_imc/cas_count_read/
      and uncore_imc/case_count_write/.
      
      These events open 6 events per socket with pmu names of
      uncore_imc_[0-5].
      
      The current metric setup code in find_evsel_group assumes one ID will
      map to 1 event to be recorded in metric_events.
      
      For events with multiple matches, the first event is recorded in
      metric_events (avoiding matching >1 event with the same name) and the
      evlist_used updated so that duplicate events aren't removed when the
      evlist has unused events removed.
      
      Before this change:
      
        $ /tmp/perf/perf stat -M DRAM_BW_Use -a -- sleep 1
      
         Performance counter stats for 'system wide':
      
                     41.14 MiB  uncore_imc/cas_count_read/
             1,002,614,251 ns   duration_time
      
               1.002614251 seconds time elapsed
      
      After this change:
      
        $ /tmp/perf/perf stat -M DRAM_BW_Use -a -- sleep 1
      
         Performance counter stats for 'system wide':
      
                    157.47 MiB  uncore_imc/cas_count_read/ #     0.00 DRAM_BW_Use
                    126.97 MiB  uncore_imc/cas_count_write/
             1,003,019,728 ns   duration_time
      
      Erroneous duplication introduced in:
      commit 2440689d ("perf metricgroup: Remove duped metric group events").
      
      Fixes: ded80bda ("perf expr: Migrate expr ids table to a hashmap").
      Reported-by: NJin Yao <yao.jin@linux.intel.com>
      Signed-off-by: NIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Andrii Nakryiko <andriin@fb.com>
      Cc: Athira Jajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: John Fastabend <john.fastabend@gmail.com>
      Cc: KP Singh <kpsingh@chromium.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Martin KaFai Lau <kafai@fb.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Yonghong Song <yhs@fb.com>
      Cc: bpf@vger.kernel.org
      Cc: netdev@vger.kernel.org
      Link: http://lore.kernel.org/lkml/20200917201807.4090224-1-irogers@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      dcc81be0
  16. 15 9月, 2020 4 次提交
    • N
      perf metric: Do not free metric when failed to resolve · 6f47ed6c
      Namhyung Kim 提交于
      It's dangerous to free the original metric when it's called from
      resolve_metric() as it's already in the metric_list and might have other
      resources too.  Instead, it'd better let them bail out and be released
      properly at the later stage.
      
      So add a check when it's called from metricgroup__add_metric() and
      release it.  Also make sure that mp is set properly.
      
      Fixes: 83de0b7d ("perf metric: Collect referenced metrics in struct metric_ref_node")
      Signed-off-by: NNamhyung Kim <namhyung@kernel.org>
      Acked-by: NJiri Olsa <jolsa@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: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20200915031819.386559-10-namhyung@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      6f47ed6c
    • N
      perf metric: Free metric when it failed to resolve · 27adafcd
      Namhyung Kim 提交于
      The metricgroup__add_metric() can find multiple match for a metric group
      and it's possible to fail.  Also it can fail in the middle like in
      resolve_metric() even for single metric.
      
      In those cases, the intermediate list and ids will be leaked like:
      
        Direct leak of 3 byte(s) in 1 object(s) allocated from:
          #0 0x7f4c938f40b5 in strdup (/lib/x86_64-linux-gnu/libasan.so.5+0x920b5)
          #1 0x55f7e71c1bef in __add_metric util/metricgroup.c:683
          #2 0x55f7e71c31d0 in add_metric util/metricgroup.c:906
          #3 0x55f7e71c3844 in metricgroup__add_metric util/metricgroup.c:940
          #4 0x55f7e71c488d in metricgroup__add_metric_list util/metricgroup.c:993
          #5 0x55f7e71c488d in parse_groups util/metricgroup.c:1045
          #6 0x55f7e71c60a4 in metricgroup__parse_groups_test util/metricgroup.c:1087
          #7 0x55f7e71235ae in __compute_metric tests/parse-metric.c:164
          #8 0x55f7e7124650 in compute_metric tests/parse-metric.c:196
          #9 0x55f7e7124650 in test_recursion_fail tests/parse-metric.c:318
          #10 0x55f7e7124650 in test__parse_metric tests/parse-metric.c:356
          #11 0x55f7e70be09b in run_test tests/builtin-test.c:410
          #12 0x55f7e70be09b in test_and_print tests/builtin-test.c:440
          #13 0x55f7e70c101a in __cmd_test tests/builtin-test.c:661
          #14 0x55f7e70c101a in cmd_test tests/builtin-test.c:807
          #15 0x55f7e7126214 in run_builtin /home/namhyung/project/linux/tools/perf/perf.c:312
          #16 0x55f7e6fc41a8 in handle_internal_command /home/namhyung/project/linux/tools/perf/perf.c:364
          #17 0x55f7e6fc41a8 in run_argv /home/namhyung/project/linux/tools/perf/perf.c:408
          #18 0x55f7e6fc41a8 in main /home/namhyung/project/linux/tools/perf/perf.c:538
          #19 0x7f4c93492cc9 in __libc_start_main ../csu/libc-start.c:308
      
      Fixes: 83de0b7d ("perf metric: Collect referenced metrics in struct metric_ref_node")
      Signed-off-by: NNamhyung Kim <namhyung@kernel.org>
      Acked-by: NJiri Olsa <jolsa@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: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20200915031819.386559-9-namhyung@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      27adafcd
    • N
      perf metric: Fix some memory leaks - part 2 · b033ab11
      Namhyung Kim 提交于
      The metric_event_delete() missed to free expr->metric_events and it
      should free an expr when metric_refs allocation failed.
      
      Fixes: 4ea28967 ("perf metric: Collect referenced metrics in struct metric_expr")
      Signed-off-by: NNamhyung Kim <namhyung@kernel.org>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20200915031819.386559-3-namhyung@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      b033ab11
    • N
      perf metric: Fix some memory leaks · 4f57a1ed
      Namhyung Kim 提交于
      I found some memory leaks while reading the metric code.  Some are real
      and others only occur in the error path.  When it failed during metric
      or event parsing, it should release all resources properly.
      
      Fixes: b18f3e36 ("perf stat: Support JSON metrics in perf stat")
      Signed-off-by: NNamhyung Kim <namhyung@kernel.org>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lore.kernel.org/lkml/20200915031819.386559-2-namhyung@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      4f57a1ed