lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240319095043.857594-2-tmricht@linux.ibm.com>
Date: Tue, 19 Mar 2024 10:50:43 +0100
From: Thomas Richter <tmricht@...ux.ibm.com>
To: linux-kernel@...r.kernel.org, linux-perf-users@...r.kernel.org,
        acme@...nel.org, irogers@...gle.com, namhyung@...nel.org
Cc: svens@...ux.ibm.com, gor@...ux.ibm.com, sumanthk@...ux.ibm.com,
        hca@...ux.ibm.com, Thomas Richter <tmricht@...ux.ibm.com>
Subject: [PATCH 2/2] perf list: do not print metrics on s390 zvm systems

On s390 z/VM virtual machines command perf list also displays metrics:

 # ./perf list | grep -A 20 'Metric Groups:'
 Metric Groups:

 No_group:
  cpi
       [Cycles per Instruction]
  est_cpi
       [Estimated Instruction Complexity CPI infinite Level 1]
  finite_cpi
       [Cycles per Instructions from Finite cache/memory]
  l1mp
       [Level One Miss per 100 Instructions]
  l2p
       [Percentage sourced from Level 2 cache]
  l3p
       [Percentage sourced from Level 3 on same chip cache]
  l4lp
       [Percentage sourced from Level 4 Local cache on same book]
  l4rp
       [Percentage sourced from Level 4 Remote cache on different book]
  memp
       [Percentage sourced from memory]
  ....
 #

This is not correct, on s390 z/VM virtual machines the referenced
CPU Counter Measurement facility does not exist. The command

 # ./perf stat -M cpi -- true
 event syntax error: '{CPU_CYCLES/metric-id=CPU_CYCLES/.....'
                       \___ Bad event or PMU

 Unable to find PMU or event on a PMU of 'CPU_CYCLES'

 event syntax error: '{CPU_CYCLES/metric-id=CPU_CYCLES/...'
                       \___ Cannot find PMU `CPU_CYCLES'.
			    Missing kernel support?
 #

fails.

Perf list should not display the metrics when the referenced
CPU Counter Measurement PMU is not available.

Output after:
 # ./perf list | grep -A 20 'Metric Groups:'
 #

Fixes: 7f76b3113068 ("perf list: Add IBM z16 event description for s390")
Signed-off-by: Thomas Richter <tmricht@...ux.ibm.com>
Acked-by: Sumanth Korikkar <sumanthk@...ux.ibm.com>
---
 tools/perf/arch/s390/util/pmu.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/tools/perf/arch/s390/util/pmu.c b/tools/perf/arch/s390/util/pmu.c
index 886c30e001fa..2dc27acc860c 100644
--- a/tools/perf/arch/s390/util/pmu.c
+++ b/tools/perf/arch/s390/util/pmu.c
@@ -8,6 +8,7 @@
 #include <string.h>
 
 #include "../../../util/pmu.h"
+#include "../../../util/pmus.h"
 
 #define	S390_PMUPAI_CRYPTO	"pai_crypto"
 #define	S390_PMUPAI_EXT		"pai_ext"
@@ -20,3 +21,19 @@ void perf_pmu__arch_init(struct perf_pmu *pmu)
 	    !strcmp(pmu->name, S390_PMUCPUM_CF))
 		pmu->selectable = true;
 }
+
+const struct pmu_metrics_table *pmu_metrics_table__find(void)
+{
+	struct perf_pmu *pmu;
+
+	/*
+	 * Metrics defined on events from PMU cpum_cf aren't supported
+	 * on z/VM. Make sure the PMU exists and return NULL if that
+	 * PMU cannot be found.
+	 */
+	pmu = perf_pmus__find("cpum_cf");
+	if (pmu)
+		return perf_pmu__find_metrics_table(pmu);
+
+	return NULL;
+}
-- 
2.44.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