linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 0/4] Test/uniquification related fixes
@ 2025-08-21 22:18 Ian Rogers
  2025-08-21 22:18 ` [PATCH v1 1/4] perf test shell lbr: Avoid failures with perf event paranoia Ian Rogers
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Ian Rogers @ 2025-08-21 22:18 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
	Ian Rogers, Adrian Hunter, Kan Liang, Chun-Tse Shao, James Clark,
	Howard Chu, linux-kernel, linux-perf-users

Failures discovered running as non-root and with v6.17-rc1 changes.

Ian Rogers (4):
  perf test shell lbr: Avoid failures with perf event paranoia
  perf test: Don't leak workload gopipe in PERF_RECORD_*
  perf evsel: Fix uniquification when PMU given without suffix
  perf test: Avoid uncore_imc/clockticks in uniquification test

 tools/perf/tests/perf-record.c                |   4 +
 tools/perf/tests/shell/record_lbr.sh          |  26 ++++-
 .../tests/shell/stat+event_uniquifying.sh     | 105 ++++++++----------
 tools/perf/util/evsel.c                       |  28 +++--
 4 files changed, 86 insertions(+), 77 deletions(-)

-- 
2.51.0.rc2.233.g662b1ed5c5-goog


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

* [PATCH v1 1/4] perf test shell lbr: Avoid failures with perf event paranoia
  2025-08-21 22:18 [PATCH v1 0/4] Test/uniquification related fixes Ian Rogers
@ 2025-08-21 22:18 ` Ian Rogers
  2025-09-16 19:00   ` Arnaldo Carvalho de Melo
  2025-08-21 22:18 ` [PATCH v1 2/4] perf test: Don't leak workload gopipe in PERF_RECORD_* Ian Rogers
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 12+ messages in thread
From: Ian Rogers @ 2025-08-21 22:18 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
	Ian Rogers, Adrian Hunter, Kan Liang, Chun-Tse Shao, James Clark,
	Howard Chu, linux-kernel, linux-perf-users

When not running as root and with higher perf event paranoia values
the perf record LBR tests could fail rather than skipping the
problematic tests. Add the sensitivity to the test and confirm it
passes with paranoia values from -1 to 2.

Fixes: 32559b99e0f5 ("perf test: Add set of perf record LBR tests")
Signed-off-by: Ian Rogers <irogers@google.com>
---
 tools/perf/tests/shell/record_lbr.sh | 26 ++++++++++++++++++++------
 1 file changed, 20 insertions(+), 6 deletions(-)

diff --git a/tools/perf/tests/shell/record_lbr.sh b/tools/perf/tests/shell/record_lbr.sh
index 6fcb5e52b9b4..78a02e90ece1 100755
--- a/tools/perf/tests/shell/record_lbr.sh
+++ b/tools/perf/tests/shell/record_lbr.sh
@@ -4,6 +4,10 @@
 
 set -e
 
+ParanoidAndNotRoot() {
+  [ "$(id -u)" != 0 ] && [ "$(cat /proc/sys/kernel/perf_event_paranoid)" -gt $1 ]
+}
+
 if [ ! -f /sys/bus/event_source/devices/cpu/caps/branches ] &&
    [ ! -f /sys/bus/event_source/devices/cpu_core/caps/branches ]
 then
@@ -23,6 +27,7 @@ cleanup() {
 }
 
 trap_cleanup() {
+  echo "Unexpected signal in ${FUNCNAME[1]}"
   cleanup
   exit 1
 }
@@ -123,8 +128,11 @@ lbr_test "-j ind_call" "any indirect call" 2
 lbr_test "-j ind_jmp" "any indirect jump" 100
 lbr_test "-j call" "direct calls" 2
 lbr_test "-j ind_call,u" "any indirect user call" 100
-lbr_test "-a -b" "system wide any branch" 2
-lbr_test "-a -j any_call" "system wide any call" 2
+if ! ParanoidAndNotRoot 1
+then
+  lbr_test "-a -b" "system wide any branch" 2
+  lbr_test "-a -j any_call" "system wide any call" 2
+fi
 
 # Parallel
 parallel_lbr_test "-b" "parallel any branch" 100 &
@@ -141,10 +149,16 @@ parallel_lbr_test "-j call" "parallel direct calls" 100 &
 pid6=$!
 parallel_lbr_test "-j ind_call,u" "parallel any indirect user call" 100 &
 pid7=$!
-parallel_lbr_test "-a -b" "parallel system wide any branch" 100 &
-pid8=$!
-parallel_lbr_test "-a -j any_call" "parallel system wide any call" 100 &
-pid9=$!
+if ParanoidAndNotRoot 1
+then
+  pid8=
+  pid9=
+else
+  parallel_lbr_test "-a -b" "parallel system wide any branch" 100 &
+  pid8=$!
+  parallel_lbr_test "-a -j any_call" "parallel system wide any call" 100 &
+  pid9=$!
+fi
 
 for pid in $pid1 $pid2 $pid3 $pid4 $pid5 $pid6 $pid7 $pid8 $pid9
 do
-- 
2.51.0.rc2.233.g662b1ed5c5-goog


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

* [PATCH v1 2/4] perf test: Don't leak workload gopipe in PERF_RECORD_*
  2025-08-21 22:18 [PATCH v1 0/4] Test/uniquification related fixes Ian Rogers
  2025-08-21 22:18 ` [PATCH v1 1/4] perf test shell lbr: Avoid failures with perf event paranoia Ian Rogers
@ 2025-08-21 22:18 ` Ian Rogers
  2025-09-16 19:04   ` Arnaldo Carvalho de Melo
  2025-08-21 22:18 ` [PATCH v1 3/4] perf evsel: Fix uniquification when PMU given without suffix Ian Rogers
  2025-08-21 22:18 ` [PATCH v1 4/4] perf test: Avoid uncore_imc/clockticks in uniquification test Ian Rogers
  3 siblings, 1 reply; 12+ messages in thread
From: Ian Rogers @ 2025-08-21 22:18 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
	Ian Rogers, Adrian Hunter, Kan Liang, Chun-Tse Shao, James Clark,
	Howard Chu, linux-kernel, linux-perf-users

The test starts a workload and then opens events. If the events fail
to open, for example because of perf_event_paranoid, the gopipe of the
workload is leaked and the file descriptor leak check fails when the
test exits. To avoid this cancel the workload when opening the events
fails.

Before:
```
$ perf test -vv 7
  7: PERF_RECORD_* events & perf_sample fields:
--- start ---
test child forked, pid 1189568
Using CPUID GenuineIntel-6-B7-1
------------------------------------------------------------
perf_event_attr:
  type                             0 (PERF_TYPE_HARDWARE)
  config                           0xa00000000 (cpu_atom/PERF_COUNT_HW_CPU_CYCLES/)
  disabled                         1
------------------------------------------------------------
sys_perf_event_open: pid 0  cpu -1  group_fd -1  flags 0x8
sys_perf_event_open failed, error -13
------------------------------------------------------------
perf_event_attr:
  type                             0 (PERF_TYPE_HARDWARE)
  config                           0xa00000000 (cpu_atom/PERF_COUNT_HW_CPU_CYCLES/)
  disabled                         1
  exclude_kernel                   1
------------------------------------------------------------
sys_perf_event_open: pid 0  cpu -1  group_fd -1  flags 0x8 = 3
------------------------------------------------------------
perf_event_attr:
  type                             0 (PERF_TYPE_HARDWARE)
  config                           0x400000000 (cpu_core/PERF_COUNT_HW_CPU_CYCLES/)
  disabled                         1
------------------------------------------------------------
sys_perf_event_open: pid 0  cpu -1  group_fd -1  flags 0x8
sys_perf_event_open failed, error -13
------------------------------------------------------------
perf_event_attr:
  type                             0 (PERF_TYPE_HARDWARE)
  config                           0x400000000 (cpu_core/PERF_COUNT_HW_CPU_CYCLES/)
  disabled                         1
  exclude_kernel                   1
------------------------------------------------------------
sys_perf_event_open: pid 0  cpu -1  group_fd -1  flags 0x8 = 3
Attempt to add: software/cpu-clock/
..after resolving event: software/config=0/
cpu-clock -> software/cpu-clock/
------------------------------------------------------------
perf_event_attr:
  type                             1 (PERF_TYPE_SOFTWARE)
  size                             136
  config                           0x9 (PERF_COUNT_SW_DUMMY)
  sample_type                      IP|TID|TIME|CPU
  read_format                      ID|LOST
  disabled                         1
  inherit                          1
  mmap                             1
  comm                             1
  enable_on_exec                   1
  task                             1
  sample_id_all                    1
  mmap2                            1
  comm_exec                        1
  ksymbol                          1
  bpf_event                        1
  { wakeup_events, wakeup_watermark } 1
------------------------------------------------------------
sys_perf_event_open: pid 1189569  cpu 0  group_fd -1  flags 0x8
sys_perf_event_open failed, error -13
perf_evlist__open: Permission denied
---- end(-2) ----
Leak of file descriptor 6 that opened: 'pipe:[14200347]'

