Skip to contentSkip to conversation

perf stat: Suppress warning when using cpum_cf events on s390

PATCH Applied Thomas Richter 2 participants 2 messages Mar 16, 2023 – Mar 24, 2023 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf stat: Suppress warning when using cpum_cf events on s390

Running command perf stat -vv -e cpu_cycles -C0 -- true displays this warning:

Attempting to add event pmu 'cpum_cf' with 'cpu_cycles,' that may result in non-fatal errors

Make the PMU cpum_cf selectable and avoid this warning. While at it also fix this warning for PMUs pai_crypto and pai_ext.

Output before:

# ./perf stat -vv -e cpu_cycles -C0 -- true Using CPUID IBM,3931,704,A01,3.7,002f Attempting to add event pmu 'cpum_cf' with 'cpu_cycles,'
that may result in non-fatal errors
After aliases, add event pmu 'cpum_cf' with 'event,'
that may result in non-fatal errors cpu_cycles -> cpum_cf/event=0/
Control descriptor is not initialized
------------------------------------------------------------
perf_event_attr:

  type                             10
  size                             128
  config                           0x1001
  sample_type                      IDENTIFIER
  read_format                      TOTAL_TIME_ENABLED|TOTAL_TIME_RUNNING
  disabled                         1
  inherit                          1
  exclude_guest                    1

------------------------------------------------------------
sys_perf_event_open: pid -1 cpu 0 group_fd -1 flags 0x8 = 3
cpu_cycles: 0: 290434 2479172 2479172:
cpu_cycles: 290434 2479172 2479172

Performance counter stats for 'CPU(s) 0':

           290,434      cpu_cycles

       0.002465617 seconds time elapsed

#

Now the warning "Attempting to add event pmu 'cpum_cf' ..." does not show up anymore.

Output after:

 # ./perf stat -vv -e cpu_cycles -C0 -- true
 Using CPUID IBM,3931,704,A01,3.7,002f
 After aliases, add event pmu 'cpum_cf' with 'event,'
   that may result in non-fatal errors
   cpu_cycles -> cpum_cf/event=0/
 Control descriptor is not initialized
 ....

Performance counter stats for 'CPU(s) 0':

           357,023      cpu_cycles

       0.002454995 seconds time elapsed

#

---
 tools/perf/arch/s390/util/Build |  1 +
 tools/perf/arch/s390/util/pmu.c | 23 +++++++++++++++++++++++
 2 files changed, 24 insertions(+)
 create mode 100644 tools/perf/arch/s390/util/pmu.c
tools/perf/arch/s390/util/Build +1 -0
index db6884086997..fa66f15a14ec 100644
@@ -6,5 +6,6 @@ perf-$(CONFIG_DWARF) += dwarf-regs.o
 perf-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o
 
 perf-y += machine.o
+perf-y += pmu.o
 
 perf-$(CONFIG_AUXTRACE) += auxtrace.o
tools/perf/arch/s390/util/pmu.c new file +23 -0
new file mode 100644
index 000000000000..11f03f32e3fd
@@ -0,0 +1,23 @@
+// SPDX-License-Identifier: GPL-2.0
+
+/*
+ * Copyright IBM Corp. 2023
+ * Author(s): Thomas Richter <[email protected]>
+ */
+
+#include <string.h>
+
+#include "../../../util/pmu.h"
+
+#define	S390_PMUPAI_CRYPTO	"pai_crypto"
+#define	S390_PMUPAI_EXT		"pai_ext"
+#define	S390_PMUCPUM_CF		"cpum_cf"
+
+struct perf_event_attr *perf_pmu__get_default_config(struct perf_pmu *pmu)
+{
+	if (!strcmp(pmu->name, S390_PMUPAI_CRYPTO) ||
+	    !strcmp(pmu->name, S390_PMUPAI_EXT) ||
+	    !strcmp(pmu->name, S390_PMUCPUM_CF))
+		pmu->selectable = true;
+	return NULL;
+}
Signature · 1 line
2.39.1
maintainer Applied
#1 lore raw

