Skip to contentSkip to conversation

perf test: Add perf_event_attr tests for the arm_spe event

PATCH Applied German Gomez 4 participants 7 messages Jan 26, 2022 – Mar 5, 2022

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf test: Add perf_event_attr tests for the arm_spe event

Adds a couple of perf_event_attr tests for the fix introduced in [1]. The tests check that the correct sample_period value is set in the struct perf_event_attr of the arm_spe events.

[1]: https://lore.kernel.org/all/[email protected]/

---
 tools/perf/tests/attr/README                  |  2 +
 tools/perf/tests/attr/base-record-spe         | 40 +++++++++++++++++++
 tools/perf/tests/attr/test-record-spe-period  | 12 ++++++
 .../tests/attr/test-record-spe-period-term    | 12 ++++++
 4 files changed, 66 insertions(+)
 create mode 100644 tools/perf/tests/attr/base-record-spe
 create mode 100644 tools/perf/tests/attr/test-record-spe-period
 create mode 100644 tools/perf/tests/attr/test-record-spe-period-term
tools/perf/tests/attr/README +2 -0
index 1116fc6bf2ac..454505d343fa 100644
@@ -58,6 +58,8 @@ Following tests are defined (with perf commands):
   perf record -c 100 -P kill                    (test-record-period)
   perf record -c 1 --pfm-events=cycles:period=2 (test-record-pfm-period)
   perf record -R kill                           (test-record-raw)
+  perf record -c 2 -e arm_spe_0// -- kill       (test-record-spe-period)
+  perf record -e arm_spe_0/period=3/ -- kill    (test-record-spe-period-term)
   perf stat -e cycles kill                      (test-stat-basic)
   perf stat kill                                (test-stat-default)
   perf stat -d kill                             (test-stat-detailed-1)
tools/perf/tests/attr/base-record-spe new file +40 -0
new file mode 100644
index 000000000000..08fa96b59240
@@ -0,0 +1,40 @@
+[event]
+fd=*
+group_fd=-1
+flags=*
+cpu=*
+type=*
+size=*
+config=*
+sample_period=*
+sample_type=*
+read_format=*
+disabled=*
+inherit=*
+pinned=*
+exclusive=*
+exclude_user=*
+exclude_kernel=*
+exclude_hv=*
+exclude_idle=*
+mmap=*
+comm=*
+freq=*
+inherit_stat=*
+enable_on_exec=*
+task=*
+watermark=*
+precise_ip=*
+mmap_data=*
+sample_id_all=*
+exclude_host=*
+exclude_guest=*
+exclude_callchain_kernel=*
+exclude_callchain_user=*
+wakeup_events=*
+bp_type=*
+config1=*
+config2=*
+branch_sample_type=*
+sample_regs_user=*
+sample_stack_user=*
tools/perf/tests/attr/test-record-spe-period new file +12 -0
new file mode 100644
index 000000000000..75f8c9cd8e3f
@@ -0,0 +1,12 @@
+[config]
+command = record
+args    = --no-bpf-event -c 2 -e arm_spe_0// -- kill >/dev/null 2>&1
+ret     = 1
+arch    = aarch64
+
+[event-10:base-record-spe]
+sample_period=2
+freq=0
+
+# dummy event
+[event-1:base-record-spe]
tools/perf/tests/attr/test-record-spe-period-term new file +12 -0
new file mode 100644
index 000000000000..8f60a4fec657
@@ -0,0 +1,12 @@
+[config]
+command = record
+args    = --no-bpf-event -e arm_spe_0/period=3/ -- kill >/dev/null 2>&1
+ret     = 1
+arch    = aarch64
+
+[event-10:base-record-spe]
+sample_period=3
+freq=0
+
+# dummy event
+[event-1:base-record-spe]
Signature · 1 line
2.25.1
#1 lore raw

Hi German,

Quoted 7 lines · German Gomez

Adds a couple of perf_event_attr tests for the fix introduced in [1]. The tests check that the correct sample_period value is set in the struct perf_event_attr of the arm_spe events.

[1]: https://lore.kernel.org/all/[email protected]/

I tested this patch with two commands:

# PERF_TEST_ATTR=/tmp /usr/bin/python2 ./tests/attr.py -d ./tests/attr/ \
-p ./perf -vvvvv -t test-record-spe-period
# PERF_TEST_ATTR=/tmp /usr/bin/python2 ./tests/attr.py -d ./tests/attr/ \
-p ./perf -vvvvv -t test-record-spe-period-term