---- unexpected signal (6) ----
Failed to read build ID for //anon
Failed to read build ID for //anon
Failed to read build ID for //anon
Failed to read build ID for //anon
Failed to read build ID for //anon
Failed to read build ID for //anon
Failed to read build ID for //anon
Failed to read build ID for //anon
Failed to read build ID for //anon
Failed to read build ID for //anon
Failed to read build ID for //anon
Failed to read build ID for //anon
Failed to read build ID for //anon
Failed to read build ID for //anon
Failed to read build ID for //anon
Failed to read build ID for //anon
Failed to read build ID for //anon
Failed to read build ID for //anon
Failed to read build ID for //anon
Failed to read build ID for //anon
Failed to read build ID for //anon
Failed to read build ID for //anon
Failed to read build ID for //anon
Failed to read build ID for //anon
Failed to read build ID for //anon
Failed to read build ID for //anon
Failed to read build ID for //anon
Failed to read build ID for //anon
Failed to read build ID for //anon
Failed to read build ID for //anon
Failed to read build ID for //anon
Failed to read build ID for //anon
    #0 0x565358f6666e in child_test_sig_handler builtin-test.c:311
    #1 0x7f29ce849df0 in __restore_rt libc_sigaction.c:0
    #2 0x7f29ce89e95c in __pthread_kill_implementation pthread_kill.c:44
    #3 0x7f29ce849cc2 in raise raise.c:27
    #4 0x7f29ce8324ac in abort abort.c:81
    #5 0x565358f662d4 in check_leaks builtin-test.c:226
    #6 0x565358f6682e in run_test_child builtin-test.c:344
    #7 0x565358ef7121 in start_command run-command.c:128
    #8 0x565358f67273 in start_test builtin-test.c:545
    #9 0x565358f6771d in __cmd_test builtin-test.c:647
    #10 0x565358f682bd in cmd_test builtin-test.c:849
    #11 0x565358ee5ded in run_builtin perf.c:349
    #12 0x565358ee6085 in handle_internal_command perf.c:401
    #13 0x565358ee61de in run_argv perf.c:448
    #14 0x565358ee6527 in main perf.c:555
    #15 0x7f29ce833ca8 in __libc_start_call_main libc_start_call_main.h:74
    #16 0x7f29ce833d65 in __libc_start_main@@GLIBC_2.34 libc-start.c:128
    #17 0x565358e391c1 in _start perf[851c1]
  7: PERF_RECORD_* events & perf_sample fields                       : FAILED!
```

After:
```
$ perf test 7
  7: PERF_RECORD_* events & perf_sample fields                       : Skip (permissions)
```

Fixes: 16d00fee7038 ("perf tests: Move test__PERF_RECORD into separate object")
Signed-off-by: Ian Rogers <irogers@google.com>
---
 tools/perf/tests/perf-record.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tools/perf/tests/perf-record.c b/tools/perf/tests/perf-record.c
index 0b3c37e66871..8c79b5166a05 100644
--- a/tools/perf/tests/perf-record.c
+++ b/tools/perf/tests/perf-record.c
@@ -115,6 +115,7 @@ static int test__PERF_RECORD(struct test_suite *test __maybe_unused, int subtest
 	if (err < 0) {
 		pr_debug("sched__get_first_possible_cpu: %s\n",
 			 str_error_r(errno, sbuf, sizeof(sbuf)));
+		evlist__cancel_workload(evlist);
 		goto out_delete_evlist;
 	}
 
@@ -126,6 +127,7 @@ static int test__PERF_RECORD(struct test_suite *test __maybe_unused, int subtest
 	if (sched_setaffinity(evlist->workload.pid, cpu_mask_size, &cpu_mask) < 0) {
 		pr_debug("sched_setaffinity: %s\n",
 			 str_error_r(errno, sbuf, sizeof(sbuf)));
+		evlist__cancel_workload(evlist);
 		goto out_delete_evlist;
 	}
 
@@ -137,6 +139,7 @@ static int test__PERF_RECORD(struct test_suite *test __maybe_unused, int subtest
 	if (err < 0) {
 		pr_debug("perf_evlist__open: %s\n",
 			 str_error_r(errno, sbuf, sizeof(sbuf)));
+		evlist__cancel_workload(evlist);
 		goto out_delete_evlist;
 	}
 
@@ -149,6 +152,7 @@ static int test__PERF_RECORD(struct test_suite *test __maybe_unused, int subtest
 	if (err < 0) {
 		pr_debug("evlist__mmap: %s\n",
 			 str_error_r(errno, sbuf, sizeof(sbuf)));
+		evlist__cancel_workload(evlist);
 		goto out_delete_evlist;
 	}
 
-- 
2.51.0.rc2.233.g662b1ed5c5-goog


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

* [PATCH v1 3/4] perf evsel: Fix uniquification when PMU given without suffix
  2025-08-21 22:18 [PATCH v1 0/4] Test/uniquification related fixes Ian Rogers
  2025-08-21 22:18 ` [PATCH v1 1/4] perf test shell lbr: Avoid failures with perf event paranoia Ian Rogers
  2025-08-21 22:18 ` [PATCH v1 2/4] perf test: Don't leak workload gopipe in PERF_RECORD_* Ian Rogers
@ 2025-08-21 22:18 ` Ian Rogers
  2025-08-21 22:18 ` [PATCH v1 4/4] perf test: Avoid uncore_imc/clockticks in uniquification test Ian Rogers
  3 siblings, 0 replies; 12+ messages in thread
From: Ian Rogers @ 2025-08-21 22:18 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
	Ian Rogers, Adrian Hunter, Kan Liang, Chun-Tse Shao, James Clark,
	Howard Chu, linux-kernel, linux-perf-users

The PMU name is appearing twice in:
```
$ perf stat -e uncore_imc_free_running/data_total/ -A true

 Performance counter stats for 'system wide':

CPU0                 1.57 MiB  uncore_imc_free_running_0/uncore_imc_free_running,data_total/
CPU0                 1.58 MiB  uncore_imc_free_running_1/uncore_imc_free_running,data_total/
       0.000892376 seconds time elapsed
```

Use the pmu_name_len_no_suffix to avoid this problem.

Fixes: 7d45f402d311 ("perf evlist: Make uniquifying counter names consistent")
Signed-off-by: Ian Rogers <irogers@google.com>
---
 tools/perf/util/evsel.c | 28 ++++++++++++++++++----------
 1 file changed, 18 insertions(+), 10 deletions(-)

diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index d264c143b592..9a6e2d556d35 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -4048,9 +4048,9 @@ bool evsel__set_needs_uniquify(struct evsel *counter, const struct perf_stat_con
 
 void evsel__uniquify_counter(struct evsel *counter)
 {
-	const char *name, *pmu_name;
-	char *new_name, *config;
-	int ret;
+	const char *name, *pmu_name, *config;
+	char *new_name;
+	int len, ret;
 
 	/* No uniquification necessary. */
 	if (!counter->needs_uniquify)
@@ -4064,15 +4064,23 @@ void evsel__uniquify_counter(struct evsel *counter)
 	counter->uniquified_name = true;
 
 	name = evsel__name(counter);
+	config = strchr(name, '/');
 	pmu_name = counter->pmu->name;
-	/* Already prefixed by the PMU name. */
-	if (!strncmp(name, pmu_name, strlen(pmu_name)))
-		return;
 
-	config = strchr(name, '/');
-	if (config) {
-		int len = config - name;
+	/* Already prefixed by the PMU name? */
+	len = pmu_name_len_no_suffix(pmu_name);
+
+	if (!strncmp(name, pmu_name, len)) {
+		/*
+		 * If the PMU name is there, then there is no sense in not
+		 * having a slash. Do this for robustness.
+		 */
+		if (config == NULL)
+			config = name - 1;
 
+		ret = asprintf(&new_name, "%s/%s", pmu_name, config + 1);
+	} else if (config) {
+		len = config - name;
 		if (config[1] == '/') {
 			/* case: event// */
 			ret = asprintf(&new_name, "%s/%.*s/%s", pmu_name, len, name, config + 2);
@@ -4084,7 +4092,7 @@ void evsel__uniquify_counter(struct evsel *counter)
 		config = strchr(name, ':');
 		if (config) {
 			/* case: event:.. */
-			int len = config - name;
+			len = config - name;
 
 			ret = asprintf(&new_name, "%s/%.*s/%s", pmu_name, len, name, config + 1);
 		} else {
-- 
2.51.0.rc2.233.g662b1ed5c5-goog


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

* [PATCH v1 4/4] perf test: Avoid uncore_imc/clockticks in uniquification test
  2025-08-21 22:18 [PATCH v1 0/4] Test/uniquification related fixes Ian Rogers
                   ` (2 preceding siblings ...)
  2025-08-21 22:18 ` [PATCH v1 3/4] perf evsel: Fix uniquification when PMU given without suffix Ian Rogers
@ 2025-08-21 22:18 ` Ian Rogers
  2025-09-16 19:15   ` Arnaldo Carvalho de Melo
  3 siblings, 1 reply; 12+ messages in thread
From: Ian Rogers @ 2025-08-21 22:18 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
	Ian Rogers, Adrian Hunter, Kan Liang, Chun-Tse Shao, James Clark,
	Howard Chu, linux-kernel, linux-perf-users

The detection of uncore_imc may happen for free running PMUs and the
clockticks event may be present on uncore_clock. Rewrite the test to
detect duplicated/deduplicated events from perf list, not hardcoded to
uncore_imc.

Fixes: 070b315333ee ("perf test: Restrict uniquifying test to machines with 'uncore_imc'")
Signed-off-by: Ian Rogers <irogers@google.com>
---
 .../tests/shell/stat+event_uniquifying.sh     | 105 ++++++++----------
 1 file changed, 44 insertions(+), 61 deletions(-)

diff --git a/tools/perf/tests/shell/stat+event_uniquifying.sh b/tools/perf/tests/shell/stat+event_uniquifying.sh
index bf54bd6c3e2e..9bc7a1f520f9 100755
--- a/tools/perf/tests/shell/stat+event_uniquifying.sh
+++ b/tools/perf/tests/shell/stat+event_uniquifying.sh
@@ -4,74 +4,57 @@
 
 set -e
 
-stat_output=$(mktemp /tmp/__perf_test.stat_output.XXXXX)
-perf_tool=perf
 err=0
+stat_output=$(mktemp /tmp/__perf_test.stat_output.XXXXX)
 
-test_event_uniquifying() {
-  # We use `clockticks` in `uncore_imc` to verify the uniquify behavior.
-  pmu="uncore_imc"
-  event="clockticks"
-
-  # If the `-A` option is added, the event should be uniquified.
-  #
-  # $perf list -v clockticks
-  #
-  # List of pre-defined events (to be used in -e or -M):
-  #
-  #   uncore_imc_0/clockticks/                           [Kernel PMU event]
-  #   uncore_imc_1/clockticks/                           [Kernel PMU event]
-  #   uncore_imc_2/clockticks/                           [Kernel PMU event]
-  #   uncore_imc_3/clockticks/                           [Kernel PMU event]
-  #   uncore_imc_4/clockticks/                           [Kernel PMU event]
-  #   uncore_imc_5/clockticks/                           [Kernel PMU event]
-  #
-  #   ...
-  #
-  # $perf stat -e clockticks -A -- true
-  #
-  #  Performance counter stats for 'system wide':
-  #
-  # CPU0            3,773,018      uncore_imc_0/clockticks/
-  # CPU0            3,609,025      uncore_imc_1/clockticks/
-  # CPU0                    0      uncore_imc_2/clockticks/
-  # CPU0            3,230,009      uncore_imc_3/clockticks/
-  # CPU0            3,049,897      uncore_imc_4/clockticks/
-  # CPU0                    0      uncore_imc_5/clockticks/
-  #
-  #        0.002029828 seconds time elapsed
-
-  echo "stat event uniquifying test"
-  uniquified_event_array=()
-
-  # Skip if the machine does not have `uncore_imc` device.
-  if ! ${perf_tool} list pmu | grep -q ${pmu}; then
-    echo "Target does not support PMU ${pmu} [Skipped]"
-    err=2
-    return
-  fi
+cleanup() {
+  rm -f "${stat_output}"
 
-  # Check how many uniquified events.
-  while IFS= read -r line; do
-    uniquified_event=$(echo "$line" | awk '{print $1}')
-    uniquified_event_array+=("${uniquified_event}")
-  done < <(${perf_tool} list -v ${event} | grep ${pmu})
+  trap - EXIT TERM INT
+}
 
-  perf_command="${perf_tool} stat -e $event -A -o ${stat_output} -- true"
-  $perf_command
+trap_cleanup() {
+  echo "Unexpected signal in ${FUNCNAME[1]}"
+  cleanup
+  exit 1
+}
+trap trap_cleanup EXIT TERM INT
 
-  # Check the output contains all uniquified events.
-  for uniquified_event in "${uniquified_event_array[@]}"; do
-    if ! cat "${stat_output}" | grep -q "${uniquified_event}"; then
-      echo "Event is not uniquified [Failed]"
-      echo "${perf_command}"
-      cat "${stat_output}"
-      err=1
-      break
-    fi
+test_event_uniquifying() {
+  echo "Uniquification of PMU sysfs events test"
+
+  # Read events from perf list with and without -v. With -v the duplicate PMUs
+  # aren't deduplicated. Note, json events are listed by perf list without a
+  # PMU.
+  read -ra pmu_events <<< "$(perf list --raw pmu)"
+  read -ra pmu_v_events <<< "$(perf list -v --raw pmu)"
+  # For all non-deduplicated events.
+  for pmu_v_event in "${pmu_v_events[@]}"; do
+    # If the event matches an event in the deduplicated events then it musn't
+    # be an event with duplicate PMUs, continue the outer loop.
+    for pmu_event in "${pmu_events[@]}"; do
+      if [[ "$pmu_v_event" == "$pmu_event" ]]; then
+        continue 2
+      fi
+    done
+    # Strip the suffix from the non-deduplicated event's PMU.
+    event=$(echo "$pmu_v_event" | sed -E 's/_[0-9]+//')
+    for pmu_event in "${pmu_events[@]}"; do
+      if [[ "$event" == "$pmu_event" ]]; then
+        echo "Testing event ${event} is uniquified to ${pmu_v_event}"
+        perf stat -e "$event" -A -o ${stat_output} -- true
+        # Ensure the non-deduplicated event appears in the output.
+        if ! grep -q "${pmu_v_event}" "${stat_output}"; then
+          echo "Uniquification of PMU sysfs events test [Failed]"
+          cat "${stat_output}"
+          err=1
+        fi
+        break
+      fi
+    done
   done
 }
 
 test_event_uniquifying
-rm -f "${stat_output}"
+cleanup
 exit $err
-- 
2.51.0.rc2.233.g662b1ed5c5-goog


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

* Re: [PATCH v1 1/4] perf test shell lbr: Avoid failures with perf event paranoia
  2025-08-21 22:18 ` [PATCH v1 1/4] perf test shell lbr: Avoid failures with perf event paranoia Ian Rogers
@ 2025-09-16 19:00   ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 12+ messages in thread
From: Arnaldo Carvalho de Melo @ 2025-09-16 19:00 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Peter Zijlstra, Ingo Molnar, Namhyung Kim, Mark Rutland,
	Alexander Shishkin, Jiri Olsa, Adrian Hunter, Kan Liang,
	Chun-Tse Shao, James Clark, Howard Chu, linux-kernel,
	linux-perf-users

On Thu, Aug 21, 2025 at 03:18:31PM -0700, Ian Rogers wrote:
> When not running as root and with higher perf event paranoia values
> the perf record LBR tests could fail rather than skipping the
> problematic tests. Add the sensitivity to the test and confirm it
> passes with paranoia values from -1 to 2.

Thanks, applied to perf-tools-next,

Committer testing:

Testing with '$ perf test -vv lbr', i.e. as non root, and then comparing
the output shows the mentioned errors before this patch:

  acme@x1:~$ grep -m1 "model name" /proc/cpuinfo
  model name    : 13th Gen Intel(R) Core(TM) i7-1365U
  acme@x1:~$ 

Before:

 132: perf record LBR tests            : Skip

After:

 132: perf record LBR tests            : Ok

- Arnaldo
 
> Fixes: 32559b99e0f5 ("perf test: Add set of perf record LBR tests")
> Signed-off-by: Ian Rogers <irogers@google.com>
> ---
>  tools/perf/tests/shell/record_lbr.sh | 26 ++++++++++++++++++++------
>  1 file changed, 20 insertions(+), 6 deletions(-)
> 
> diff --git a/tools/perf/tests/shell/record_lbr.sh b/tools/perf/tests/shell/record_lbr.sh
> index 6fcb5e52b9b4..78a02e90ece1 100755
> --- a/tools/perf/tests/shell/record_lbr.sh
> +++ b/tools/perf/tests/shell/record_lbr.sh
> @@ -4,6 +4,10 @@
>  
>  set -e
>  
> +ParanoidAndNotRoot() {
> +  [ "$(id -u)" != 0 ] && [ "$(cat /proc/sys/kernel/perf_event_paranoid)" -gt $1 ]
> +}
> +
>  if [ ! -f /sys/bus/event_source/devices/cpu/caps/branches ] &&
>     [ ! -f /sys/bus/event_source/devices/cpu_core/caps/branches ]
>  then
> @@ -23,6 +27,7 @@ cleanup() {
>  }
>  
>  trap_cleanup() {
> +  echo "Unexpected signal in ${FUNCNAME[1]}"
>    cleanup
>    exit 1
>  }
> @@ -123,8 +128,11 @@ lbr_test "-j ind_call" "any indirect call" 2
>  lbr_test "-j ind_jmp" "any indirect jump" 100
>  lbr_test "-j call" "direct calls" 2
>  lbr_test "-j ind_call,u" "any indirect user call" 100
> -lbr_test "-a -b" "system wide any branch" 2
> -lbr_test "-a -j any_call" "system wide any call" 2
> +if ! ParanoidAndNotRoot 1
> +then
> +  lbr_test "-a -b" "system wide any branch" 2
> +  lbr_test "-a -j any_call" "system wide any call" 2
> +fi
>  
>  # Parallel
>  parallel_lbr_test "-b" "parallel any branch" 100 &
> @@ -141,10 +149,16 @@ parallel_lbr_test "-j call" "parallel direct calls" 100 &
>  pid6=$!
>  parallel_lbr_test "-j ind_call,u" "parallel any indirect user call" 100 &
>  pid7=$!
> -parallel_lbr_test "-a -b" "parallel system wide any branch" 100 &
> -pid8=$!
> -parallel_lbr_test "-a -j any_call" "parallel system wide any call" 100 &
> -pid9=$!
> +if ParanoidAndNotRoot 1
> +then
> +  pid8=
> +  pid9=
> +else
> +  parallel_lbr_test "-a -b" "parallel system wide any branch" 100 &
> +  pid8=$!
> +  parallel_lbr_test "-a -j any_call" "parallel system wide any call" 100 &
> +  pid9=$!
> +fi
>  
>  for pid in $pid1 $pid2 $pid3 $pid4 $pid5 $pid6 $pid7 $pid8 $pid9
>  do
> -- 
> 2.51.0.rc2.233.g662b1ed5c5-goog

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

* Re: [PATCH v1 2/4] perf test: Don't leak workload gopipe in PERF_RECORD_*
  2025-08-21 22:18 ` [PATCH v1 2/4] perf test: Don't leak workload gopipe in PERF_RECORD_* Ian Rogers
@ 2025-09-16 19:04   ` Arnaldo Carvalho de Melo
  2025-09-16 19:08     ` Ian Rogers
  0 siblings, 1 reply; 12+ messages in thread
From: Arnaldo Carvalho de Melo @ 2025-09-16 19:04 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Peter Zijlstra, Ingo Molnar, Namhyung Kim, Mark Rutland,
	Alexander Shishkin, Jiri Olsa, Adrian Hunter, Kan Liang,
	Chun-Tse Shao, James Clark, Howard Chu, linux-kernel,
	linux-perf-users

On Thu, Aug 21, 2025 at 03:18:32PM -0700, Ian Rogers wrote:
> The test starts a workload and then opens events. If the events fail
> to open, for example because of perf_event_paranoid, the gopipe of the
> workload is leaked and the file descriptor leak check fails when the
> test exits. To avoid this cancel the workload when opening the events
> fails.
> 
> Before:
> ```
> $ perf test -vv 7
>   7: PERF_RECORD_* events & perf_sample fields:
> --- start ---

