Patch "perf jevents: fix breakage when do perf stat on system metric" has been added to the 6.12-stable tree

gregkh at linuxfoundation.org gregkh at linuxfoundation.org
Fri Dec 6 04:08:06 PST 2024


This is a note to let you know that I've just added the patch titled

    perf jevents: fix breakage when do perf stat on system metric

to the 6.12-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     perf-jevents-fix-breakage-when-do-perf-stat-on-system-metric.patch
and it can be found in the queue-6.12 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable at vger.kernel.org> know about it.


>From 4a159e6049f319bef6f9e6d2ccdd322f57d24830 Mon Sep 17 00:00:00 2001
From: Xu Yang <xu.yang_2 at nxp.com>
Date: Thu, 7 Nov 2024 08:20:28 -0800
Subject: perf jevents: fix breakage when do perf stat on system metric
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

From: Xu Yang <xu.yang_2 at nxp.com>

commit 4a159e6049f319bef6f9e6d2ccdd322f57d24830 upstream.

When do perf stat on sys metric, perf tool output nothing now:

  $ perf stat -a -M imx95_ddr_read.all -I 1000
  $

This command runs on an arm64 machine and the Soc has one DDR hw pmu
except one armv8_cortex_a55 pmu. Their maps show as follows:

const struct pmu_events_map pmu_events_map[] = {
{
	.arch = "arm64",
	.cpuid = "0x00000000410fd050",
	.event_table = {
		.pmus = pmu_events__arm_cortex_a55,
		.num_pmus = ARRAY_SIZE(pmu_events__arm_cortex_a55)
	},
	.metric_table = {
		.pmus = NULL,
		.num_pmus = 0
	}
},

static const struct pmu_sys_events pmu_sys_event_tables[] = {
{
	.event_table = {
		.pmus = pmu_events__freescale_imx95_sys,
		.num_pmus = ARRAY_SIZE(pmu_events__freescale_imx95_sys)
	},
	.metric_table = {
		.pmus = pmu_metrics__freescale_imx95_sys,
		.num_pmus = ARRAY_SIZE(pmu_metrics__freescale_imx95_sys)
	},
	.name = "pmu_events__freescale_imx95_sys",
},

Currently, pmu_metrics_table__find() will return NULL when only do perf
stat on sys metric. Then parse_groups() will never be called to parse
sys metric_name, finally perf tool will exit directly. This should be a
common problem.

To fix the issue, this will keep the logic before commit f20c15d13f01
("perf pmu-events: Remember the perf_events_map for a PMU") to return a
empty metric table rather than a NULL pointer.

This should be fine since the removed part just check if the table match
provided metric_name.  Without these code, the code in parse_groups()
will also check the validity of metrci_name too.

Fixes: f20c15d13f017d4b ("perf pmu-events: Remember the perf_events_map for a PMU")
Reviewed-by: James Clark <james.clark at linaro.org>
Signed-off-by: Xu Yang <xu.yang_2 at nxp.com>
Tested-by: Xu Yang <xu.yang_2 at nxp.com>
Acked-by: Ian Rogers <irogers at google.com>
Cc: Adrian Hunter <adrian.hunter at intel.com>
Cc: Albert Ou <aou at eecs.berkeley.edu>
Cc: Alexander Shishkin <alexander.shishkin at linux.intel.com>
Cc: Alexandre Ghiti <alexghiti at rivosinc.com>
Cc: Athira Rajeev <atrajeev at linux.vnet.ibm.com>
Cc: Benjamin Gray <bgray at linux.ibm.com>
Cc: Ben Zong-You Xie <ben717 at andestech.com>
Cc: Bibo Mao <maobibo at loongson.cn>
Cc: Clément Le Goffic <clement.legoffic at foss.st.com>
Cc: Dima Kogan <dima at secretsauce.net>
Cc: Dr. David Alan Gilbert <linux at treblig.org>
Cc: Huacai Chen <chenhuacai at kernel.org>
Cc: Ingo Molnar <mingo at redhat.com>
Cc: Jiri Olsa <jolsa at kernel.org>
Cc: John Garry <john.g.garry at oracle.com>
Cc: Kan Liang <kan.liang at linux.intel.com>
Cc: Leo Yan <leo.yan at linux.dev>
Cc: Mark Rutland <mark.rutland at arm.com>
Cc: Masami Hiramatsu <mhiramat at kernel.org>
Cc: Mike Leach <mike.leach at linaro.org>
Cc: Namhyung Kim <namhyung at kernel.org>
Cc: Palmer Dabbelt <palmer at dabbelt.com>
Cc: Paul Walmsley <paul.walmsley at sifive.com>
Cc: Peter Zijlstra <peterz at infradead.org>
Cc: Ravi Bangoria <ravi.bangoria at amd.com>
Cc: Sandipan Das <sandipan.das at amd.com>
Cc: Will Deacon <will at kernel.org>
Cc: Yicong Yang <yangyicong at hisilicon.com>
Cc: linux-arm-kernel at lists.infradead.org
Cc: linux-riscv at lists.infradead.org
Cc: stable at vger.kernel.org
Link: https://lore.kernel.org/r/20241107162035.52206-2-irogers@google.com
Signed-off-by: Ian Rogers <irogers at google.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme at redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh at linuxfoundation.org>
---
 tools/perf/pmu-events/empty-pmu-events.c |   12 +-----------
 tools/perf/pmu-events/jevents.py         |   12 +-----------
 2 files changed, 2 insertions(+), 22 deletions(-)

--- a/tools/perf/pmu-events/empty-pmu-events.c
+++ b/tools/perf/pmu-events/empty-pmu-events.c
@@ -539,17 +539,7 @@ const struct pmu_metrics_table *perf_pmu
         if (!map)
                 return NULL;
 
-        if (!pmu)
-                return &map->metric_table;
-
-        for (size_t i = 0; i < map->metric_table.num_pmus; i++) {
-                const struct pmu_table_entry *table_pmu = &map->metric_table.pmus[i];
-                const char *pmu_name = &big_c_string[table_pmu->pmu_name.offset];
-
-                if (pmu__name_match(pmu, pmu_name))
-                           return &map->metric_table;
-        }
-        return NULL;
+	return &map->metric_table;
 }
 
 const struct pmu_events_table *find_core_events_table(const char *arch, const char *cpuid)
--- a/tools/perf/pmu-events/jevents.py
+++ b/tools/perf/pmu-events/jevents.py
@@ -1089,17 +1089,7 @@ const struct pmu_metrics_table *perf_pmu
         if (!map)
                 return NULL;
 
-        if (!pmu)
-                return &map->metric_table;
-
-        for (size_t i = 0; i < map->metric_table.num_pmus; i++) {
-                const struct pmu_table_entry *table_pmu = &map->metric_table.pmus[i];
-                const char *pmu_name = &big_c_string[table_pmu->pmu_name.offset];
-
-                if (pmu__name_match(pmu, pmu_name))
-                           return &map->metric_table;
-        }
-        return NULL;
+	return &map->metric_table;
 }
 
 const struct pmu_events_table *find_core_events_table(const char *arch, const char *cpuid)


Patches currently in stable-queue which might be from xu.yang_2 at nxp.com are

queue-6.12/perf-jevents-fix-breakage-when-do-perf-stat-on-system-metric.patch



More information about the linux-arm-kernel mailing list