Both testing can pass on Hisilicon D06 board.

One question: I'm a bit concern this case will fail on some Arm64 platforms which doesn't contain Arm SPE modules. E.g. below commands will always fail on Arm64 platforms if SPE module is absent. So I am wandering if we can add extra checking ARM SPE event is existed or not?

  # ./perf test list
   17: Setup struct perf_event_attr
  # ./perf test 17

Thanks,
Leo

Quoted 108 lines
---
 tools/perf/tests/attr/README                  |  2 +
 tools/perf/tests/attr/base-record-spe         | 40 +++++++++++++++++++
 tools/perf/tests/attr/test-record-spe-period  | 12 ++++++
 .../tests/attr/test-record-spe-period-term    | 12 ++++++
 4 files changed, 66 insertions(+)
 create mode 100644 tools/perf/tests/attr/base-record-spe
 create mode 100644 tools/perf/tests/attr/test-record-spe-period
 create mode 100644 tools/perf/tests/attr/test-record-spe-period-term
tools/perf/tests/attr/README +2 -0
index 1116fc6bf2ac..454505d343fa 100644
@@ -58,6 +58,8 @@ Following tests are defined (with perf commands):
   perf record -c 100 -P kill                    (test-record-period)
   perf record -c 1 --pfm-events=cycles:period=2 (test-record-pfm-period)
   perf record -R kill                           (test-record-raw)
+  perf record -c 2 -e arm_spe_0// -- kill       (test-record-spe-period)
+  perf record -e arm_spe_0/period=3/ -- kill    (test-record-spe-period-term)
   perf stat -e cycles kill                      (test-stat-basic)
   perf stat kill                                (test-stat-default)
   perf stat -d kill                             (test-stat-detailed-1)
tools/perf/tests/attr/base-record-spe new file +40 -0
new file mode 100644
index 000000000000..08fa96b59240
@@ -0,0 +1,40 @@
+[event]
+fd=*
+group_fd=-1
+flags=*
+cpu=*
+type=*
+size=*
+config=*
+sample_period=*
+sample_type=*
+read_format=*
+disabled=*
+inherit=*
+pinned=*
+exclusive=*
+exclude_user=*
+exclude_kernel=*
+exclude_hv=*
+exclude_idle=*
+mmap=*
+comm=*
+freq=*
+inherit_stat=*
+enable_on_exec=*
+task=*
+watermark=*
+precise_ip=*
+mmap_data=*
+sample_id_all=*
+exclude_host=*
+exclude_guest=*
+exclude_callchain_kernel=*
+exclude_callchain_user=*
+wakeup_events=*
+bp_type=*
+config1=*
+config2=*
+branch_sample_type=*
+sample_regs_user=*
+sample_stack_user=*
tools/perf/tests/attr/test-record-spe-period new file +12 -0
new file mode 100644
index 000000000000..75f8c9cd8e3f
@@ -0,0 +1,12 @@
+[config]
+command = record
+args    = --no-bpf-event -c 2 -e arm_spe_0// -- kill >/dev/null 2>&1
+ret     = 1
+arch    = aarch64
+
+[event-10:base-record-spe]
+sample_period=2
+freq=0
+
+# dummy event
+[event-1:base-record-spe]
tools/perf/tests/attr/test-record-spe-period-term new file +12 -0
new file mode 100644
index 000000000000..8f60a4fec657
@@ -0,0 +1,12 @@
+[config]
+command = record
+args    = --no-bpf-event -e arm_spe_0/period=3/ -- kill >/dev/null 2>&1
+ret     = 1
+arch    = aarch64
+
+[event-10:base-record-spe]
+sample_period=3
+freq=0
+
+# dummy event
+[event-1:base-record-spe]
Signature · 1 line
2.25.1
#2 lore raw

Hi Leo, thanks for checking this

Quoted 17 lines · Leo Yan

Hi German,

Quoted 7 lines · German Gomez

Adds a couple of perf_event_attr tests for the fix introduced in [1]. The tests check that the correct sample_period value is set in the struct perf_event_attr of the arm_spe events.

[1]: https://lore.kernel.org/all/[email protected]/

I tested this patch with two commands:

# PERF_TEST_ATTR=/tmp /usr/bin/python2 ./tests/attr.py -d ./tests/attr/ \
-p ./perf -vvvvv -t test-record-spe-period
# PERF_TEST_ATTR=/tmp /usr/bin/python2 ./tests/attr.py -d ./tests/attr/ \
-p ./perf -vvvvv -t test-record-spe-period-term

Quoted 6 lines

Both testing can pass on Hisilicon D06 board.

One question: I'm a bit concern this case will fail on some Arm64 platforms which doesn't contain Arm SPE modules. E.g. below commands will always fail on Arm64 platforms if SPE module is absent. So I am wandering if we can add extra checking ARM SPE event is existed or not?


The test reports "unsupported" if the return code and the 'ret' field don't match.

When I unload the SPE module:

running './tests/attr//test-record-spe-period-term' test limitation 'aarch64'
unsupp  './tests/attr//test-record-spe-period-term'

Quoted 116 lines
  # ./perf test list
   17: Setup struct perf_event_attr
  # ./perf test 17

Thanks,
Leo

Quoted 108 lines
---
 tools/perf/tests/attr/README                  |  2 +
 tools/perf/tests/attr/base-record-spe         | 40 +++++++++++++++++++
 tools/perf/tests/attr/test-record-spe-period  | 12 ++++++
 .../tests/attr/test-record-spe-period-term    | 12 ++++++
 4 files changed, 66 insertions(+)
 create mode 100644 tools/perf/tests/attr/base-record-spe
 create mode 100644 tools/perf/tests/attr/test-record-spe-period
 create mode 100644 tools/perf/tests/attr/test-record-spe-period-term
tools/perf/tests/attr/README +2 -0
index 1116fc6bf2ac..454505d343fa 100644
@@ -58,6 +58,8 @@ Following tests are defined (with perf commands):
   perf record -c 100 -P kill                    (test-record-period)
   perf record -c 1 --pfm-events=cycles:period=2 (test-record-pfm-period)
   perf record -R kill                           (test-record-raw)
+  perf record -c 2 -e arm_spe_0// -- kill       (test-record-spe-period)
+  perf record -e arm_spe_0/period=3/ -- kill    (test-record-spe-period-term)
   perf stat -e cycles kill                      (test-stat-basic)
   perf stat kill                                (test-stat-default)
   perf stat -d kill                             (test-stat-detailed-1)
tools/perf/tests/attr/base-record-spe new file +40 -0
new file mode 100644
index 000000000000..08fa96b59240
@@ -0,0 +1,40 @@
+[event]
+fd=*
+group_fd=-1
+flags=*
+cpu=*
+type=*
+size=*
+config=*
+sample_period=*
+sample_type=*
+read_format=*
+disabled=*
+inherit=*
+pinned=*
+exclusive=*
+exclude_user=*
+exclude_kernel=*
+exclude_hv=*
+exclude_idle=*
+mmap=*
+comm=*
+freq=*
+inherit_stat=*
+enable_on_exec=*
+task=*
+watermark=*
+precise_ip=*
+mmap_data=*
+sample_id_all=*
+exclude_host=*
+exclude_guest=*
+exclude_callchain_kernel=*
+exclude_callchain_user=*
+wakeup_events=*
+bp_type=*
+config1=*
+config2=*
+branch_sample_type=*
+sample_regs_user=*
+sample_stack_user=*
tools/perf/tests/attr/test-record-spe-period new file +12 -0
new file mode 100644
index 000000000000..75f8c9cd8e3f
@@ -0,0 +1,12 @@
+[config]
+command = record
+args    = --no-bpf-event -c 2 -e arm_spe_0// -- kill >/dev/null 2>&1
+ret     = 1
+arch    = aarch64
+
+[event-10:base-record-spe]
+sample_period=2
+freq=0
+
+# dummy event
+[event-1:base-record-spe]
tools/perf/tests/attr/test-record-spe-period-term new file +12 -0
new file mode 100644
index 000000000000..8f60a4fec657
@@ -0,0 +1,12 @@
+[config]
+command = record
+args    = --no-bpf-event -e arm_spe_0/period=3/ -- kill >/dev/null 2>&1
+ret     = 1
+arch    = aarch64
+
+[event-10:base-record-spe]
+sample_period=3
+freq=0
+
+# dummy event
+[event-1:base-record-spe]
Signature · 1 line
2.25.1
Tested-by
#3 lore raw
Quoted 26 lines · German Gomez

Hi Leo, thanks for checking this

Quoted 17 lines · Leo Yan

Hi German,

Quoted 7 lines · German Gomez

Adds a couple of perf_event_attr tests for the fix introduced in [1]. The tests check that the correct sample_period value is set in the struct perf_event_attr of the arm_spe events.

[1]: https://lore.kernel.org/all/[email protected]/

I tested this patch with two commands:

# PERF_TEST_ATTR=/tmp /usr/bin/python2 ./tests/attr.py -d ./tests/attr/ \
-p ./perf -vvvvv -t test-record-spe-period
# PERF_TEST_ATTR=/tmp /usr/bin/python2 ./tests/attr.py -d ./tests/attr/ \
-p ./perf -vvvvv -t test-record-spe-period-term

Quoted 6 lines

Both testing can pass on Hisilicon D06 board.

One question: I'm a bit concern this case will fail on some Arm64 platforms which doesn't contain Arm SPE modules. E.g. below commands will always fail on Arm64 platforms if SPE module is absent. So I am wandering if we can add extra checking ARM SPE event is existed or not?

Quoted 8 lines


The test reports "unsupported" if the return code and the 'ret' field don't match.

When I unload the SPE module:

running './tests/attr//test-record-spe-period-term' test limitation 'aarch64'
unsupp  './tests/attr//test-record-spe-period-term'

Thanks for confirmation, German.

You could add my testing tag for this patch:

Reviewed-by on v1 1/1
#5 lore raw
In reply to German Gomez
Quoted 7 lines · German Gomez

Adds a couple of perf_event_attr tests for the fix introduced in [1]. The tests check that the correct sample_period value is set in the struct perf_event_attr of the arm_spe events.

[1]: https://lore.kernel.org/all/[email protected]/

Quoted 105 lines
---
 tools/perf/tests/attr/README                  |  2 +
 tools/perf/tests/attr/base-record-spe         | 40 +++++++++++++++++++
 tools/perf/tests/attr/test-record-spe-period  | 12 ++++++
 .../tests/attr/test-record-spe-period-term    | 12 ++++++
 4 files changed, 66 insertions(+)
 create mode 100644 tools/perf/tests/attr/base-record-spe
 create mode 100644 tools/perf/tests/attr/test-record-spe-period
 create mode 100644 tools/perf/tests/attr/test-record-spe-period-term
tools/perf/tests/attr/README +2 -0
index 1116fc6bf2ac..454505d343fa 100644
@@ -58,6 +58,8 @@ Following tests are defined (with perf commands):
   perf record -c 100 -P kill                    (test-record-period)
   perf record -c 1 --pfm-events=cycles:period=2 (test-record-pfm-period)
   perf record -R kill                           (test-record-raw)
+  perf record -c 2 -e arm_spe_0// -- kill       (test-record-spe-period)
+  perf record -e arm_spe_0/period=3/ -- kill    (test-record-spe-period-term)
   perf stat -e cycles kill                      (test-stat-basic)
   perf stat kill                                (test-stat-default)
   perf stat -d kill                             (test-stat-detailed-1)
tools/perf/tests/attr/base-record-spe new file +40 -0
new file mode 100644
index 000000000000..08fa96b59240
@@ -0,0 +1,40 @@
+[event]
+fd=*
+group_fd=-1
+flags=*
+cpu=*
+type=*
+size=*
+config=*
+sample_period=*
+sample_type=*
+read_format=*
+disabled=*
+inherit=*
+pinned=*
+exclusive=*
+exclude_user=*
+exclude_kernel=*
+exclude_hv=*
+exclude_idle=*
+mmap=*
+comm=*
+freq=*
+inherit_stat=*
+enable_on_exec=*
+task=*
+watermark=*
+precise_ip=*
+mmap_data=*
+sample_id_all=*
+exclude_host=*
+exclude_guest=*
+exclude_callchain_kernel=*
+exclude_callchain_user=*
+wakeup_events=*
+bp_type=*
+config1=*
+config2=*
+branch_sample_type=*
+sample_regs_user=*
+sample_stack_user=*
tools/perf/tests/attr/test-record-spe-period new file +12 -0
new file mode 100644
index 000000000000..75f8c9cd8e3f
@@ -0,0 +1,12 @@
+[config]
+command = record
+args    = --no-bpf-event -c 2 -e arm_spe_0// -- kill >/dev/null 2>&1
+ret     = 1
+arch    = aarch64
+
+[event-10:base-record-spe]
+sample_period=2
+freq=0
+
+# dummy event
+[event-1:base-record-spe]
tools/perf/tests/attr/test-record-spe-period-term new file +12 -0
new file mode 100644
index 000000000000..8f60a4fec657
@@ -0,0 +1,12 @@
+[config]
+command = record
+args    = --no-bpf-event -e arm_spe_0/period=3/ -- kill >/dev/null 2>&1
+ret     = 1
+arch    = aarch64
+
+[event-10:base-record-spe]
+sample_period=3
+freq=0
+
+# dummy event
+[event-1:base-record-spe]
maintainer Applied
#6 lore raw