⬢ [acme@toolbx perf-tools-next]$ patch -p1 < b
patching file tools/perf/tests/perf-record.c
Hunk #1 succeeded at 130 (offset 15 lines).
Hunk #2 succeeded at 142 with fuzz 1 (offset 15 lines).
Hunk #3 succeeded at 154 (offset 15 lines).
Hunk #4 succeeded at 167 (offset 15 lines).
⬢ [acme@toolbx perf-tools-next]$ 
⬢ [acme@toolbx perf-tools-next]$ git log --oneline -5 tools/perf/tests/perf-record.c
576bd7a8c90c48e9 (x1/perf-tools-next, x1/HEAD, five/perf-tools-next, five/HEAD) perf tests record: Update testcase to fix usage of affinity for machines with #CPUs > 1K
b4c658d4d63d6149 perf target: Remove uid from target
dc6d2bc2d893a878 perf sample: Make user_regs and intr_regs optional
fd8d5a3b076c033f perf tests: Add missing event.h include
9823147da6c893d9 perf tools: Move 'struct perf_sample' to a separate header file to disentangle headers
⬢ [acme@toolbx perf-tools-next]$

Can you please check that it is still ok?

I processed the first in the series and now I'm going thru the other
two.

- Arnaldo

> test child forked, pid 1189568
> Using CPUID GenuineIntel-6-B7-1
> ------------------------------------------------------------
> perf_event_attr:
>   type                             0 (PERF_TYPE_HARDWARE)
>   config                           0xa00000000 (cpu_atom/PERF_COUNT_HW_CPU_CYCLES/)
>   disabled                         1
> ------------------------------------------------------------
> sys_perf_event_open: pid 0  cpu -1  group_fd -1  flags 0x8
> sys_perf_event_open failed, error -13
> ------------------------------------------------------------
> perf_event_attr:
>   type                             0 (PERF_TYPE_HARDWARE)
>   config                           0xa00000000 (cpu_atom/PERF_COUNT_HW_CPU_CYCLES/)
>   disabled                         1
>   exclude_kernel                   1
> ------------------------------------------------------------
> sys_perf_event_open: pid 0  cpu -1  group_fd -1  flags 0x8 = 3
> ------------------------------------------------------------
> perf_event_attr:
>   type                             0 (PERF_TYPE_HARDWARE)
>   config                           0x400000000 (cpu_core/PERF_COUNT_HW_CPU_CYCLES/)
>   disabled                         1
> ------------------------------------------------------------
> sys_perf_event_open: pid 0  cpu -1  group_fd -1  flags 0x8
> sys_perf_event_open failed, error -13
> ------------------------------------------------------------
> perf_event_attr:
>   type                             0 (PERF_TYPE_HARDWARE)
>   config                           0x400000000 (cpu_core/PERF_COUNT_HW_CPU_CYCLES/)
>   disabled                         1
>   exclude_kernel                   1
> ------------------------------------------------------------
> sys_perf_event_open: pid 0  cpu -1  group_fd -1  flags 0x8 = 3
> Attempt to add: software/cpu-clock/
> ..after resolving event: software/config=0/
> cpu-clock -> software/cpu-clock/
> ------------------------------------------------------------
> perf_event_attr:
>   type                             1 (PERF_TYPE_SOFTWARE)
>   size                             136
>   config                           0x9 (PERF_COUNT_SW_DUMMY)
>   sample_type                      IP|TID|TIME|CPU
>   read_format                      ID|LOST
>   disabled                         1
>   inherit                          1
>   mmap                             1
>   comm                             1
>   enable_on_exec                   1
>   task                             1
>   sample_id_all                    1
>   mmap2                            1
>   comm_exec                        1
>   ksymbol                          1
>   bpf_event                        1
>   { wakeup_events, wakeup_watermark } 1
> ------------------------------------------------------------
> sys_perf_event_open: pid 1189569  cpu 0  group_fd -1  flags 0x8
> sys_perf_event_open failed, error -13
> perf_evlist__open: Permission denied
> ---- end(-2) ----
> Leak of file descriptor 6 that opened: 'pipe:[14200347]'
> 
> ---- unexpected signal (6) ----
> Failed to read build ID for //anon
> Failed to read build ID for //anon
> Failed to read build ID for //anon
> Failed to read build ID for //anon
> Failed to read build ID for //anon
> Failed to read build ID for //anon
> Failed to read build ID for //anon
> Failed to read build ID for //anon
> Failed to read build ID for //anon
> Failed to read build ID for //anon
> Failed to read build ID for //anon
> Failed to read build ID for //anon
> Failed to read build ID for //anon
> Failed to read build ID for //anon
> Failed to read build ID for //anon
> Failed to read build ID for //anon
> Failed to read build ID for //anon
> Failed to read build ID for //anon
> Failed to read build ID for //anon
> Failed to read build ID for //anon
> Failed to read build ID for //anon
> Failed to read build ID for //anon
> Failed to read build ID for //anon
> Failed to read build ID for //anon
> Failed to read build ID for //anon
> Failed to read build ID for //anon
> Failed to read build ID for //anon
> Failed to read build ID for //anon
> Failed to read build ID for //anon
> Failed to read build ID for //anon
> Failed to read build ID for //anon
> Failed to read build ID for //anon
>     #0 0x565358f6666e in child_test_sig_handler builtin-test.c:311
>     #1 0x7f29ce849df0 in __restore_rt libc_sigaction.c:0
>     #2 0x7f29ce89e95c in __pthread_kill_implementation pthread_kill.c:44
>     #3 0x7f29ce849cc2 in raise raise.c:27
>     #4 0x7f29ce8324ac in abort abort.c:81
>     #5 0x565358f662d4 in check_leaks builtin-test.c:226
>     #6 0x565358f6682e in run_test_child builtin-test.c:344
>     #7 0x565358ef7121 in start_command run-command.c:128
>     #8 0x565358f67273 in start_test builtin-test.c:545
>     #9 0x565358f6771d in __cmd_test builtin-test.c:647
>     #10 0x565358f682bd in cmd_test builtin-test.c:849
>     #11 0x565358ee5ded in run_builtin perf.c:349
>     #12 0x565358ee6085 in handle_internal_command perf.c:401
>     #13 0x565358ee61de in run_argv perf.c:448
>     #14 0x565358ee6527 in main perf.c:555
>     #15 0x7f29ce833ca8 in __libc_start_call_main libc_start_call_main.h:74
>     #16 0x7f29ce833d65 in __libc_start_main@@GLIBC_2.34 libc-start.c:128
>     #17 0x565358e391c1 in _start perf[851c1]
>   7: PERF_RECORD_* events & perf_sample fields                       : FAILED!
> ```
> 
> After:
> ```
> $ perf test 7
>   7: PERF_RECORD_* events & perf_sample fields                       : Skip (permissions)
> ```
> 
> Fixes: 16d00fee7038 ("perf tests: Move test__PERF_RECORD into separate object")
> Signed-off-by: Ian Rogers <irogers@google.com>
> ---
>  tools/perf/tests/perf-record.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/tools/perf/tests/perf-record.c b/tools/perf/tests/perf-record.c
> index 0b3c37e66871..8c79b5166a05 100644
> --- a/tools/perf/tests/perf-record.c
> +++ b/tools/perf/tests/perf-record.c
> @@ -115,6 +115,7 @@ static int test__PERF_RECORD(struct test_suite *test __maybe_unused, int subtest
>  	if (err < 0) {
>  		pr_debug("sched__get_first_possible_cpu: %s\n",
>  			 str_error_r(errno, sbuf, sizeof(sbuf)));
> +		evlist__cancel_workload(evlist);
>  		goto out_delete_evlist;
>  	}
>  
> @@ -126,6 +127,7 @@ static int test__PERF_RECORD(struct test_suite *test __maybe_unused, int subtest
>  	if (sched_setaffinity(evlist->workload.pid, cpu_mask_size, &cpu_mask) < 0) {
>  		pr_debug("sched_setaffinity: %s\n",
>  			 str_error_r(errno, sbuf, sizeof(sbuf)));
> +		evlist__cancel_workload(evlist);
>  		goto out_delete_evlist;
>  	}
>  
> @@ -137,6 +139,7 @@ static int test__PERF_RECORD(struct test_suite *test __maybe_unused, int subtest
>  	if (err < 0) {
>  		pr_debug("perf_evlist__open: %s\n",
>  			 str_error_r(errno, sbuf, sizeof(sbuf)));
> +		evlist__cancel_workload(evlist);
>  		goto out_delete_evlist;
>  	}
>  
> @@ -149,6 +152,7 @@ static int test__PERF_RECORD(struct test_suite *test __maybe_unused, int subtest
>  	if (err < 0) {
>  		pr_debug("evlist__mmap: %s\n",
>  			 str_error_r(errno, sbuf, sizeof(sbuf)));
> +		evlist__cancel_workload(evlist);
>  		goto out_delete_evlist;
>  	}
>  
> -- 
> 2.51.0.rc2.233.g662b1ed5c5-goog

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

* Re: [PATCH v1 2/4] perf test: Don't leak workload gopipe in PERF_RECORD_*
  2025-09-16 19:04   ` Arnaldo Carvalho de Melo
@ 2025-09-16 19:08     ` Ian Rogers
  2025-09-17  1:06       ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 12+ messages in thread
From: Ian Rogers @ 2025-09-16 19:08 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Peter Zijlstra, Ingo Molnar, Namhyung Kim, Mark Rutland,
	Alexander Shishkin, Jiri Olsa, Adrian Hunter, Kan Liang,
	Chun-Tse Shao, James Clark, Howard Chu, linux-kernel,
	linux-perf-users

On Tue, Sep 16, 2025 at 12:04 PM Arnaldo Carvalho de Melo
<acme@kernel.org> wrote:
>
> On Thu, Aug 21, 2025 at 03:18:32PM -0700, Ian Rogers wrote:
> > The test starts a workload and then opens events. If the events fail
> > to open, for example because of perf_event_paranoid, the gopipe of the
> > workload is leaked and the file descriptor leak check fails when the
> > test exits. To avoid this cancel the workload when opening the events
> > fails.
> >
> > Before:
> > ```
> > $ perf test -vv 7
> >   7: PERF_RECORD_* events & perf_sample fields:
> > --- start ---
>
> ⬢ [acme@toolbx perf-tools-next]$ patch -p1 < b
> patching file tools/perf/tests/perf-record.c
> Hunk #1 succeeded at 130 (offset 15 lines).
> Hunk #2 succeeded at 142 with fuzz 1 (offset 15 lines).
> Hunk #3 succeeded at 154 (offset 15 lines).
> Hunk #4 succeeded at 167 (offset 15 lines).
> ⬢ [acme@toolbx perf-tools-next]$
> ⬢ [acme@toolbx perf-tools-next]$ git log --oneline -5 tools/perf/tests/perf-record.c
> 576bd7a8c90c48e9 (x1/perf-tools-next, x1/HEAD, five/perf-tools-next, five/HEAD) perf tests record: Update testcase to fix usage of affinity for machines with #CPUs > 1K
> b4c658d4d63d6149 perf target: Remove uid from target
> dc6d2bc2d893a878 perf sample: Make user_regs and intr_regs optional
> fd8d5a3b076c033f perf tests: Add missing event.h include
> 9823147da6c893d9 perf tools: Move 'struct perf_sample' to a separate header file to disentangle headers
> ⬢ [acme@toolbx perf-tools-next]$
>
> Can you please check that it is still ok?
>
> I processed the first in the series and now I'm going thru the other
> two.

Thanks Arnaldo! I'm not seeing the patch on:
https://web.git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/log/?h=tmp.perf-tools-next
I'm happy to check.

Ian

> - Arnaldo
>
> > test child forked, pid 1189568
> > Using CPUID GenuineIntel-6-B7-1
> > ------------------------------------------------------------
> > perf_event_attr:
> >   type                             0 (PERF_TYPE_HARDWARE)
> >   config                           0xa00000000 (cpu_atom/PERF_COUNT_HW_CPU_CYCLES/)
> >   disabled                         1
> > ------------------------------------------------------------
> > sys_perf_event_open: pid 0  cpu -1  group_fd -1  flags 0x8
> > sys_perf_event_open failed, error -13
> > ------------------------------------------------------------
> > perf_event_attr:
> >   type                             0 (PERF_TYPE_HARDWARE)
> >   config                           0xa00000000 (cpu_atom/PERF_COUNT_HW_CPU_CYCLES/)
> >   disabled                         1
> >   exclude_kernel                   1
> > ------------------------------------------------------------
> > sys_perf_event_open: pid 0  cpu -1  group_fd -1  flags 0x8 = 3
> > ------------------------------------------------------------
> > perf_event_attr:
> >   type                             0 (PERF_TYPE_HARDWARE)
> >   config                           0x400000000 (cpu_core/PERF_COUNT_HW_CPU_CYCLES/)
> >   disabled                         1
> > ------------------------------------------------------------
> > sys_perf_event_open: pid 0  cpu -1  group_fd -1  flags 0x8
> > sys_perf_event_open failed, error -13
> > ------------------------------------------------------------
> > perf_event_attr:
> >   type                             0 (PERF_TYPE_HARDWARE)
> >   config                           0x400000000 (cpu_core/PERF_COUNT_HW_CPU_CYCLES/)
> >   disabled                         1
> >   exclude_kernel                   1
> > ------------------------------------------------------------
> > sys_perf_event_open: pid 0  cpu -1  group_fd -1  flags 0x8 = 3
> > Attempt to add: software/cpu-clock/
> > ..after resolving event: software/config=0/
> > cpu-clock -> software/cpu-clock/
> > ------------------------------------------------------------
> > perf_event_attr:
> >   type                             1 (PERF_TYPE_SOFTWARE)
> >   size                             136
> >   config                           0x9 (PERF_COUNT_SW_DUMMY)
> >   sample_type                      IP|TID|TIME|CPU
> >   read_format                      ID|LOST
> >   disabled                         1
> >   inherit                          1
> >   mmap                             1
> >   comm                             1
> >   enable_on_exec                   1
> >   task                             1
> >   sample_id_all                    1
> >   mmap2                            1
> >   comm_exec                        1
> >   ksymbol                          1
> >   bpf_event                        1
> >   { wakeup_events, wakeup_watermark } 1
> > ------------------------------------------------------------
> > sys_perf_event_open: pid 1189569  cpu 0  group_fd -1  flags 0x8
> > sys_perf_event_open failed, error -13
> > perf_evlist__open: Permission denied
> > ---- end(-2) ----
> > Leak of file descriptor 6 that opened: 'pipe:[14200347]'
> >
> > ---- unexpected signal (6) ----
> > Failed to read build ID for //anon
> > Failed to read build ID for //anon
> > Failed to read build ID for //anon
> > Failed to read build ID for //anon
> > Failed to read build ID for //anon
> > Failed to read build ID for //anon
> > Failed to read build ID for //anon
> > Failed to read build ID for //anon
> > Failed to read build ID for //anon
> > Failed to read build ID for //anon
> > Failed to read build ID for //anon
> > Failed to read build ID for //anon
> > Failed to read build ID for //anon
> > Failed to read build ID for //anon
> > Failed to read build ID for //anon
> > Failed to read build ID for //anon
> > Failed to read build ID for //anon
> > Failed to read build ID for //anon
> > Failed to read build ID for //anon
> > Failed to read build ID for //anon
> > Failed to read build ID for //anon
> > Failed to read build ID for //anon
> > Failed to read build ID for //anon
> > Failed to read build ID for //anon
> > Failed to read build ID for //anon
> > Failed to read build ID for //anon
> > Failed to read build ID for //anon
> > Failed to read build ID for //anon
> > Failed to read build ID for //anon
> > Failed to read build ID for //anon
> > Failed to read build ID for //anon
> > Failed to read build ID for //anon
> >     #0 0x565358f6666e in child_test_sig_handler builtin-test.c:311
> >     #1 0x7f29ce849df0 in __restore_rt libc_sigaction.c:0
> >     #2 0x7f29ce89e95c in __pthread_kill_implementation pthread_kill.c:44
> >     #3 0x7f29ce849cc2 in raise raise.c:27
> >     #4 0x7f29ce8324ac in abort abort.c:81
> >     #5 0x565358f662d4 in check_leaks builtin-test.c:226
> >     #6 0x565358f6682e in run_test_child builtin-test.c:344
> >     #7 0x565358ef7121 in start_command run-command.c:128
> >     #8 0x565358f67273 in start_test builtin-test.c:545
> >     #9 0x565358f6771d in __cmd_test builtin-test.c:647
> >     #10 0x565358f682bd in cmd_test builtin-test.c:849
> >     #11 0x565358ee5ded in run_builtin perf.c:349
> >     #12 0x565358ee6085 in handle_internal_command perf.c:401
> >     #13 0x565358ee61de in run_argv perf.c:448
> >     #14 0x565358ee6527 in main perf.c:555
> >     #15 0x7f29ce833ca8 in __libc_start_call_main libc_start_call_main.h:74
> >     #16 0x7f29ce833d65 in __libc_start_main@@GLIBC_2.34 libc-start.c:128
> >     #17 0x565358e391c1 in _start perf[851c1]
> >   7: PERF_RECORD_* events & perf_sample fields                       : FAILED!
> > ```
> >
> > After:
> > ```
> > $ perf test 7
> >   7: PERF_RECORD_* events & perf_sample fields                       : Skip (permissions)
> > ```
> >
> > Fixes: 16d00fee7038 ("perf tests: Move test__PERF_RECORD into separate object")
> > Signed-off-by: Ian Rogers <irogers@google.com>
> > ---
> >  tools/perf/tests/perf-record.c | 4 ++++
> >  1 file changed, 4 insertions(+)
> >
> > diff --git a/tools/perf/tests/perf-record.c b/tools/perf/tests/perf-record.c
> > index 0b3c37e66871..8c79b5166a05 100644
> > --- a/tools/perf/tests/perf-record.c
> > +++ b/tools/perf/tests/perf-record.c
> > @@ -115,6 +115,7 @@ static int test__PERF_RECORD(struct test_suite *test __maybe_unused, int subtest
> >       if (err < 0) {
> >               pr_debug("sched__get_first_possible_cpu: %s\n",
> >                        str_error_r(errno, sbuf, sizeof(sbuf)));
> > +             evlist__cancel_workload(evlist);
> >               goto out_delete_evlist;
> >       }
> >
> > @@ -126,6 +127,7 @@ static int test__PERF_RECORD(struct test_suite *test __maybe_unused, int subtest
> >       if (sched_setaffinity(evlist->workload.pid, cpu_mask_size, &cpu_mask) < 0) {
> >               pr_debug("sched_setaffinity: %s\n",
> >                        str_error_r(errno, sbuf, sizeof(sbuf)));
> > +             evlist__cancel_workload(evlist);
> >               goto out_delete_evlist;
> >       }
> >
> > @@ -137,6 +139,7 @@ static int test__PERF_RECORD(struct test_suite *test __maybe_unused, int subtest
> >       if (err < 0) {
> >               pr_debug("perf_evlist__open: %s\n",
> >                        str_error_r(errno, sbuf, sizeof(sbuf)));
> > +             evlist__cancel_workload(evlist);
> >               goto out_delete_evlist;
> >       }
> >
> > @@ -149,6 +152,7 @@ static int test__PERF_RECORD(struct test_suite *test __maybe_unused, int subtest
> >       if (err < 0) {
> >               pr_debug("evlist__mmap: %s\n",
> >                        str_error_r(errno, sbuf, sizeof(sbuf)));
> > +             evlist__cancel_workload(evlist);
> >               goto out_delete_evlist;
> >       }
> >
> > --
> > 2.51.0.rc2.233.g662b1ed5c5-goog

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

* Re: [PATCH v1 4/4] perf test: Avoid uncore_imc/clockticks in uniquification test
  2025-08-21 22:18 ` [PATCH v1 4/4] perf test: Avoid uncore_imc/clockticks in uniquification test Ian Rogers
@ 2025-09-16 19:15   ` Arnaldo Carvalho de Melo
  2025-09-16 20:45     ` Ian Rogers
  0 siblings, 1 reply; 12+ messages in thread
From: Arnaldo Carvalho de Melo @ 2025-09-16 19:15 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Peter Zijlstra, Ingo Molnar, Namhyung Kim, Mark Rutland,
	Alexander Shishkin, Jiri Olsa, Adrian Hunter, Kan Liang,
	Chun-Tse Shao, James Clark, Howard Chu, linux-kernel,
	linux-perf-users

On Thu, Aug 21, 2025 at 03:18:34PM -0700, Ian Rogers wrote:
> The detection of uncore_imc may happen for free running PMUs and the
> clockticks event may be present on uncore_clock. Rewrite the test to
> detect duplicated/deduplicated events from perf list, not hardcoded to
> uncore_imc.

acme@x1:~/git/perf-tools-next$ perf test 96
 96: perf stat events uniquifying                                    : FAILED!
acme@x1:~/git/perf-tools-next$ perf test -vv 96
Couldn't bump rlimit(MEMLOCK), failures may take place when creating BPF maps, etc
 96: perf stat events uniquifying:
--- start ---
test child forked, pid 86847
Uniquification of PMU sysfs events test
Testing event uncore_imc_free_running/data_read/ is uniquified to uncore_imc_free_running_0/data_read/
Error:
The sys_perf_event_open() syscall returned with 22 (Invalid argument) for event (uncore_imc_free_running/data_read/u).
"dmesg | grep -i perf" may provide additional information.

Unexpected signal in test_event_uniquifying
---- end(-1) ----
 96: perf stat events uniquifying                                    : FAILED!


Works for root:

acme@x1:~/git/perf-tools-next$ sudo su -
[sudo] password for acme: 
root@x1:~# perf test 96
 96: perf stat events uniquifying                                    : Ok
root@x1:~#

acme@x1:~/git/perf-tools-next$ ls -la /sys/bus/event_source/devices/uncore_imc_free_running_*/events/
/sys/bus/event_source/devices/uncore_imc_free_running_0/events/:
total 0
drwxr-xr-x. 2 root root    0 Sep 16 16:09 .
drwxr-xr-x. 5 root root    0 Sep 16 16:09 ..
-r--r--r--. 1 root root 4096 Sep 16 16:09 data_read
-r--r--r--. 1 root root 4096 Sep 16 16:09 data_read.scale
-r--r--r--. 1 root root 4096 Sep 16 16:09 data_read.unit
-r--r--r--. 1 root root 4096 Sep 16 16:09 data_total
-r--r--r--. 1 root root 4096 Sep 16 16:09 data_total.scale
-r--r--r--. 1 root root 4096 Sep 16 16:09 data_total.unit
-r--r--r--. 1 root root 4096 Sep 16 16:09 data_write
-r--r--r--. 1 root root 4096 Sep 16 16:09 data_write.scale
-r--r--r--. 1 root root 4096 Sep 16 16:09 data_write.unit