Em Thu, Mar 16, 2023 at 08:49:46AM +0100, Thomas Richter escreveu:

Quoted 10 lines

Running command perf stat -vv -e cpu_cycles -C0 -- true displays this warning:

Attempting to add event pmu 'cpum_cf' with 'cpu_cycles,' that may result in non-fatal errors

Make the PMU cpum_cf selectable and avoid this warning. While at it also fix this warning for PMUs pai_crypto and pai_ext.

Output before:

Thanks, applied.

- Arnaldo

Quoted 99 lines

# ./perf stat -vv -e cpu_cycles -C0 -- true Using CPUID IBM,3931,704,A01,3.7,002f Attempting to add event pmu 'cpum_cf' with 'cpu_cycles,'
that may result in non-fatal errors
After aliases, add event pmu 'cpum_cf' with 'event,'
that may result in non-fatal errors cpu_cycles -> cpum_cf/event=0/
Control descriptor is not initialized
------------------------------------------------------------
perf_event_attr:

  type                             10
  size                             128
  config                           0x1001
  sample_type                      IDENTIFIER
  read_format                      TOTAL_TIME_ENABLED|TOTAL_TIME_RUNNING
  disabled                         1
  inherit                          1
  exclude_guest                    1

------------------------------------------------------------
sys_perf_event_open: pid -1 cpu 0 group_fd -1 flags 0x8 = 3
cpu_cycles: 0: 290434 2479172 2479172:
cpu_cycles: 290434 2479172 2479172

Performance counter stats for 'CPU(s) 0':

           290,434      cpu_cycles

       0.002465617 seconds time elapsed

#

Now the warning "Attempting to add event pmu 'cpum_cf' ..." does not show up anymore.

Output after:

 # ./perf stat -vv -e cpu_cycles -C0 -- true
 Using CPUID IBM,3931,704,A01,3.7,002f
 After aliases, add event pmu 'cpum_cf' with 'event,'
   that may result in non-fatal errors
   cpu_cycles -> cpum_cf/event=0/
 Control descriptor is not initialized
 ....

Performance counter stats for 'CPU(s) 0':

           357,023      cpu_cycles

       0.002454995 seconds time elapsed

#

---
 tools/perf/arch/s390/util/Build |  1 +
 tools/perf/arch/s390/util/pmu.c | 23 +++++++++++++++++++++++
 2 files changed, 24 insertions(+)
 create mode 100644 tools/perf/arch/s390/util/pmu.c
tools/perf/arch/s390/util/Build +1 -0
index db6884086997..fa66f15a14ec 100644
@@ -6,5 +6,6 @@ perf-$(CONFIG_DWARF) += dwarf-regs.o
 perf-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o
 
 perf-y += machine.o
+perf-y += pmu.o
 
 perf-$(CONFIG_AUXTRACE) += auxtrace.o
tools/perf/arch/s390/util/pmu.c new file +23 -0
new file mode 100644
index 000000000000..11f03f32e3fd
@@ -0,0 +1,23 @@
+// SPDX-License-Identifier: GPL-2.0
+
+/*
+ * Copyright IBM Corp. 2023
+ * Author(s): Thomas Richter <[email protected]>
+ */
+
+#include <string.h>
+
+#include "../../../util/pmu.h"
+
+#define	S390_PMUPAI_CRYPTO	"pai_crypto"
+#define	S390_PMUPAI_EXT		"pai_ext"
+#define	S390_PMUCPUM_CF		"cpum_cf"
+
+struct perf_event_attr *perf_pmu__get_default_config(struct perf_pmu *pmu)
+{
+	if (!strcmp(pmu->name, S390_PMUPAI_CRYPTO) ||
+	    !strcmp(pmu->name, S390_PMUPAI_EXT) ||
+	    !strcmp(pmu->name, S390_PMUCPUM_CF))
+		pmu->selectable = true;
+	return NULL;
+}
Signature · 1 line
2.39.1
Signature · 1 line
- Arnaldo