Em Mon, Feb 28, 2022 at 03:05:21PM +0000, James Clark escreveu:

Quoted 7 lines · German Gomez
Quoted 4 lines

Adds a couple of perf_event_attr tests for the fix introduced in [1]. The tests check that the correct sample_period value is set in the struct perf_event_attr of the arm_spe events.

Quoted 5 lines
Quoted 3 lines

[1]: https://lore.kernel.org/all/[email protected]/

Thanks, applied.

- Arnaldo

Quoted 105 lines
Quoted 105 lines
---
 tools/perf/tests/attr/README                  |  2 +
 tools/perf/tests/attr/base-record-spe         | 40 +++++++++++++++++++
 tools/perf/tests/attr/test-record-spe-period  | 12 ++++++
 .../tests/attr/test-record-spe-period-term    | 12 ++++++
 4 files changed, 66 insertions(+)
 create mode 100644 tools/perf/tests/attr/base-record-spe
 create mode 100644 tools/perf/tests/attr/test-record-spe-period
 create mode 100644 tools/perf/tests/attr/test-record-spe-period-term
tools/perf/tests/attr/README +2 -0
index 1116fc6bf2ac..454505d343fa 100644
@@ -58,6 +58,8 @@ Following tests are defined (with perf commands):
   perf record -c 100 -P kill                    (test-record-period)
   perf record -c 1 --pfm-events=cycles:period=2 (test-record-pfm-period)
   perf record -R kill                           (test-record-raw)
+  perf record -c 2 -e arm_spe_0// -- kill       (test-record-spe-period)
+  perf record -e arm_spe_0/period=3/ -- kill    (test-record-spe-period-term)
   perf stat -e cycles kill                      (test-stat-basic)
   perf stat kill                                (test-stat-default)
   perf stat -d kill                             (test-stat-detailed-1)
tools/perf/tests/attr/base-record-spe new file +40 -0
new file mode 100644
index 000000000000..08fa96b59240
@@ -0,0 +1,40 @@
+[event]
+fd=*
+group_fd=-1
+flags=*
+cpu=*
+type=*
+size=*
+config=*
+sample_period=*
+sample_type=*
+read_format=*
+disabled=*
+inherit=*
+pinned=*
+exclusive=*
+exclude_user=*
+exclude_kernel=*
+exclude_hv=*
+exclude_idle=*
+mmap=*
+comm=*
+freq=*
+inherit_stat=*
+enable_on_exec=*
+task=*
+watermark=*
+precise_ip=*
+mmap_data=*
+sample_id_all=*
+exclude_host=*
+exclude_guest=*
+exclude_callchain_kernel=*
+exclude_callchain_user=*
+wakeup_events=*
+bp_type=*
+config1=*
+config2=*
+branch_sample_type=*
+sample_regs_user=*
+sample_stack_user=*
tools/perf/tests/attr/test-record-spe-period new file +12 -0
new file mode 100644
index 000000000000..75f8c9cd8e3f
@@ -0,0 +1,12 @@
+[config]
+command = record
+args    = --no-bpf-event -c 2 -e arm_spe_0// -- kill >/dev/null 2>&1
+ret     = 1
+arch    = aarch64
+
+[event-10:base-record-spe]
+sample_period=2
+freq=0
+
+# dummy event
+[event-1:base-record-spe]
tools/perf/tests/attr/test-record-spe-period-term new file +12 -0
new file mode 100644
index 000000000000..8f60a4fec657
@@ -0,0 +1,12 @@
+[config]
+command = record
+args    = --no-bpf-event -e arm_spe_0/period=3/ -- kill >/dev/null 2>&1
+ret     = 1
+arch    = aarch64
+
+[event-10:base-record-spe]
+sample_period=3
+freq=0
+
+# dummy event
+[event-1:base-record-spe]
Signature · 1 line
- Arnaldo