/sys/bus/event_source/devices/uncore_imc_free_running_1/events/:
total 0
drwxr-xr-x. 2 root root    0 Sep 16 16:09 .
drwxr-xr-x. 5 root root    0 Sep 16 16:09 ..
-r--r--r--. 1 root root 4096 Sep 16 16:09 data_read
-r--r--r--. 1 root root 4096 Sep 16 16:09 data_read.scale
-r--r--r--. 1 root root 4096 Sep 16 16:09 data_read.unit
-r--r--r--. 1 root root 4096 Sep 16 16:09 data_total
-r--r--r--. 1 root root 4096 Sep 16 16:09 data_total.scale
-r--r--r--. 1 root root 4096 Sep 16 16:09 data_total.unit
-r--r--r--. 1 root root 4096 Sep 16 16:09 data_write
-r--r--r--. 1 root root 4096 Sep 16 16:09 data_write.scale
-r--r--r--. 1 root root 4096 Sep 16 16:09 data_write.unit
acme@x1:~/git/perf-tools-next$


 
> Fixes: 070b315333ee ("perf test: Restrict uniquifying test to machines with 'uncore_imc'")
> Signed-off-by: Ian Rogers <irogers@google.com>
> ---
>  .../tests/shell/stat+event_uniquifying.sh     | 105 ++++++++----------
>  1 file changed, 44 insertions(+), 61 deletions(-)
> 
> diff --git a/tools/perf/tests/shell/stat+event_uniquifying.sh b/tools/perf/tests/shell/stat+event_uniquifying.sh
> index bf54bd6c3e2e..9bc7a1f520f9 100755
> --- a/tools/perf/tests/shell/stat+event_uniquifying.sh
> +++ b/tools/perf/tests/shell/stat+event_uniquifying.sh
> @@ -4,74 +4,57 @@
>  
>  set -e
>  
> -stat_output=$(mktemp /tmp/__perf_test.stat_output.XXXXX)
> -perf_tool=perf
>  err=0
> +stat_output=$(mktemp /tmp/__perf_test.stat_output.XXXXX)
>  
> -test_event_uniquifying() {
> -  # We use `clockticks` in `uncore_imc` to verify the uniquify behavior.
> -  pmu="uncore_imc"
> -  event="clockticks"
> -
> -  # If the `-A` option is added, the event should be uniquified.
> -  #
> -  # $perf list -v clockticks
> -  #
> -  # List of pre-defined events (to be used in -e or -M):
> -  #
> -  #   uncore_imc_0/clockticks/                           [Kernel PMU event]
> -  #   uncore_imc_1/clockticks/                           [Kernel PMU event]
> -  #   uncore_imc_2/clockticks/                           [Kernel PMU event]
> -  #   uncore_imc_3/clockticks/                           [Kernel PMU event]
> -  #   uncore_imc_4/clockticks/                           [Kernel PMU event]
> -  #   uncore_imc_5/clockticks/                           [Kernel PMU event]
> -  #
> -  #   ...
> -  #
> -  # $perf stat -e clockticks -A -- true
> -  #
> -  #  Performance counter stats for 'system wide':
> -  #
> -  # CPU0            3,773,018      uncore_imc_0/clockticks/
> -  # CPU0            3,609,025      uncore_imc_1/clockticks/
> -  # CPU0                    0      uncore_imc_2/clockticks/
> -  # CPU0            3,230,009      uncore_imc_3/clockticks/
> -  # CPU0            3,049,897      uncore_imc_4/clockticks/
> -  # CPU0                    0      uncore_imc_5/clockticks/
> -  #
> -  #        0.002029828 seconds time elapsed
> -
> -  echo "stat event uniquifying test"
> -  uniquified_event_array=()
> -
> -  # Skip if the machine does not have `uncore_imc` device.
> -  if ! ${perf_tool} list pmu | grep -q ${pmu}; then
> -    echo "Target does not support PMU ${pmu} [Skipped]"
> -    err=2
> -    return
> -  fi
> +cleanup() {
> +  rm -f "${stat_output}"
>  
> -  # Check how many uniquified events.
> -  while IFS= read -r line; do
> -    uniquified_event=$(echo "$line" | awk '{print $1}')
> -    uniquified_event_array+=("${uniquified_event}")
> -  done < <(${perf_tool} list -v ${event} | grep ${pmu})
> +  trap - EXIT TERM INT
> +}
>  
> -  perf_command="${perf_tool} stat -e $event -A -o ${stat_output} -- true"
> -  $perf_command
> +trap_cleanup() {
> +  echo "Unexpected signal in ${FUNCNAME[1]}"
> +  cleanup
> +  exit 1
> +}
> +trap trap_cleanup EXIT TERM INT
>  
> -  # Check the output contains all uniquified events.
> -  for uniquified_event in "${uniquified_event_array[@]}"; do
> -    if ! cat "${stat_output}" | grep -q "${uniquified_event}"; then
> -      echo "Event is not uniquified [Failed]"
> -      echo "${perf_command}"
> -      cat "${stat_output}"
> -      err=1
> -      break
> -    fi
> +test_event_uniquifying() {
> +  echo "Uniquification of PMU sysfs events test"
> +
> +  # Read events from perf list with and without -v. With -v the duplicate PMUs
> +  # aren't deduplicated. Note, json events are listed by perf list without a
> +  # PMU.
> +  read -ra pmu_events <<< "$(perf list --raw pmu)"
> +  read -ra pmu_v_events <<< "$(perf list -v --raw pmu)"
> +  # For all non-deduplicated events.
> +  for pmu_v_event in "${pmu_v_events[@]}"; do
> +    # If the event matches an event in the deduplicated events then it musn't
> +    # be an event with duplicate PMUs, continue the outer loop.
> +    for pmu_event in "${pmu_events[@]}"; do
> +      if [[ "$pmu_v_event" == "$pmu_event" ]]; then
> +        continue 2
> +      fi
> +    done
> +    # Strip the suffix from the non-deduplicated event's PMU.
> +    event=$(echo "$pmu_v_event" | sed -E 's/_[0-9]+//')
> +    for pmu_event in "${pmu_events[@]}"; do
> +      if [[ "$event" == "$pmu_event" ]]; then
> +        echo "Testing event ${event} is uniquified to ${pmu_v_event}"
> +        perf stat -e "$event" -A -o ${stat_output} -- true
> +        # Ensure the non-deduplicated event appears in the output.
> +        if ! grep -q "${pmu_v_event}" "${stat_output}"; then
> +          echo "Uniquification of PMU sysfs events test [Failed]"
> +          cat "${stat_output}"
> +          err=1
> +        fi
> +        break
> +      fi
> +    done
>    done
>  }
>  
>  test_event_uniquifying
> -rm -f "${stat_output}"
> +cleanup
>  exit $err
> -- 
> 2.51.0.rc2.233.g662b1ed5c5-goog

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

* Re: [PATCH v1 4/4] perf test: Avoid uncore_imc/clockticks in uniquification test
  2025-09-16 19:15   ` Arnaldo Carvalho de Melo
@ 2025-09-16 20:45     ` Ian Rogers
  0 siblings, 0 replies; 12+ messages in thread
From: Ian Rogers @ 2025-09-16 20:45 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Peter Zijlstra, Ingo Molnar, Namhyung Kim, Mark Rutland,
	Alexander Shishkin, Jiri Olsa, Adrian Hunter, Kan Liang,
	Chun-Tse Shao, James Clark, Howard Chu, linux-kernel,
	linux-perf-users

On Tue, Sep 16, 2025 at 12:15 PM Arnaldo Carvalho de Melo
<acme@kernel.org> wrote:
>
> On Thu, Aug 21, 2025 at 03:18:34PM -0700, Ian Rogers wrote:
> > The detection of uncore_imc may happen for free running PMUs and the
> > clockticks event may be present on uncore_clock. Rewrite the test to
> > detect duplicated/deduplicated events from perf list, not hardcoded to
> > uncore_imc.
>
> acme@x1:~/git/perf-tools-next$ perf test 96
>  96: perf stat events uniquifying                                    : FAILED!
> acme@x1:~/git/perf-tools-next$ perf test -vv 96
> Couldn't bump rlimit(MEMLOCK), failures may take place when creating BPF maps, etc
>  96: perf stat events uniquifying:
> --- start ---
> test child forked, pid 86847
> Uniquification of PMU sysfs events test
> Testing event uncore_imc_free_running/data_read/ is uniquified to uncore_imc_free_running_0/data_read/
> Error:
> The sys_perf_event_open() syscall returned with 22 (Invalid argument) for event (uncore_imc_free_running/data_read/u).
> "dmesg | grep -i perf" may provide additional information.
>
> Unexpected signal in test_event_uniquifying
> ---- end(-1) ----
>  96: perf stat events uniquifying                                    : FAILED!
>
>
> Works for root:
>
> acme@x1:~/git/perf-tools-next$ sudo su -
> [sudo] password for acme:
> root@x1:~# perf test 96
>  96: perf stat events uniquifying                                    : Ok
> root@x1:~#
>
> acme@x1:~/git/perf-tools-next$ ls -la /sys/bus/event_source/devices/uncore_imc_free_running_*/events/
> /sys/bus/event_source/devices/uncore_imc_free_running_0/events/:
> total 0
> drwxr-xr-x. 2 root root    0 Sep 16 16:09 .
> drwxr-xr-x. 5 root root    0 Sep 16 16:09 ..
> -r--r--r--. 1 root root 4096 Sep 16 16:09 data_read
> -r--r--r--. 1 root root 4096 Sep 16 16:09 data_read.scale
> -r--r--r--. 1 root root 4096 Sep 16 16:09 data_read.unit
> -r--r--r--. 1 root root 4096 Sep 16 16:09 data_total
> -r--r--r--. 1 root root 4096 Sep 16 16:09 data_total.scale
> -r--r--r--. 1 root root 4096 Sep 16 16:09 data_total.unit
> -r--r--r--. 1 root root 4096 Sep 16 16:09 data_write
> -r--r--r--. 1 root root 4096 Sep 16 16:09 data_write.scale
> -r--r--r--. 1 root root 4096 Sep 16 16:09 data_write.unit
>
> /sys/bus/event_source/devices/uncore_imc_free_running_1/events/:
> total 0
> drwxr-xr-x. 2 root root    0 Sep 16 16:09 .
> drwxr-xr-x. 5 root root    0 Sep 16 16:09 ..
> -r--r--r--. 1 root root 4096 Sep 16 16:09 data_read
> -r--r--r--. 1 root root 4096 Sep 16 16:09 data_read.scale
> -r--r--r--. 1 root root 4096 Sep 16 16:09 data_read.unit
> -r--r--r--. 1 root root 4096 Sep 16 16:09 data_total
> -r--r--r--. 1 root root 4096 Sep 16 16:09 data_total.scale
> -r--r--r--. 1 root root 4096 Sep 16 16:09 data_total.unit
> -r--r--r--. 1 root root 4096 Sep 16 16:09 data_write
> -r--r--r--. 1 root root 4096 Sep 16 16:09 data_write.scale
> -r--r--r--. 1 root root 4096 Sep 16 16:09 data_write.unit
> acme@x1:~/git/perf-tools-next$

Looks like a permissions issue (opening an uncore event with user
filter is a bad idea, but is tried when open fails and we do
fallbacks). I'll do a v2 with a permission check fix and resolving the
earlier merge conflict.

Thanks,
Ian

> > Fixes: 070b315333ee ("perf test: Restrict uniquifying test to machines with 'uncore_imc'")
> > Signed-off-by: Ian Rogers <irogers@google.com>
> > ---
> >  .../tests/shell/stat+event_uniquifying.sh     | 105 ++++++++----------
> >  1 file changed, 44 insertions(+), 61 deletions(-)
> >
> > diff --git a/tools/perf/tests/shell/stat+event_uniquifying.sh b/tools/perf/tests/shell/stat+event_uniquifying.sh
> > index bf54bd6c3e2e..9bc7a1f520f9 100755
> > --- a/tools/perf/tests/shell/stat+event_uniquifying.sh
> > +++ b/tools/perf/tests/shell/stat+event_uniquifying.sh
> > @@ -4,74 +4,57 @@
> >
> >  set -e
> >
> > -stat_output=$(mktemp /tmp/__perf_test.stat_output.XXXXX)
> > -perf_tool=perf
> >  err=0
> > +stat_output=$(mktemp /tmp/__perf_test.stat_output.XXXXX)
> >
> > -test_event_uniquifying() {
> > -  # We use `clockticks` in `uncore_imc` to verify the uniquify behavior.
> > -  pmu="uncore_imc"
> > -  event="clockticks"
> > -
> > -  # If the `-A` option is added, the event should be uniquified.
> > -  #
> > -  # $perf list -v clockticks
> > -  #
> > -  # List of pre-defined events (to be used in -e or -M):
> > -  #
> > -  #   uncore_imc_0/clockticks/                           [Kernel PMU event]
> > -  #   uncore_imc_1/clockticks/                           [Kernel PMU event]
> > -  #   uncore_imc_2/clockticks/                           [Kernel PMU event]
> > -  #   uncore_imc_3/clockticks/                           [Kernel PMU event]
> > -  #   uncore_imc_4/clockticks/                           [Kernel PMU event]
> > -  #   uncore_imc_5/clockticks/                           [Kernel PMU event]
> > -  #
> > -  #   ...
> > -  #
> > -  # $perf stat -e clockticks -A -- true
> > -  #
> > -  #  Performance counter stats for 'system wide':
> > -  #
> > -  # CPU0            3,773,018      uncore_imc_0/clockticks/
> > -  # CPU0            3,609,025      uncore_imc_1/clockticks/
> > -  # CPU0                    0      uncore_imc_2/clockticks/
> > -  # CPU0            3,230,009      uncore_imc_3/clockticks/
> > -  # CPU0            3,049,897      uncore_imc_4/clockticks/
> > -  # CPU0                    0      uncore_imc_5/clockticks/
> > -  #
> > -  #        0.002029828 seconds time elapsed
> > -
> > -  echo "stat event uniquifying test"
> > -  uniquified_event_array=()
> > -
> > -  # Skip if the machine does not have `uncore_imc` device.
> > -  if ! ${perf_tool} list pmu | grep -q ${pmu}; then
> > -    echo "Target does not support PMU ${pmu} [Skipped]"
> > -    err=2
> > -    return
> > -  fi
> > +cleanup() {
> > +  rm -f "${stat_output}"
> >
> > -  # Check how many uniquified events.
> > -  while IFS= read -r line; do
> > -    uniquified_event=$(echo "$line" | awk '{print $1}')
> > -    uniquified_event_array+=("${uniquified_event}")
> > -  done < <(${perf_tool} list -v ${event} | grep ${pmu})
> > +  trap - EXIT TERM INT
> > +}
> >
> > -  perf_command="${perf_tool} stat -e $event -A -o ${stat_output} -- true"
> > -  $perf_command
> > +trap_cleanup() {
> > +  echo "Unexpected signal in ${FUNCNAME[1]}"
> > +  cleanup
> > +  exit 1
> > +}
> > +trap trap_cleanup EXIT TERM INT
> >
> > -  # Check the output contains all uniquified events.
> > -  for uniquified_event in "${uniquified_event_array[@]}"; do
> > -    if ! cat "${stat_output}" | grep -q "${uniquified_event}"; then
> > -      echo "Event is not uniquified [Failed]"
> > -      echo "${perf_command}"
> > -      cat "${stat_output}"
> > -      err=1
> > -      break
> > -    fi
> > +test_event_uniquifying() {
> > +  echo "Uniquification of PMU sysfs events test"
> > +
> > +  # Read events from perf list with and without -v. With -v the duplicate PMUs
> > +  # aren't deduplicated. Note, json events are listed by perf list without a
> > +  # PMU.
> > +  read -ra pmu_events <<< "$(perf list --raw pmu)"
> > +  read -ra pmu_v_events <<< "$(perf list -v --raw pmu)"
> > +  # For all non-deduplicated events.
> > +  for pmu_v_event in "${pmu_v_events[@]}"; do
> > +    # If the event matches an event in the deduplicated events then it musn't
> > +    # be an event with duplicate PMUs, continue the outer loop.
> > +    for pmu_event in "${pmu_events[@]}"; do
> > +      if [[ "$pmu_v_event" == "$pmu_event" ]]; then
> > +        continue 2
> > +      fi
> > +    done
> > +    # Strip the suffix from the non-deduplicated event's PMU.
> > +    event=$(echo "$pmu_v_event" | sed -E 's/_[0-9]+//')
> > +    for pmu_event in "${pmu_events[@]}"; do
> > +      if [[ "$event" == "$pmu_event" ]]; then
> > +        echo "Testing event ${event} is uniquified to ${pmu_v_event}"
> > +        perf stat -e "$event" -A -o ${stat_output} -- true
> > +        # Ensure the non-deduplicated event appears in the output.
> > +        if ! grep -q "${pmu_v_event}" "${stat_output}"; then
> > +          echo "Uniquification of PMU sysfs events test [Failed]"
> > +          cat "${stat_output}"
> > +          err=1
> > +        fi
> > +        break
> > +      fi
> > +    done
> >    done
> >  }
> >
> >  test_event_uniquifying
> > -rm -f "${stat_output}"
> > +cleanup
> >  exit $err
> > --
> > 2.51.0.rc2.233.g662b1ed5c5-goog

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

* Re: [PATCH v1 2/4] perf test: Don't leak workload gopipe in PERF_RECORD_*
  2025-09-16 19:08     ` Ian Rogers
@ 2025-09-17  1:06       ` Arnaldo Carvalho de Melo
  2025-09-18 22:17         ` Ian Rogers
  0 siblings, 1 reply; 12+ messages in thread
From: Arnaldo Carvalho de Melo @ 2025-09-17  1:06 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Peter Zijlstra, Ingo Molnar, Namhyung Kim, Mark Rutland,
	Alexander Shishkin, Jiri Olsa, Adrian Hunter, Kan Liang,
	Chun-Tse Shao, James Clark, Howard Chu, linux-kernel,
	linux-perf-users

On Tue, Sep 16, 2025 at 12:08:58PM -0700, Ian Rogers wrote:
> On Tue, Sep 16, 2025 at 12:04 PM Arnaldo Carvalho de Melo <acme@kernel.org> wrote:
> > On Thu, Aug 21, 2025 at 03:18:32PM -0700, Ian Rogers wrote:
> > > The test starts a workload and then opens events. If the events fail
> > > to open, for example because of perf_event_paranoid, the gopipe of the
> > > workload is leaked and the file descriptor leak check fails when the
> > > test exits. To avoid this cancel the workload when opening the events
> > > fails.

> > > Before:
> > > ```
> > > $ perf test -vv 7
> > >   7: PERF_RECORD_* events & perf_sample fields:
> > > --- start ---

> > ⬢ [acme@toolbx perf-tools-next]$ patch -p1 < b
> > patching file tools/perf/tests/perf-record.c
> > Hunk #1 succeeded at 130 (offset 15 lines).
> > Hunk #2 succeeded at 142 with fuzz 1 (offset 15 lines).
> > Hunk #3 succeeded at 154 (offset 15 lines).
> > Hunk #4 succeeded at 167 (offset 15 lines).
> > ⬢ [acme@toolbx perf-tools-next]$
> > ⬢ [acme@toolbx perf-tools-next]$ git log --oneline -5 tools/perf/tests/perf-record.c
> > 576bd7a8c90c48e9 (x1/perf-tools-next, x1/HEAD, five/perf-tools-next, five/HEAD) perf tests record: Update testcase to fix usage of affinity for machines with #CPUs > 1K
> > b4c658d4d63d6149 perf target: Remove uid from target
> > dc6d2bc2d893a878 perf sample: Make user_regs and intr_regs optional
> > fd8d5a3b076c033f perf tests: Add missing event.h include
> > 9823147da6c893d9 perf tools: Move 'struct perf_sample' to a separate header file to disentangle headers
> > ⬢ [acme@toolbx perf-tools-next]$

> > Can you please check that it is still ok?

> > I processed the first in the series and now I'm going thru the other
> > two.
 
> Thanks Arnaldo! I'm not seeing the patch on:
> https://web.git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/log/?h=tmp.perf-tools-next

Sorry, I thought I had pushed it earlier, should be there now.

> I'm happy to check.

Thanks!

- Arnaldo

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

* Re: [PATCH v1 2/4] perf test: Don't leak workload gopipe in PERF_RECORD_*
  2025-09-17  1:06       ` Arnaldo Carvalho de Melo
@ 2025-09-18 22:17         ` Ian Rogers
  0 siblings, 0 replies; 12+ messages in thread
From: Ian Rogers @ 2025-09-18 22:17 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Peter Zijlstra, Ingo Molnar, Namhyung Kim, Mark Rutland,
	Alexander Shishkin, Jiri Olsa, Adrian Hunter, Kan Liang,
	Chun-Tse Shao, James Clark, Howard Chu, linux-kernel,
	linux-perf-users

On Tue, Sep 16, 2025 at 6:06 PM Arnaldo Carvalho de Melo
<acme@kernel.org> wrote:
>
> On Tue, Sep 16, 2025 at 12:08:58PM -0700, Ian Rogers wrote:
> > On Tue, Sep 16, 2025 at 12:04 PM Arnaldo Carvalho de Melo <acme@kernel.org> wrote:
> > > On Thu, Aug 21, 2025 at 03:18:32PM -0700, Ian Rogers wrote:
> > > > The test starts a workload and then opens events. If the events fail
> > > > to open, for example because of perf_event_paranoid, the gopipe of the
> > > > workload is leaked and the file descriptor leak check fails when the
> > > > test exits. To avoid this cancel the workload when opening the events
> > > > fails.
>
> > > > Before:
> > > > ```
> > > > $ perf test -vv 7
> > > >   7: PERF_RECORD_* events & perf_sample fields:
> > > > --- start ---
>
> > > ⬢ [acme@toolbx perf-tools-next]$ patch -p1 < b
> > > patching file tools/perf/tests/perf-record.c
> > > Hunk #1 succeeded at 130 (offset 15 lines).
> > > Hunk #2 succeeded at 142 with fuzz 1 (offset 15 lines).
> > > Hunk #3 succeeded at 154 (offset 15 lines).
> > > Hunk #4 succeeded at 167 (offset 15 lines).
> > > ⬢ [acme@toolbx perf-tools-next]$
> > > ⬢ [acme@toolbx perf-tools-next]$ git log --oneline -5 tools/perf/tests/perf-record.c
> > > 576bd7a8c90c48e9 (x1/perf-tools-next, x1/HEAD, five/perf-tools-next, five/HEAD) perf tests record: Update testcase to fix usage of affinity for machines with #CPUs > 1K
> > > b4c658d4d63d6149 perf target: Remove uid from target
> > > dc6d2bc2d893a878 perf sample: Make user_regs and intr_regs optional
> > > fd8d5a3b076c033f perf tests: Add missing event.h include
> > > 9823147da6c893d9 perf tools: Move 'struct perf_sample' to a separate header file to disentangle headers
> > > ⬢ [acme@toolbx perf-tools-next]$
>
> > > Can you please check that it is still ok?
>
> > > I processed the first in the series and now I'm going thru the other
> > > two.
>
> > Thanks Arnaldo! I'm not seeing the patch on:
> > https://web.git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/log/?h=tmp.perf-tools-next
>
> Sorry, I thought I had pushed it earlier, should be there now.
>
> > I'm happy to check.
>
> Thanks!

Not seeing it, but I see the first patch. In any case I'll rebase and
send as a v2.

Thanks,
Ian

> - Arnaldo

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

end of thread, other threads:[~2025-09-18 22:17 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-21 22:18 [PATCH v1 0/4] Test/uniquification related fixes Ian Rogers
2025-08-21 22:18 ` [PATCH v1 1/4] perf test shell lbr: Avoid failures with perf event paranoia Ian Rogers
2025-09-16 19:00   ` Arnaldo Carvalho de Melo
2025-08-21 22:18 ` [PATCH v1 2/4] perf test: Don't leak workload gopipe in PERF_RECORD_* Ian Rogers
2025-09-16 19:04   ` Arnaldo Carvalho de Melo
2025-09-16 19:08     ` Ian Rogers
2025-09-17  1:06       ` Arnaldo Carvalho de Melo
2025-09-18 22:17         ` Ian Rogers
2025-08-21 22:18 ` [PATCH v1 3/4] perf evsel: Fix uniquification when PMU given without suffix Ian Rogers
2025-08-21 22:18 ` [PATCH v1 4/4] perf test: Avoid uncore_imc/clockticks in uniquification test Ian Rogers
2025-09-16 19:15   ` Arnaldo Carvalho de Melo
2025-09-16 20:45     ` Ian Rogers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).