Patch "perf header: Fix missing PMU caps" has been added to the 6.5-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

    perf header: Fix missing PMU caps

to the 6.5-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-header-fix-missing-pmu-caps.patch
and it can be found in the queue-6.5 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 21b10f53515ab092024a608c048d598bae2db9f8
Author: Ian Rogers <irogers@xxxxxxxxxx>
Date:   Thu Aug 24 19:39:57 2023 -0700

    perf header: Fix missing PMU caps
    
    [ Upstream commit 9897009eecae821efc684ecdd1d04584f5501509 ]
    
    PMU caps are written as HEADER_PMU_CAPS or for the special case of the
    PMU "cpu" as HEADER_CPU_PMU_CAPS. As the PMU "cpu" is special, and not
    any "core" PMU, the logic had become broken and core PMUs not called
    "cpu" were not having their caps written.
    
    This affects ARM and s390 non-hybrid PMUs.
    
    Simplify the PMU caps writing logic to scan one fewer time and to be
    more explicit in its behavior.
    
    Fixes: 178ddf3bad981380 ("perf header: Avoid hybrid PMU list in write_pmu_caps")
    Reported-by: Wei Li <liwei391@xxxxxxxxxx>
    Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
    Cc: Adrian Hunter <adrian.hunter@xxxxxxxxx>
    Cc: Alexander Shishkin <alexander.shishkin@xxxxxxxxxxxxxxx>
    Cc: Athira Rajeev <atrajeev@xxxxxxxxxxxxxxxxxx>
    Cc: Huacai Chen <chenhuacai@xxxxxxxxxx>
    Cc: Ian Rogers <irogers@xxxxxxxxxx>
    Cc: Ingo Molnar <mingo@xxxxxxxxxx>
    Cc: James Clark <james.clark@xxxxxxx>
    Cc: Jiri Olsa <jolsa@xxxxxxxxxx>
    Cc: John Garry <john.g.garry@xxxxxxxxxx>
    Cc: K Prateek Nayak <kprateek.nayak@xxxxxxx>
    Cc: Kajol Jain <kjain@xxxxxxxxxxxxx>
    Cc: Kan Liang <kan.liang@xxxxxxxxxxxxxxx>
    Cc: Leo Yan <leo.yan@xxxxxxxxxx>
    Cc: Mark Rutland <mark.rutland@xxxxxxx>
    Cc: Mike Leach <mike.leach@xxxxxxxxxx>
    Cc: Ming Wang <wangming01@xxxxxxxxxxx>
    Cc: Namhyung Kim <namhyung@xxxxxxxxxx>
    Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
    Cc: Ravi Bangoria <ravi.bangoria@xxxxxxx>
    Cc: Sean Christopherson <seanjc@xxxxxxxxxx>
    Cc: Suzuki Poulouse <suzuki.poulose@xxxxxxx>
    Cc: Will Deacon <will@xxxxxxxxxx>
    Cc: linux-arm-kernel@xxxxxxxxxxxxxxxxxxx
    Link: https://lore.kernel.org/r/20230825024002.801955-2-irogers@xxxxxxxxxx
    Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 52fbf526fe74a..13c71d28e0eb3 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -1605,8 +1605,15 @@ static int write_pmu_caps(struct feat_fd *ff,
 	int ret;
 
 	while ((pmu = perf_pmus__scan(pmu))) {
-		if (!pmu->name || !strcmp(pmu->name, "cpu") ||
-		    perf_pmu__caps_parse(pmu) <= 0)
+		if (!strcmp(pmu->name, "cpu")) {
+			/*
+			 * The "cpu" PMU is special and covered by
+			 * HEADER_CPU_PMU_CAPS. Note, core PMUs are
+			 * counted/written here for ARM, s390 and Intel hybrid.
+			 */
+			continue;
+		}
+		if (perf_pmu__caps_parse(pmu) <= 0)
 			continue;
 		nr_pmu++;
 	}
@@ -1619,23 +1626,17 @@ static int write_pmu_caps(struct feat_fd *ff,
 		return 0;
 
 	/*
-	 * Write hybrid pmu caps first to maintain compatibility with
-	 * older perf tool.
+	 * Note older perf tools assume core PMUs come first, this is a property
+	 * of perf_pmus__scan.
 	 */
-	if (perf_pmus__num_core_pmus() > 1) {
-		pmu = NULL;
-		while ((pmu = perf_pmus__scan_core(pmu))) {
-			ret = __write_pmu_caps(ff, pmu, true);
-			if (ret < 0)
-				return ret;
-		}
-	}
-
 	pmu = NULL;
 	while ((pmu = perf_pmus__scan(pmu))) {
-		if (pmu->is_core || !pmu->nr_caps)
+		if (!strcmp(pmu->name, "cpu")) {
+			/* Skip as above. */
+			continue;
+		}
+		if (perf_pmu__caps_parse(pmu) <= 0)
 			continue;
-
 		ret = __write_pmu_caps(ff, pmu, true);
 		if (ret < 0)
 			return ret;



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux