mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/6 v1] perf test attr: Fix the re-enabled test
@ 2026-10-06 16:13 Arnaldo Carvalho de Melo
  2026-10-06 16:13 ` [PATCH 1/6] perf test attr: Propagate the return value from the test to the wrapper Arnaldo Carvalho de Melo
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-10-06 16:13 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Ingo Molnar, Thomas Gleixner, James Clark, Jiri Olsa, Ian Rogers,
	Adrian Hunter, Clark Williams, linux-kernel, linux-perf-users,
	Arnaldo Carvalho de Melo

From: Arnaldo Carvalho de Melo <acme@redhat.com>

Hello all,

This series fixes the "Perf attribute expectations test" (perf test 82,
formerly "Setup struct perf_event_attr").

Patches 1-2 are Michael Petlan's prerequisite fixes that make the shell
wrapper propagate attr.py's return value and correct the
perf_event_attr size expectation after struct config4 was added.  They
are included at the start of the series so that it applies cleanly on
the current perf-tools-next (and for the review bots to verify the new
patches); the new fixes are patches 3-6.

With the test reporting failures again, several stale expectations
surfaced and are addressed here:

- test-record-graph-dwarf still expected PERF_SAMPLE_ADDR and
  PERF_SAMPLE_DATA_SRC for --call-graph dwarf.  Those were dropped by
  bdd051e249141c79 ("perf record: Split --data-mmap option"), which
  decoupled data MMAP recording from the sample address bits.

- The record and stat group tests expected cache-misses and
  instructions to be the legacy PERF_TYPE_HARDWARE events, but since
  b1c5efbfd92eb84d ("perf parse-events: Remove hard coded legacy
  hardware and cache parsing") they resolve to the core PMU sysfs/JSON
  events, so request the legacy encodings explicitly with the
  legacy-hardware-config term.

- The perf stat default metrics open their events in groups and the
  raw encodings of instructions, branch-misses, cpu-cycles and
  stalled-cycles-frontend/backend differ between Intel and AMD, so
  base-stat now accepts the standalone and group variants and
  test-stat-default/detailed-{1,2,3} gained the per-vendor raw
  encodings.

- attr.py no longer requires a recorded event to be in a group when
  the matching expectation does not declare one, allowing the stat
  tests to verify event attributes without encoding the metric
  grouping.  Expectations that declare a group are still verified in
  both directions.

The test passes with 'perf test -vv attribute' on x86_64.  The AMD
encodings come from the amd_pmu_event_map tables in
arch/x86/events/amd/core.c.

Arnaldo

Arnaldo Carvalho de Melo (4):
  perf test attr: Fix record dwarf sample_type expectation
  perf test attr: Fix legacy event encodings in group tests
  perf test attr: Fix default stat metrics expectations
  perf test attr: Relax group checking for ungrouped expectations

Michael Petlan (2):
  perf test attr: Propagate the return value from the test to the
    wrapper
  perf test attr: Fix wrong size expectation for events

 tools/perf/tests/shell/attr.sh                |  1 +
 tools/perf/tests/shell/attr/README            | 10 +++---
 tools/perf/tests/shell/attr/base-record       |  2 +-
 tools/perf/tests/shell/attr/base-stat         |  8 ++---
 tools/perf/tests/shell/attr/system-wide-dummy |  2 +-
 .../tests/shell/attr/test-record-dummy-C0     |  2 +-
 .../tests/shell/attr/test-record-graph-dwarf  |  2 +-
 .../shell/attr/test-record-group-sampling     |  4 +--
 .../shell/attr/test-record-group-sampling1    |  4 +--
 .../shell/attr/test-record-group-sampling2    |  4 +--
 .../perf/tests/shell/attr/test-record-group1  |  2 +-
 .../perf/tests/shell/attr/test-record-group2  |  2 +-
 .../perf/tests/shell/attr/test-record-group3  |  2 +-
 tools/perf/tests/shell/attr/test-stat-default | 32 +++++++++++++++++--
 .../tests/shell/attr/test-stat-detailed-1     | 32 +++++++++++++++++--
 .../tests/shell/attr/test-stat-detailed-2     | 32 +++++++++++++++++--
 .../tests/shell/attr/test-stat-detailed-3     | 32 +++++++++++++++++--
 tools/perf/tests/shell/attr/test-stat-group1  |  2 +-
 tools/perf/tests/shell/lib/attr.py            | 11 +++++--
 19 files changed, 152 insertions(+), 34 deletions(-)

-- 
2.55.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/6] perf test attr: Propagate the return value from the test to the wrapper
  2026-10-06 16:13 [PATCH 0/6 v1] perf test attr: Fix the re-enabled test Arnaldo Carvalho de Melo
@ 2026-10-06 16:13 ` Arnaldo Carvalho de Melo
  2026-10-06 16:13 ` [PATCH 2/6] perf test attr: Fix wrong size expectation for events Arnaldo Carvalho de Melo
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-10-06 16:13 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Ingo Molnar, Thomas Gleixner, James Clark, Jiri Olsa, Ian Rogers,
	Adrian Hunter, Clark Williams, linux-kernel, linux-perf-users,
	Michael Petlan, Arnaldo Carvalho de Melo

From: Michael Petlan <mpetlan@redhat.com>

Currently it does not matter what the python script actually returns,
the test always passes, as the $err variable is always 0.

Fix that.

Fixes: 8519e4f44c2af722 ("perf test: Add a shell wrapper for "Setup struct perf_event_attr"")
Signed-off-by: Michael Petlan <mpetlan@redhat.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/tests/shell/attr.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/perf/tests/shell/attr.sh b/tools/perf/tests/shell/attr.sh
index 5a4e43b2471de811..307e1535795a34dc 100755
--- a/tools/perf/tests/shell/attr.sh
+++ b/tools/perf/tests/shell/attr.sh
@@ -18,5 +18,6 @@ trap trap_cleanup EXIT TERM INT
 shelldir=$(dirname "$0")
 perf_path=$(which perf)
 python "${shelldir}"/lib/attr.py -d "${shelldir}"/attr -v -p "$perf_path"
+err=$?
 cleanup
 exit $err
-- 
2.55.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 2/6] perf test attr: Fix wrong size expectation for events
  2026-10-06 16:13 [PATCH 0/6 v1] perf test attr: Fix the re-enabled test Arnaldo Carvalho de Melo
  2026-10-06 16:13 ` [PATCH 1/6] perf test attr: Propagate the return value from the test to the wrapper Arnaldo Carvalho de Melo
@ 2026-10-06 16:13 ` Arnaldo Carvalho de Melo
  2026-10-06 16:13 ` [PATCH 3/6] perf test attr: Fix record dwarf sample_type expectation Arnaldo Carvalho de Melo
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-10-06 16:13 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Ingo Molnar, Thomas Gleixner, James Clark, Jiri Olsa, Ian Rogers,
	Adrian Hunter, Clark Williams, linux-kernel, linux-perf-users,
	Michael Petlan, Arnaldo Carvalho de Melo

From: Michael Petlan <mpetlan@redhat.com>

Although config4 has been added into struct perf_event_attr, the size
expectation for the struct hasn't been adjusted. This hasn't been
noticed, since the testcase's return value has been ignored after
rewriting the testcase to python until previous commit.

Fix that.

Fixes: eb89aef367e47010 ("perf headers: Sync perf_event.h/perf_regs.h with the kernel headers")
Fixes: 80cdf208117a36de ("tools headers UAPI: Sync linux/perf_event.h with the kernel sources")
Signed-off-by: Michael Petlan <mpetlan@redhat.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/tests/shell/attr/base-record          | 2 +-
 tools/perf/tests/shell/attr/base-stat            | 2 +-
 tools/perf/tests/shell/attr/system-wide-dummy    | 2 +-
 tools/perf/tests/shell/attr/test-record-dummy-C0 | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/perf/tests/shell/attr/base-record b/tools/perf/tests/shell/attr/base-record
index b44e4e6e444386af..a4597d4c0cd12550 100644
--- a/tools/perf/tests/shell/attr/base-record
+++ b/tools/perf/tests/shell/attr/base-record
@@ -5,7 +5,7 @@ group_fd=-1
 flags=0|8
 cpu=*
 type=0|1
-size=136
+size=176
 config=0|1
 sample_period=*
 sample_type=263
diff --git a/tools/perf/tests/shell/attr/base-stat b/tools/perf/tests/shell/attr/base-stat
index fccd8ec4d1b0225c..67d6eea8947034e1 100644
--- a/tools/perf/tests/shell/attr/base-stat
+++ b/tools/perf/tests/shell/attr/base-stat
@@ -5,7 +5,7 @@ group_fd=-1
 flags=0|8
 cpu=*
 type=0
-size=136
+size=176
 config=0
 sample_period=0
 sample_type=65536
diff --git a/tools/perf/tests/shell/attr/system-wide-dummy b/tools/perf/tests/shell/attr/system-wide-dummy
index a1e1d6a263bf14e7..b062ad7f3c1c61dc 100644
--- a/tools/perf/tests/shell/attr/system-wide-dummy
+++ b/tools/perf/tests/shell/attr/system-wide-dummy
@@ -7,7 +7,7 @@ cpu=*
 pid=-1
 flags=8
 type=1
-size=136
+size=176
 config=9
 sample_period=1
 # PERF_SAMPLE_IP | PERF_SAMPLE_TID | PERF_SAMPLE_TIME |
diff --git a/tools/perf/tests/shell/attr/test-record-dummy-C0 b/tools/perf/tests/shell/attr/test-record-dummy-C0
index 91499405fff4d32b..54adb835d203f2b1 100644
--- a/tools/perf/tests/shell/attr/test-record-dummy-C0
+++ b/tools/perf/tests/shell/attr/test-record-dummy-C0
@@ -10,7 +10,7 @@ cpu=0
 pid=-1
 flags=8
 type=1
-size=136
+size=176
 config=9
 sample_period=4000
 # PERF_SAMPLE_IP | PERF_SAMPLE_TID | PERF_SAMPLE_TIME |
-- 
2.55.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 3/6] perf test attr: Fix record dwarf sample_type expectation
  2026-10-06 16:13 [PATCH 0/6 v1] perf test attr: Fix the re-enabled test Arnaldo Carvalho de Melo
  2026-10-06 16:13 ` [PATCH 1/6] perf test attr: Propagate the return value from the test to the wrapper Arnaldo Carvalho de Melo
  2026-10-06 16:13 ` [PATCH 2/6] perf test attr: Fix wrong size expectation for events Arnaldo Carvalho de Melo
@ 2026-10-06 16:13 ` Arnaldo Carvalho de Melo
  2026-10-06 16:13 ` [PATCH 4/6] perf test attr: Fix legacy event encodings in group tests Arnaldo Carvalho de Melo
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-10-06 16:13 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Ingo Molnar, Thomas Gleixner, James Clark, Jiri Olsa, Ian Rogers,
	Adrian Hunter, Clark Williams, linux-kernel, linux-perf-users,
	Arnaldo Carvalho de Melo

From: Arnaldo Carvalho de Melo <acme@redhat.com>

Since bdd051e249141c79 ("perf record: Split --data-mmap option"),
record_opts__parse_callchain() sets record_data_mmap instead of
record->sample_address for the DWARF unwind mode, so -d/--data and its
implied PERF_SAMPLE_DATA_SRC are not enabled implicitly anymore.

As a result, --call-graph dwarf no longer sets PERF_SAMPLE_ADDR and
PERF_SAMPLE_DATA_SRC, making the test fail:

  expected sample_type=45359, got 12583

where 45359 (0xb12f) is:

  IP|TID|TIME|ADDR|CALLCHAIN|PERIOD|REGS_USER|STACK_USER|DATA_SRC

and 12583 (0x3127) is:

  IP|TID|TIME|CALLCHAIN|PERIOD|REGS_USER|STACK_USER

i.e. the values differ exactly by PERF_SAMPLE_ADDR (0x8) and
PERF_SAMPLE_DATA_SRC (0x8000).  The mmap_data=1 expectation is still
correct as DWARF now enables record_data_mmap.

This went unnoticed because tests/attr.sh ignored attr.py's return
value until 04a0a19ede01e771 ("perf test attr: Propagate the return
value from the test to the wrapper").

Fixes: bdd051e249141c79 ("perf record: Split --data-mmap option")
Assisted-by: LLM
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/tests/shell/attr/test-record-graph-dwarf | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/tests/shell/attr/test-record-graph-dwarf b/tools/perf/tests/shell/attr/test-record-graph-dwarf
index ae92061d611ded68..fbe0faa8cdb6a8f4 100644
--- a/tools/perf/tests/shell/attr/test-record-graph-dwarf
+++ b/tools/perf/tests/shell/attr/test-record-graph-dwarf
@@ -4,7 +4,7 @@ args    = --no-bpf-event --call-graph dwarf -- kill >/dev/null 2>&1
 ret     = 1
 
 [event:base-record]
-sample_type=45359
+sample_type=12583
 exclude_callchain_user=1
 sample_stack_user=8192
 # TODO different for each arch, no support for that now
-- 
2.55.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 4/6] perf test attr: Fix legacy event encodings in group tests
  2026-10-06 16:13 [PATCH 0/6 v1] perf test attr: Fix the re-enabled test Arnaldo Carvalho de Melo
                   ` (2 preceding siblings ...)
  2026-10-06 16:13 ` [PATCH 3/6] perf test attr: Fix record dwarf sample_type expectation Arnaldo Carvalho de Melo
@ 2026-10-06 16:13 ` Arnaldo Carvalho de Melo
  2026-10-06 16:13 ` [PATCH 5/6] perf test attr: Fix default stat metrics expectations Arnaldo Carvalho de Melo
  2026-10-06 16:13 ` [PATCH 6/6] perf test attr: Relax group checking for ungrouped expectations Arnaldo Carvalho de Melo
  5 siblings, 0 replies; 7+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-10-06 16:13 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Ingo Molnar, Thomas Gleixner, James Clark, Jiri Olsa, Ian Rogers,
	Adrian Hunter, Clark Williams, linux-kernel, linux-perf-users,
	Arnaldo Carvalho de Melo

From: Arnaldo Carvalho de Melo <acme@redhat.com>

Since b1c5efbfd92eb84d ("perf parse-events: Remove hard coded legacy
hardware and cache parsing"), event names are resolved with sysfs/JSON
priority over the legacy encodings, so bare cache-misses and
instructions now become the core PMU sysfs/JSON events (on x86 type 4,
configs 0x412e and 0xc0) rather than the legacy
PERF_TYPE_HARDWARE/config=3 and config=1 events the tests expect, e.g.:

  expected config=3, got 0
  expected disabled=0, got 1
  expected mmap=0, got 1
  expected comm=0, got 1
  expected freq=0, got 1
  expected enable_on_exec=0, got 1
  expected task=0, got 1
  FAILED '.../test-record-group-sampling1' - match failure

The shown diff is against the cycles group leader, as no result event
matches the expected cache-misses member anymore.

Request the legacy encodings explicitly with the legacy-hardware-config
term, introduced for this purpose, keeping the original attribute
expectations unchanged, in:

  test-record-group1
  test-record-group2
  test-record-group3
  test-record-group-sampling
  test-record-group-sampling1
  test-record-group-sampling2
  test-stat-group1

This went unnoticed because tests/attr.sh ignored attr.py's return
value until 04a0a19ede01e771 ("perf test attr: Propagate the return
value from the test to the wrapper").

Fixes: b1c5efbfd92eb84d ("perf parse-events: Remove hard coded legacy hardware and cache parsing")
Assisted-by: LLM
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/tests/shell/attr/README                     | 10 +++++-----
 tools/perf/tests/shell/attr/test-record-group-sampling |  4 ++--
 .../perf/tests/shell/attr/test-record-group-sampling1  |  4 ++--
 .../perf/tests/shell/attr/test-record-group-sampling2  |  4 ++--
 tools/perf/tests/shell/attr/test-record-group1         |  2 +-
 tools/perf/tests/shell/attr/test-record-group2         |  2 +-
 tools/perf/tests/shell/attr/test-record-group3         |  2 +-
 tools/perf/tests/shell/attr/test-stat-group1           |  2 +-
 8 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/tools/perf/tests/shell/attr/README b/tools/perf/tests/shell/attr/README
index 67c4ca76b85d5611..c7b49cdf87297177 100644
--- a/tools/perf/tests/shell/attr/README
+++ b/tools/perf/tests/shell/attr/README
@@ -49,10 +49,10 @@ Following tests are defined (with perf commands):
   perf record --call-graph dwarf kill		(test-record-graph-dwarf)
   perf record --call-graph fp kill              (test-record-graph-fp)
   perf record --call-graph fp kill              (test-record-graph-fp-aarch64)
-  perf record -e '{cycles,instructions}' kill   (test-record-group1)
-  perf record -e '{cycles/period=1/,instructions/period=2/}:S' kill (test-record-group2)
-  perf record -e '{cycles,cache-misses}:S' kill (test-record-group-sampling1)
-  perf record -c 10000 -e '{cycles,cache-misses}:S' kill (test-record-group-sampling2)
+  perf record -e '{cycles,default_core/legacy-hardware-config=1/}' kill (test-record-group1)
+  perf record -e '{cycles/period=1234000/,default_core/legacy-hardware-config=1,period=6789000/}:S' kill (test-record-group2)
+  perf record -e '{cycles,default_core/legacy-hardware-config=3/}:S' kill (test-record-group-sampling1)
+  perf record -c 10000 -e '{cycles,default_core/legacy-hardware-config=3/}:S' kill (test-record-group-sampling2)
   perf record -D kill                           (test-record-no-delay)
   perf record -i kill                           (test-record-no-inherit)
   perf record -n kill                           (test-record-no-samples)
@@ -67,5 +67,5 @@ Following tests are defined (with perf commands):
   perf stat -d kill                             (test-stat-detailed-1)
   perf stat -dd kill                            (test-stat-detailed-2)
   perf stat -ddd kill                           (test-stat-detailed-3)
-  perf stat -e '{cycles,instructions}' kill     (test-stat-group1)
+  perf stat -e '{cycles,default_core/legacy-hardware-config=1/}' kill (test-stat-group1)
   perf stat -i -e cycles kill                   (test-stat-no-inherit)
diff --git a/tools/perf/tests/shell/attr/test-record-group-sampling b/tools/perf/tests/shell/attr/test-record-group-sampling
index 86a940d7895d7404..766aadef2f1f9ffd 100644
--- a/tools/perf/tests/shell/attr/test-record-group-sampling
+++ b/tools/perf/tests/shell/attr/test-record-group-sampling
@@ -1,6 +1,6 @@
 [config]
 command = record
-args    = --no-bpf-event -e '{cycles,cache-misses}:S' kill >/dev/null 2>&1
+args    = --no-bpf-event -e '{cycles,default_core/legacy-hardware-config=3/}:S' kill >/dev/null 2>&1
 ret     = 1
 kernel_until = 6.12
 
@@ -15,7 +15,7 @@ inherit=0
 fd=2
 group_fd=1
 
-# cache-misses
+# cache-misses, explicitly requested with the legacy hardware encoding
 type=0
 config=3
 
diff --git a/tools/perf/tests/shell/attr/test-record-group-sampling1 b/tools/perf/tests/shell/attr/test-record-group-sampling1
index 4748ab7bf68437c7..5be9a1a2a4ff0751 100644
--- a/tools/perf/tests/shell/attr/test-record-group-sampling1
+++ b/tools/perf/tests/shell/attr/test-record-group-sampling1
@@ -1,6 +1,6 @@
 [config]
 command = record
-args    = --no-bpf-event -e '{cycles,cache-misses}:S' kill >/dev/null 2>&1
+args    = --no-bpf-event -e '{cycles,default_core/legacy-hardware-config=3/}:S' kill >/dev/null 2>&1
 ret     = 1
 kernel_since = 6.12
 
@@ -30,7 +30,7 @@ inherit=1
 fd=2
 group_fd=1
 
-# cache-misses
+# cache-misses, explicitly requested with the legacy hardware encoding
 type=0
 config=3
 
diff --git a/tools/perf/tests/shell/attr/test-record-group-sampling2 b/tools/perf/tests/shell/attr/test-record-group-sampling2
index e0432244a0eb7f6c..c05225167ec3464b 100644
--- a/tools/perf/tests/shell/attr/test-record-group-sampling2
+++ b/tools/perf/tests/shell/attr/test-record-group-sampling2
@@ -1,6 +1,6 @@
 [config]
 command = record
-args    = --no-bpf-event -c 10000 -e '{cycles,cache-misses}:S' kill >/dev/null 2>&1
+args    = --no-bpf-event -c 10000 -e '{cycles,default_core/legacy-hardware-config=3/}:S' kill >/dev/null 2>&1
 ret     = 1
 kernel_since = 6.12
 
@@ -36,7 +36,7 @@ write_backward=0
 fd=2
 group_fd=1
 
-# cache-misses
+# cache-misses, explicitly requested with the legacy hardware encoding
 type=0
 config=3
 
diff --git a/tools/perf/tests/shell/attr/test-record-group1 b/tools/perf/tests/shell/attr/test-record-group1
index eeb1db392bc9ceac..0437ea4939e88865 100644
--- a/tools/perf/tests/shell/attr/test-record-group1
+++ b/tools/perf/tests/shell/attr/test-record-group1
@@ -1,6 +1,6 @@
 [config]
 command = record
-args    = --no-bpf-event -e '{cycles,instructions}' kill >/dev/null 2>&1
+args    = --no-bpf-event -e '{cycles,default_core/legacy-hardware-config=1/}' kill >/dev/null 2>&1
 ret     = 1
 
 [event-1:base-record]
diff --git a/tools/perf/tests/shell/attr/test-record-group2 b/tools/perf/tests/shell/attr/test-record-group2
index 891d41a7bddf785a..ca5bbf441968fd8c 100644
--- a/tools/perf/tests/shell/attr/test-record-group2
+++ b/tools/perf/tests/shell/attr/test-record-group2
@@ -1,6 +1,6 @@
 [config]
 command = record
-args    = --no-bpf-event -e '{cycles/period=1234000/,instructions/period=6789000/}:S' kill >/dev/null 2>&1
+args    = --no-bpf-event -e '{cycles/period=1234000/,default_core/legacy-hardware-config=1,period=6789000/}:S' kill >/dev/null 2>&1
 ret     = 1
 kernel_until = 6.12
 
diff --git a/tools/perf/tests/shell/attr/test-record-group3 b/tools/perf/tests/shell/attr/test-record-group3
index 249be884959eaaba..8191b3af936de5aa 100644
--- a/tools/perf/tests/shell/attr/test-record-group3
+++ b/tools/perf/tests/shell/attr/test-record-group3
@@ -1,6 +1,6 @@
 [config]
 command = record
-args    = --no-bpf-event -e '{cycles/period=1234000/,instructions/period=6789000/}:S' kill >/dev/null 2>&1
+args    = --no-bpf-event -e '{cycles/period=1234000/,default_core/legacy-hardware-config=1,period=6789000/}:S' kill >/dev/null 2>&1
 ret     = 1
 kernel_since = 6.12
 
diff --git a/tools/perf/tests/shell/attr/test-stat-group1 b/tools/perf/tests/shell/attr/test-stat-group1
index 1746751123dcb2c4..fa2ca74e4cf29ad5 100644
--- a/tools/perf/tests/shell/attr/test-stat-group1
+++ b/tools/perf/tests/shell/attr/test-stat-group1
@@ -1,6 +1,6 @@
 [config]
 command = stat
-args    = -e '{cycles,instructions}' kill >/dev/null 2>&1
+args    = -e '{cycles,default_core/legacy-hardware-config=1/}' kill >/dev/null 2>&1
 ret     = 1
 
 [event-1:base-stat]
-- 
2.55.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 5/6] perf test attr: Fix default stat metrics expectations
  2026-10-06 16:13 [PATCH 0/6 v1] perf test attr: Fix the re-enabled test Arnaldo Carvalho de Melo
                   ` (3 preceding siblings ...)
  2026-10-06 16:13 ` [PATCH 4/6] perf test attr: Fix legacy event encodings in group tests Arnaldo Carvalho de Melo
@ 2026-10-06 16:13 ` Arnaldo Carvalho de Melo
  2026-10-06 16:13 ` [PATCH 6/6] perf test attr: Relax group checking for ungrouped expectations Arnaldo Carvalho de Melo
  5 siblings, 0 replies; 7+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-10-06 16:13 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Ingo Molnar, Thomas Gleixner, James Clark, Jiri Olsa, Ian Rogers,
	Adrian Hunter, Clark Williams, linux-kernel, linux-perf-users,
	Arnaldo Carvalho de Melo

From: Arnaldo Carvalho de Melo <acme@redhat.com>

Since c7adeb0974f18da4 ("perf jevents: Add set of common metrics based
on default ones") and 2dfc0cab3da4a205 ("perf stat: Add detail -d,-dd,-ddd
metrics") the perf stat default metrics open their events in groups, so
group leaders and members have read_format=15 and members are enabled
without enable_on_exec, while standalone events keep read_format=3 and
are disabled until exec.

Also, since b1c5efbfd92eb84d ("perf parse-events: Remove hard coded
legacy hardware and cache parsing") bare hardware events resolve to the
core PMU sysfs/JSON events (type 4), so add the raw encodings seen on
Intel and AMD for instructions, branch-misses, cpu-cycles and
stalled-cycles-frontend/backend to test-stat-default and
test-stat-detailed-1/2/3.

Update base-stat to accept both the standalone and group variants of
read_format, disabled and enable_on_exec.

Fixes: b1c5efbfd92eb84d ("perf parse-events: Remove hard coded legacy hardware and cache parsing")
Fixes: c7adeb0974f18da4 ("perf jevents: Add set of common metrics based on default ones")
Fixes: 2dfc0cab3da4a205 ("perf stat: Add detail -d,-dd,-ddd metrics")
Assisted-by: LLM
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/tests/shell/attr/base-stat         |  6 ++--
 tools/perf/tests/shell/attr/test-stat-default | 32 +++++++++++++++++--
 .../tests/shell/attr/test-stat-detailed-1     | 32 +++++++++++++++++--
 .../tests/shell/attr/test-stat-detailed-2     | 32 +++++++++++++++++--
 .../tests/shell/attr/test-stat-detailed-3     | 32 +++++++++++++++++--
 5 files changed, 123 insertions(+), 11 deletions(-)

diff --git a/tools/perf/tests/shell/attr/base-stat b/tools/perf/tests/shell/attr/base-stat
index 67d6eea8947034e1..dda41a626cbca64e 100644
--- a/tools/perf/tests/shell/attr/base-stat
+++ b/tools/perf/tests/shell/attr/base-stat
@@ -9,8 +9,8 @@ size=176
 config=0
 sample_period=0
 sample_type=65536
-read_format=3
-disabled=1
+read_format=3|15
+disabled=0|1
 inherit=1
 pinned=0
 exclusive=0
@@ -22,7 +22,7 @@ mmap=0
 comm=0
 freq=0
 inherit_stat=0
-enable_on_exec=1
+enable_on_exec=0|1
 task=0
 watermark=0
 precise_ip=0
diff --git a/tools/perf/tests/shell/attr/test-stat-default b/tools/perf/tests/shell/attr/test-stat-default
index 8dd27c1fb661fb77..e79bc56389fda180 100644
--- a/tools/perf/tests/shell/attr/test-stat-default
+++ b/tools/perf/tests/shell/attr/test-stat-default
@@ -179,11 +179,11 @@ type=4
 config=17039629
 optional=1
 
-# PERF_TYPE_RAW / CPU_CLK_UNHALTED.THREAD
+# PERF_TYPE_RAW / cpu-cycles (core PMU sysfs event; Intel 0x3c, AMD 0x76)
 [event22:base-stat]
 fd=22
 type=4
-config=60
+config=60|118
 optional=1
 
 # PERF_TYPE_RAW / INT_MISC.RECOVERY_CYCLES_ANY
@@ -233,4 +233,32 @@ optional=1
 fd=29
 type=4
 config=4269
+optional=1
+
+# PERF_TYPE_RAW / instructions (core PMU sysfs event)
+[event30:base-stat]
+fd=30
+type=4
+config=192
+optional=1
+
+# PERF_TYPE_RAW / branch-misses (core PMU sysfs event; Intel 0xc5, AMD 0xc3)
+[event31:base-stat]
+fd=31
+type=4
+config=197|195
+optional=1
+
+# PERF_TYPE_RAW / stalled-cycles-frontend (core PMU sysfs event; AMD 0xd0/0x287/0xa9)
+[event32:base-stat]
+fd=32
+type=4
+config=208|647|169
+optional=1
+
+# PERF_TYPE_RAW / stalled-cycles-backend (core PMU sysfs event; AMD 0xd1/0x187)
+[event33:base-stat]
+fd=33
+type=4
+config=209|391
 optional=1
\ No newline at end of file
diff --git a/tools/perf/tests/shell/attr/test-stat-detailed-1 b/tools/perf/tests/shell/attr/test-stat-detailed-1
index 12a2ebf4e64a0077..cbd1041cd6c0430c 100644
--- a/tools/perf/tests/shell/attr/test-stat-detailed-1
+++ b/tools/perf/tests/shell/attr/test-stat-detailed-1
@@ -181,11 +181,11 @@ type=4
 config=17039629
 optional=1
 
-# PERF_TYPE_RAW / CPU_CLK_UNHALTED.THREAD
+# PERF_TYPE_RAW / cpu-cycles (core PMU sysfs event; Intel 0x3c, AMD 0x76)
 [event22:base-stat]
 fd=22
 type=4
-config=60
+config=60|118
 optional=1
 
 # PERF_TYPE_RAW / INT_MISC.RECOVERY_CYCLES_ANY
@@ -275,4 +275,32 @@ optional=1
 fd=33
 type=4
 config=4269
+optional=1
+
+# PERF_TYPE_RAW / instructions (core PMU sysfs event)
+[event34:base-stat]
+fd=34
+type=4
+config=192
+optional=1
+
+# PERF_TYPE_RAW / branch-misses (core PMU sysfs event; Intel 0xc5, AMD 0xc3)
+[event35:base-stat]
+fd=35
+type=4
+config=197|195
+optional=1
+
+# PERF_TYPE_RAW / stalled-cycles-frontend (core PMU sysfs event; AMD 0xd0/0x287/0xa9)
+[event36:base-stat]
+fd=36
+type=4
+config=208|647|169
+optional=1
+
+# PERF_TYPE_RAW / stalled-cycles-backend (core PMU sysfs event; AMD 0xd1/0x187)
+[event37:base-stat]
+fd=37
+type=4
+config=209|391
 optional=1
\ No newline at end of file
diff --git a/tools/perf/tests/shell/attr/test-stat-detailed-2 b/tools/perf/tests/shell/attr/test-stat-detailed-2
index 66ea25b7d38f8d59..c47b22b4ec30259f 100644
--- a/tools/perf/tests/shell/attr/test-stat-detailed-2
+++ b/tools/perf/tests/shell/attr/test-stat-detailed-2
@@ -181,11 +181,11 @@ type=4
 config=17039629
 optional=1
 
-# PERF_TYPE_RAW / CPU_CLK_UNHALTED.THREAD
+# PERF_TYPE_RAW / cpu-cycles (core PMU sysfs event; Intel 0x3c, AMD 0x76)
 [event22:base-stat]
 fd=22
 type=4
-config=60
+config=60|118
 optional=1
 
 # PERF_TYPE_RAW / INT_MISC.RECOVERY_CYCLES_ANY
@@ -335,4 +335,32 @@ optional=1
 fd=39
 type=4
 config=4269
+optional=1
+
+# PERF_TYPE_RAW / instructions (core PMU sysfs event)
+[event40:base-stat]
+fd=40
+type=4
+config=192
+optional=1
+
+# PERF_TYPE_RAW / branch-misses (core PMU sysfs event; Intel 0xc5, AMD 0xc3)
+[event41:base-stat]
+fd=41
+type=4
+config=197|195
+optional=1
+
+# PERF_TYPE_RAW / stalled-cycles-frontend (core PMU sysfs event; AMD 0xd0/0x287/0xa9)
+[event42:base-stat]
+fd=42
+type=4
+config=208|647|169
+optional=1
+
+# PERF_TYPE_RAW / stalled-cycles-backend (core PMU sysfs event; AMD 0xd1/0x187)
+[event43:base-stat]
+fd=43
+type=4
+config=209|391
 optional=1
\ No newline at end of file
diff --git a/tools/perf/tests/shell/attr/test-stat-detailed-3 b/tools/perf/tests/shell/attr/test-stat-detailed-3
index 4a27bbfb9f87a538..a6251005097a9639 100644
--- a/tools/perf/tests/shell/attr/test-stat-detailed-3
+++ b/tools/perf/tests/shell/attr/test-stat-detailed-3
@@ -181,11 +181,11 @@ type=4
 config=17039629
 optional=1
 
-# PERF_TYPE_RAW / CPU_CLK_UNHALTED.THREAD
+# PERF_TYPE_RAW / cpu-cycles (core PMU sysfs event; Intel 0x3c, AMD 0x76)
 [event22:base-stat]
 fd=22
 type=4
-config=60
+config=60|118
 optional=1
 
 # PERF_TYPE_RAW / INT_MISC.RECOVERY_CYCLES_ANY
@@ -355,4 +355,32 @@ optional=1
 fd=41
 type=4
 config=4269
+optional=1
+
+# PERF_TYPE_RAW / instructions (core PMU sysfs event)
+[event42:base-stat]
+fd=42
+type=4
+config=192
+optional=1
+
+# PERF_TYPE_RAW / branch-misses (core PMU sysfs event; Intel 0xc5, AMD 0xc3)
+[event43:base-stat]
+fd=43
+type=4
+config=197|195
+optional=1
+
+# PERF_TYPE_RAW / stalled-cycles-frontend (core PMU sysfs event; AMD 0xd0/0x287/0xa9)
+[event44:base-stat]
+fd=44
+type=4
+config=208|647|169
+optional=1
+
+# PERF_TYPE_RAW / stalled-cycles-backend (core PMU sysfs event; AMD 0xd1/0x187)
+[event45:base-stat]
+fd=45
+type=4
+config=209|391
 optional=1
\ No newline at end of file
-- 
2.55.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 6/6] perf test attr: Relax group checking for ungrouped expectations
  2026-10-06 16:13 [PATCH 0/6 v1] perf test attr: Fix the re-enabled test Arnaldo Carvalho de Melo
                   ` (4 preceding siblings ...)
  2026-10-06 16:13 ` [PATCH 5/6] perf test attr: Fix default stat metrics expectations Arnaldo Carvalho de Melo
@ 2026-10-06 16:13 ` Arnaldo Carvalho de Melo
  5 siblings, 0 replies; 7+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-10-06 16:13 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Ingo Molnar, Thomas Gleixner, James Clark, Jiri Olsa, Ian Rogers,
	Adrian Hunter, Clark Williams, linux-kernel, linux-perf-users,
	Arnaldo Carvalho de Melo

From: Arnaldo Carvalho de Melo <acme@redhat.com>

When matching the recorded events back against the expectations,
attr.py requires every event opened in a group to match an expectation
that declares the same group.  The perf stat default metrics open the
events of each metric in groups, but the test expectations only verify
the event attributes, so test-stat-default fails with:

  FAILED '.../test-stat-default' - group failure

Only enforce the group of a recorded event when the expectation it
matches declares one.  Expectations that ask for a group are still
verified in both directions.

Fixes: c7adeb0974f18da4 ("perf jevents: Add set of common metrics based on default ones")
Fixes: 2dfc0cab3da4a205 ("perf stat: Add detail -d,-dd,-ddd metrics")
Assisted-by: LLM
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/tests/shell/lib/attr.py | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/tools/perf/tests/shell/lib/attr.py b/tools/perf/tests/shell/lib/attr.py
index 68f06df9565a0811..3319abfd451c4e4f 100644
--- a/tools/perf/tests/shell/lib/attr.py
+++ b/tools/perf/tests/shell/lib/attr.py
@@ -309,7 +309,7 @@ class Test(object):
             else:
                 raise Unsup(self)
 
-    def compare(self, expect, result):
+    def compare(self, expect, result, strict_groups=True):
         match = {}
 
         log.debug("  compare")
@@ -344,7 +344,10 @@ class Test(object):
             match[exp_name] = exp_list
 
         # For each defined group in the expected events
-        # check we match the same group in the result.
+        # check we match the same group in the result. When matching
+        # the result back against the expectations, events opened in a
+        # group may match an expectation that doesn't request a group,
+        # as such expectations only verify the event attributes.
         for exp_name, exp_event in expect.items():
             group = exp_event.group
 
@@ -353,6 +356,8 @@ class Test(object):
 
             for res_name in match[exp_name]:
                 res_group = result[res_name].group
+                if res_group == '' and not strict_groups:
+                    continue
                 if res_group not in match[group]:
                     raise Fail(self, 'group failure')
 
@@ -391,7 +396,7 @@ class Test(object):
 
             # do the expectation - results matching - both ways
             self.compare(self.expect, self.result)
-            self.compare(self.result, self.expect)
+            self.compare(self.result, self.expect, strict_groups=False)
 
         finally:
             # cleanup
-- 
2.55.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-10-06 16:13 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-06 16:13 [PATCH 0/6 v1] perf test attr: Fix the re-enabled test Arnaldo Carvalho de Melo
2026-10-06 16:13 ` [PATCH 1/6] perf test attr: Propagate the return value from the test to the wrapper Arnaldo Carvalho de Melo
2026-10-06 16:13 ` [PATCH 2/6] perf test attr: Fix wrong size expectation for events Arnaldo Carvalho de Melo
2026-10-06 16:13 ` [PATCH 3/6] perf test attr: Fix record dwarf sample_type expectation Arnaldo Carvalho de Melo
2026-10-06 16:13 ` [PATCH 4/6] perf test attr: Fix legacy event encodings in group tests Arnaldo Carvalho de Melo
2026-10-06 16:13 ` [PATCH 5/6] perf test attr: Fix default stat metrics expectations Arnaldo Carvalho de Melo
2026-10-06 16:13 ` [PATCH 6/6] perf test attr: Relax group checking for ungrouped expectations Arnaldo Carvalho de Melo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®