* [PATCH v2 0/6] perf test: Small improvements
@ 2025-03-04 2:28 Namhyung Kim
2025-03-04 2:28 ` [PATCH v2 1/6] perf test: Add --metric-only to perf stat output tests Namhyung Kim
` (7 more replies)
0 siblings, 8 replies; 13+ messages in thread
From: Namhyung Kim @ 2025-03-04 2:28 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo, Ian Rogers, Kan Liang
Cc: Jiri Olsa, Adrian Hunter, Peter Zijlstra, Ingo Molnar, LKML,
linux-perf-users
Hello,
This is an assorted list of changes in the perf test.
I've added perf stat --metric-only test and perf trace record and replay.
And other changes to skip privileged tests for non-root and simplify
data symbol test.
v2 changes)
* fix shellcheck errors
* simplify datasym test with timeout
Thanks,
Namhyung
Namhyung Kim (6):
perf test: Add --metric-only to perf stat output tests
perf test: Skip perf probe tests when running as non-root
perf test: Skip perf trace tests when running as non-root
perf test: Add trace record and replay test
perf test: Add timeout to datasym workload
perf test: Simplify data symbol test
.../tests/shell/lib/perf_json_output_lint.py | 7 ++++++
tools/perf/tests/shell/lib/stat_output.sh | 8 +++++++
.../tests/shell/perftool-testsuite_probe.sh | 1 +
tools/perf/tests/shell/probe_vfs_getname.sh | 1 +
.../shell/record+probe_libc_inet_pton.sh | 1 +
.../shell/record+script_probe_vfs_getname.sh | 1 +
tools/perf/tests/shell/stat+csv_output.sh | 2 ++
tools/perf/tests/shell/stat+json_output.sh | 9 ++++++++
tools/perf/tests/shell/stat+std_output.sh | 8 +++++++
tools/perf/tests/shell/test_data_symbol.sh | 15 ++----------
.../shell/test_uprobe_from_different_cu.sh | 11 ++++-----
.../tests/shell/trace+probe_vfs_getname.sh | 1 +
tools/perf/tests/shell/trace_btf_enum.sh | 1 +
tools/perf/tests/shell/trace_btf_general.sh | 1 +
tools/perf/tests/shell/trace_exit_race.sh | 1 +
tools/perf/tests/shell/trace_record_replay.sh | 21 +++++++++++++++++
tools/perf/tests/workloads/datasym.c | 23 +++++++++++++++++--
17 files changed, 91 insertions(+), 21 deletions(-)
create mode 100755 tools/perf/tests/shell/trace_record_replay.sh
--
2.48.1.711.g2feabab25a-goog
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v2 1/6] perf test: Add --metric-only to perf stat output tests
2025-03-04 2:28 [PATCH v2 0/6] perf test: Small improvements Namhyung Kim
@ 2025-03-04 2:28 ` Namhyung Kim
2025-03-04 2:28 ` [PATCH v2 2/6] perf test: Skip perf probe tests when running as non-root Namhyung Kim
` (6 subsequent siblings)
7 siblings, 0 replies; 13+ messages in thread
From: Namhyung Kim @ 2025-03-04 2:28 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo, Ian Rogers, Kan Liang
Cc: Jiri Olsa, Adrian Hunter, Peter Zijlstra, Ingo Molnar, LKML,
linux-perf-users
Add a test case for --metric-only for std, csv, json output mode using
shadow IPC metric from instructions and cycles events. It should
produce 'insn per cycle' metric.
But currently JSON output has (none) 'GHz' as well. It looks like a bug
but I don't have enough time to debug it for now so I made it pass. :(
$ perf stat --metric-only -e instructions,cycles true
Performance counter stats for 'true':
0.56
0.002127319 seconds time elapsed
0.002077000 seconds user
0.000000000 seconds sys
$ perf stat -x, --metric-only -e instructions,cycles true
0.55,,
$ perf stat -j --metric-only -e instructions,cycles true
{"insn per cycle" : "0.53", "GHz" : "none"}
$ perf test output -v
5: Test data source output : Ok
31: Sort output of hist entries : Ok
88: perf stat CSV output linter : Ok
90: perf stat JSON output linter : Ok
92: perf stat STD output linter : Ok
Suggested-by: Ian Rogers <irogers@google.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/tests/shell/lib/perf_json_output_lint.py | 7 +++++++
tools/perf/tests/shell/lib/stat_output.sh | 8 ++++++++
tools/perf/tests/shell/stat+csv_output.sh | 2 ++
tools/perf/tests/shell/stat+json_output.sh | 9 +++++++++
tools/perf/tests/shell/stat+std_output.sh | 8 ++++++++
5 files changed, 34 insertions(+)
diff --git a/tools/perf/tests/shell/lib/perf_json_output_lint.py b/tools/perf/tests/shell/lib/perf_json_output_lint.py
index b066d721f89735df..9e772a89ce381636 100644
--- a/tools/perf/tests/shell/lib/perf_json_output_lint.py
+++ b/tools/perf/tests/shell/lib/perf_json_output_lint.py
@@ -19,6 +19,7 @@ ap.add_argument('--per-cluster', action='store_true')
ap.add_argument('--per-die', action='store_true')
ap.add_argument('--per-node', action='store_true')
ap.add_argument('--per-socket', action='store_true')
+ap.add_argument('--metric-only', action='store_true')
ap.add_argument('--file', type=argparse.FileType('r'), default=sys.stdin)
args = ap.parse_args()
@@ -64,6 +65,8 @@ Lines = args.file.readlines()
'socket': lambda x: True,
'thread': lambda x: True,
'unit': lambda x: True,
+ 'insn per cycle': lambda x: isfloat(x),
+ 'GHz': lambda x: True, # FIXME: it seems unintended for --metric-only
}
input = '[\n' + ','.join(Lines) + '\n]'
for item in json.loads(input):
@@ -78,6 +81,8 @@ Lines = args.file.readlines()
pass
elif count - 1 in expected_items and 'metric-threshold' in item:
pass
+ elif count in expected_items and 'insn per cycle' in item:
+ pass
elif count not in expected_items:
raise RuntimeError(f'wrong number of fields. counted {count} expected {expected_items}'
f' in \'{item}\'')
@@ -95,6 +100,8 @@ Lines = args.file.readlines()
expected_items = [6, 8]
elif args.per_core or args.per_socket or args.per_node or args.per_die or args.per_cluster or args.per_cache:
expected_items = [7, 9]
+ elif args.metric_only:
+ expected_items = [1, 2]
else:
# If no option is specified, don't check the number of items.
expected_items = -1
diff --git a/tools/perf/tests/shell/lib/stat_output.sh b/tools/perf/tests/shell/lib/stat_output.sh
index 9a176ceae4a3c3a2..4d4aac547f0109d1 100644
--- a/tools/perf/tests/shell/lib/stat_output.sh
+++ b/tools/perf/tests/shell/lib/stat_output.sh
@@ -148,6 +148,14 @@ check_per_socket()
echo "[Success]"
}
+check_metric_only()
+{
+ echo -n "Checking $1 output: metric only "
+ perf stat --metric-only $2 -e instructions,cycles true
+ commachecker --metric-only
+ echo "[Success]"
+}
+
# The perf stat options for per-socket, per-core, per-die
# and -A ( no_aggr mode ) uses the info fetched from this
# directory: "/sys/devices/system/cpu/cpu*/topology". For
diff --git a/tools/perf/tests/shell/stat+csv_output.sh b/tools/perf/tests/shell/stat+csv_output.sh
index fc2d8cc6e5e0b1e5..7a6f6e1774028322 100755
--- a/tools/perf/tests/shell/stat+csv_output.sh
+++ b/tools/perf/tests/shell/stat+csv_output.sh
@@ -44,6 +44,7 @@ function commachecker()
;; "--per-die") exp=8
;; "--per-cluster") exp=8
;; "--per-cache") exp=8
+ ;; "--metric-only") exp=2
esac
while read line
@@ -75,6 +76,7 @@ check_interval "CSV" "$perf_cmd"
check_event "CSV" "$perf_cmd"
check_per_thread "CSV" "$perf_cmd"
check_per_node "CSV" "$perf_cmd"
+check_metric_only "CSV" "$perf_cmd"
if [ $skip_test -ne 1 ]
then
check_system_wide_no_aggr "CSV" "$perf_cmd"
diff --git a/tools/perf/tests/shell/stat+json_output.sh b/tools/perf/tests/shell/stat+json_output.sh
index 6b630d33c3287899..a4f257ea839e1368 100755
--- a/tools/perf/tests/shell/stat+json_output.sh
+++ b/tools/perf/tests/shell/stat+json_output.sh
@@ -173,6 +173,14 @@ check_per_socket()
echo "[Success]"
}
+check_metric_only()
+{
+ echo -n "Checking json output: metric only "
+ perf stat -j --metric-only -e instructions,cycles -o "${stat_output}" true
+ $PYTHON $pythonchecker --metric-only --file "${stat_output}"
+ echo "[Success]"
+}
+
# The perf stat options for per-socket, per-core, per-die
# and -A ( no_aggr mode ) uses the info fetched from this
# directory: "/sys/devices/system/cpu/cpu*/topology". For
@@ -207,6 +215,7 @@ check_interval
check_event
check_per_thread
check_per_node
+check_metric_only
if [ $skip_test -ne 1 ]
then
check_system_wide_no_aggr
diff --git a/tools/perf/tests/shell/stat+std_output.sh b/tools/perf/tests/shell/stat+std_output.sh
index 0f7967be60afdc7d..6fee67693ba7a9be 100755
--- a/tools/perf/tests/shell/stat+std_output.sh
+++ b/tools/perf/tests/shell/stat+std_output.sh
@@ -30,6 +30,7 @@ trap trap_cleanup EXIT TERM INT
function commachecker()
{
local prefix=1
+ local -i metric_only=0
case "$1"
in "--interval") prefix=2
@@ -41,6 +42,7 @@ function commachecker()
;; "--per-die") prefix=3
;; "--per-cache") prefix=3
;; "--per-cluster") prefix=3
+ ;; "--metric-only") metric_only=1
esac
while read line
@@ -60,6 +62,9 @@ function commachecker()
x=${main_body%#*}
[ "$x" = "" ] && continue
+ # Check metric only - if it has a non-empty result
+ [ $metric_only -eq 1 ] && return 0
+
# Skip metrics without event name
y=${main_body#*#}
for i in "${!skip_metric[@]}"; do
@@ -84,6 +89,8 @@ function commachecker()
exit 1;
}
done < "${stat_output}"
+
+ [ $metric_only -eq 1 ] && exit 1
return 0
}
@@ -95,6 +102,7 @@ check_system_wide "STD" "$perf_cmd"
check_interval "STD" "$perf_cmd"
check_per_thread "STD" "$perf_cmd"
check_per_node "STD" "$perf_cmd"
+check_metric_only "STD" "$perf_cmd"
if [ $skip_test -ne 1 ]
then
check_system_wide_no_aggr "STD" "$perf_cmd"
--
2.48.1.711.g2feabab25a-goog
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 2/6] perf test: Skip perf probe tests when running as non-root
2025-03-04 2:28 [PATCH v2 0/6] perf test: Small improvements Namhyung Kim
2025-03-04 2:28 ` [PATCH v2 1/6] perf test: Add --metric-only to perf stat output tests Namhyung Kim
@ 2025-03-04 2:28 ` Namhyung Kim
2025-03-04 2:28 ` [PATCH v2 3/6] perf test: Skip perf trace " Namhyung Kim
` (5 subsequent siblings)
7 siblings, 0 replies; 13+ messages in thread
From: Namhyung Kim @ 2025-03-04 2:28 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo, Ian Rogers, Kan Liang
Cc: Jiri Olsa, Adrian Hunter, Peter Zijlstra, Ingo Molnar, LKML,
linux-perf-users, Masami Hiramatsu
perf trace requires root because it needs to use [ku]probes.
Skip those test when it's not run as root.
Before:
$ perf test probe
47: Probe SDT events : Ok
104: test perf probe of function from different CU : FAILED!
115: perftool-testsuite_probe : FAILED!
117: Add vfs_getname probe to get syscall args filenames : FAILED!
118: probe libc's inet_pton & backtrace it with ping : FAILED!
119: Use vfs_getname probe to get syscall args filenames : FAILED!
After:
$ perf test probe
47: Probe SDT events : Ok
104: test perf probe of function from different CU : Skip
115: perftool-testsuite_probe : Skip
117: Add vfs_getname probe to get syscall args filenames : Skip
118: probe libc's inet_pton & backtrace it with ping : Skip
119: Use vfs_getname probe to get syscall args filenames : Skip
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/tests/shell/perftool-testsuite_probe.sh | 1 +
tools/perf/tests/shell/probe_vfs_getname.sh | 1 +
tools/perf/tests/shell/record+probe_libc_inet_pton.sh | 1 +
.../tests/shell/record+script_probe_vfs_getname.sh | 1 +
.../perf/tests/shell/test_uprobe_from_different_cu.sh | 11 +++++------
5 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/tools/perf/tests/shell/perftool-testsuite_probe.sh b/tools/perf/tests/shell/perftool-testsuite_probe.sh
index 7b1bfd0f888fc30c..3863df16c19b9fa2 100755
--- a/tools/perf/tests/shell/perftool-testsuite_probe.sh
+++ b/tools/perf/tests/shell/perftool-testsuite_probe.sh
@@ -2,6 +2,7 @@
# perftool-testsuite_probe (exclusive)
# SPDX-License-Identifier: GPL-2.0
+[ "$(id -u)" = 0 ] || exit 2
test -d "$(dirname "$0")/base_probe" || exit 2
cd "$(dirname "$0")/base_probe" || exit 2
status=0
diff --git a/tools/perf/tests/shell/probe_vfs_getname.sh b/tools/perf/tests/shell/probe_vfs_getname.sh
index 0c5aacc446b3ef76..c51a32931af6313e 100755
--- a/tools/perf/tests/shell/probe_vfs_getname.sh
+++ b/tools/perf/tests/shell/probe_vfs_getname.sh
@@ -8,6 +8,7 @@
. "$(dirname $0)"/lib/probe.sh
skip_if_no_perf_probe || exit 2
+[ "$(id -u)" = 0 ] || exit 2
# shellcheck source=lib/probe_vfs_getname.sh
. "$(dirname $0)"/lib/probe_vfs_getname.sh
diff --git a/tools/perf/tests/shell/record+probe_libc_inet_pton.sh b/tools/perf/tests/shell/record+probe_libc_inet_pton.sh
index d5e5193cceb625fd..c4bab5b5cc59f0b3 100755
--- a/tools/perf/tests/shell/record+probe_libc_inet_pton.sh
+++ b/tools/perf/tests/shell/record+probe_libc_inet_pton.sh
@@ -105,6 +105,7 @@ delete_libc_inet_pton_event() {
# Check for IPv6 interface existence
ip a sh lo | grep -F -q inet6 || exit 2
+[ "$(id -u)" = 0 ] || exit 2
skip_if_no_perf_probe && \
add_libc_inet_pton_event && \
diff --git a/tools/perf/tests/shell/record+script_probe_vfs_getname.sh b/tools/perf/tests/shell/record+script_probe_vfs_getname.sh
index 5940fdc1df37c502..fd5b10d469158b65 100755
--- a/tools/perf/tests/shell/record+script_probe_vfs_getname.sh
+++ b/tools/perf/tests/shell/record+script_probe_vfs_getname.sh
@@ -13,6 +13,7 @@
. "$(dirname "$0")/lib/probe.sh"
skip_if_no_perf_probe || exit 2
+[ "$(id -u)" = 0 ] || exit 2
# shellcheck source=lib/probe_vfs_getname.sh
. "$(dirname "$0")/lib/probe_vfs_getname.sh"
diff --git a/tools/perf/tests/shell/test_uprobe_from_different_cu.sh b/tools/perf/tests/shell/test_uprobe_from_different_cu.sh
index 33387c329f92b6ed..7adf9755d6de240e 100755
--- a/tools/perf/tests/shell/test_uprobe_from_different_cu.sh
+++ b/tools/perf/tests/shell/test_uprobe_from_different_cu.sh
@@ -4,12 +4,11 @@
set -e
-# Skip if there's no probe command.
-if ! perf | grep probe
-then
- echo "Skip: probe command isn't present"
- exit 2
-fi
+# shellcheck source=lib/probe.sh
+. "$(dirname $0)"/lib/probe.sh
+
+skip_if_no_perf_probe || exit 2
+[ "$(id -u)" == 0 ] || exit 2
# skip if there's no gcc
if ! [ -x "$(command -v gcc)" ]; then
--
2.48.1.711.g2feabab25a-goog
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 3/6] perf test: Skip perf trace tests when running as non-root
2025-03-04 2:28 [PATCH v2 0/6] perf test: Small improvements Namhyung Kim
2025-03-04 2:28 ` [PATCH v2 1/6] perf test: Add --metric-only to perf stat output tests Namhyung Kim
2025-03-04 2:28 ` [PATCH v2 2/6] perf test: Skip perf probe tests when running as non-root Namhyung Kim
@ 2025-03-04 2:28 ` Namhyung Kim
2025-03-04 2:28 ` [PATCH v2 4/6] perf test: Add trace record and replay test Namhyung Kim
` (4 subsequent siblings)
7 siblings, 0 replies; 13+ messages in thread
From: Namhyung Kim @ 2025-03-04 2:28 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo, Ian Rogers, Kan Liang
Cc: Jiri Olsa, Adrian Hunter, Peter Zijlstra, Ingo Molnar, LKML,
linux-perf-users, Howard Chu
perf trace requires root because it needs to use tracepoints and BPF.
Skip those test when it's not run as root.
Before:
$ perf test trace
15: Parse sched tracepoints fields : Skip (permissions)
80: perf ftrace tests : Skip
105: perf trace enum augmentation tests : FAILED!
106: perf trace BTF general tests : FAILED!
107: perf trace exit race : FAILED!
118: probe libc's inet_pton & backtrace it with ping : Skip
125: Check Arm CoreSight trace data recording and synthesized samples: Skip
127: Check Arm SPE trace data recording and synthesized samples : Skip
132: Check open filename arg using perf trace + vfs_getname : FAILED!
After:
$ perf test trace
15: Parse sched tracepoints fields : Skip (permissions)
80: perf ftrace tests : Skip
105: perf trace enum augmentation tests : Skip
106: perf trace BTF general tests : Skip
107: perf trace exit race : Skip
118: probe libc's inet_pton & backtrace it with ping : Skip
125: Check Arm CoreSight trace data recording and synthesized samples: Skip
127: Check Arm SPE trace data recording and synthesized samples : Skip
132: Check open filename arg using perf trace + vfs_getname : Skip
Cc: Howard Chu <howardchu95@gmail.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/tests/shell/trace+probe_vfs_getname.sh | 1 +
tools/perf/tests/shell/trace_btf_enum.sh | 1 +
tools/perf/tests/shell/trace_btf_general.sh | 1 +
tools/perf/tests/shell/trace_exit_race.sh | 1 +
4 files changed, 4 insertions(+)
diff --git a/tools/perf/tests/shell/trace+probe_vfs_getname.sh b/tools/perf/tests/shell/trace+probe_vfs_getname.sh
index 708a13f006353611..60fccb62c5403ee9 100755
--- a/tools/perf/tests/shell/trace+probe_vfs_getname.sh
+++ b/tools/perf/tests/shell/trace+probe_vfs_getname.sh
@@ -15,6 +15,7 @@
skip_if_no_perf_probe || exit 2
skip_if_no_perf_trace || exit 2
+[ "$(id -u)" = 0 ] || exit 2
. "$(dirname $0)"/lib/probe_vfs_getname.sh
diff --git a/tools/perf/tests/shell/trace_btf_enum.sh b/tools/perf/tests/shell/trace_btf_enum.sh
index 8d1e6bbeac906843..60b3fa254cf6c7bc 100755
--- a/tools/perf/tests/shell/trace_btf_enum.sh
+++ b/tools/perf/tests/shell/trace_btf_enum.sh
@@ -13,6 +13,7 @@ TESTPROG="perf test -w landlock"
# shellcheck source=lib/probe.sh
. "$(dirname $0)"/lib/probe.sh
skip_if_no_perf_trace || exit 2
+[ "$(id -u)" = 0 ] || exit 2
check_vmlinux() {
echo "Checking if vmlinux exists"
diff --git a/tools/perf/tests/shell/trace_btf_general.sh b/tools/perf/tests/shell/trace_btf_general.sh
index e9ee727f3433eaba..a25d8744695e6fef 100755
--- a/tools/perf/tests/shell/trace_btf_general.sh
+++ b/tools/perf/tests/shell/trace_btf_general.sh
@@ -76,6 +76,7 @@ trace_config() {
skip_if_no_perf_trace || exit 2
check_vmlinux || exit 2
+[ "$(id -u)" = 0 ] || exit 2
trace_config
diff --git a/tools/perf/tests/shell/trace_exit_race.sh b/tools/perf/tests/shell/trace_exit_race.sh
index fbb0adc33a889516..1e247693e756d439 100755
--- a/tools/perf/tests/shell/trace_exit_race.sh
+++ b/tools/perf/tests/shell/trace_exit_race.sh
@@ -10,6 +10,7 @@
. "$(dirname $0)"/lib/probe.sh
skip_if_no_perf_trace || exit 2
+[ "$(id -u)" = 0 ] || exit 2
if [ "$1" = "-v" ]; then
verbose="1"
--
2.48.1.711.g2feabab25a-goog
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 4/6] perf test: Add trace record and replay test
2025-03-04 2:28 [PATCH v2 0/6] perf test: Small improvements Namhyung Kim
` (2 preceding siblings ...)
2025-03-04 2:28 ` [PATCH v2 3/6] perf test: Skip perf trace " Namhyung Kim
@ 2025-03-04 2:28 ` Namhyung Kim
2025-03-04 2:28 ` [PATCH v2 5/6] perf test: Add timeout to datasym workload Namhyung Kim
` (3 subsequent siblings)
7 siblings, 0 replies; 13+ messages in thread
From: Namhyung Kim @ 2025-03-04 2:28 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo, Ian Rogers, Kan Liang
Cc: Jiri Olsa, Adrian Hunter, Peter Zijlstra, Ingo Molnar, LKML,
linux-perf-users, Howard Chu
It just check trace record and replay could display correct output.
It uses 'sleep' process and sees there's a clock_nanosleep syscall.
$ sudo perf test -vv replay
108: perf trace record and replay:
--- start ---
test child forked, pid 1563219
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.077 MB /tmp/temporary_file.w1ApA (242 samples) ]
0.686 (1000.068 ms): sleep/1563226 clock_nanosleep(rqtp: 0x7ffc20ffee10, rmtp: 0x7ffc20ffee50) = 0
---- end(0) ----
108: perf trace record and replay : Ok
Cc: Howard Chu <howardchu95@gmail.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/tests/shell/trace_record_replay.sh | 21 +++++++++++++++++++
1 file changed, 21 insertions(+)
create mode 100755 tools/perf/tests/shell/trace_record_replay.sh
diff --git a/tools/perf/tests/shell/trace_record_replay.sh b/tools/perf/tests/shell/trace_record_replay.sh
new file mode 100755
index 0000000000000000..6b4ed863c1ef8679
--- /dev/null
+++ b/tools/perf/tests/shell/trace_record_replay.sh
@@ -0,0 +1,21 @@
+#!/bin/sh
+# perf trace record and replay
+# SPDX-License-Identifier: GPL-2.0
+
+# Check that perf trace works with record and replay
+
+# shellcheck source=lib/probe.sh
+. "$(dirname $0)"/lib/probe.sh
+
+skip_if_no_perf_trace || exit 2
+[ "$(id -u)" = 0 ] || exit 2
+
+file=$(mktemp /tmp/temporary_file.XXXXX)
+
+perf trace record -o ${file} sleep 1 || exit 1
+if ! perf trace -i ${file} 2>&1 | grep nanosleep; then
+ echo "Failed: cannot find *nanosleep syscall"
+ exit 1
+fi
+
+rm -f ${file}
--
2.48.1.711.g2feabab25a-goog
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 5/6] perf test: Add timeout to datasym workload
2025-03-04 2:28 [PATCH v2 0/6] perf test: Small improvements Namhyung Kim
` (3 preceding siblings ...)
2025-03-04 2:28 ` [PATCH v2 4/6] perf test: Add trace record and replay test Namhyung Kim
@ 2025-03-04 2:28 ` Namhyung Kim
2025-03-04 7:37 ` Thomas Richter
2025-03-04 15:16 ` Leo Yan
2025-03-04 2:28 ` [PATCH v2 6/6] perf test: Simplify data symbol test Namhyung Kim
` (2 subsequent siblings)
7 siblings, 2 replies; 13+ messages in thread
From: Namhyung Kim @ 2025-03-04 2:28 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo, Ian Rogers, Kan Liang
Cc: Jiri Olsa, Adrian Hunter, Peter Zijlstra, Ingo Molnar, LKML,
linux-perf-users, Thomas Richter, Leo Yan
Unlike others it has an infinite loop that make it annoying to call.
Make it finish after 1 second and handle command-line argument to change
the setting.
Cc: Thomas Richter <tmricht@linux.ibm.com>
Cc: Leo Yan <leo.yan@arm.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/tests/workloads/datasym.c | 23 +++++++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)
diff --git a/tools/perf/tests/workloads/datasym.c b/tools/perf/tests/workloads/datasym.c
index 8e08fc75a973e5f7..8ddb2aa6a049e343 100644
--- a/tools/perf/tests/workloads/datasym.c
+++ b/tools/perf/tests/workloads/datasym.c
@@ -1,3 +1,6 @@
+#include <stdlib.h>
+#include <signal.h>
+#include <unistd.h>
#include <linux/compiler.h>
#include "../tests.h"
@@ -12,9 +15,25 @@ static buf buf1 = {
.reserved[0] = 1,
};
-static int datasym(int argc __maybe_unused, const char **argv __maybe_unused)
+static volatile sig_atomic_t done;
+
+static void sighandler(int sig __maybe_unused)
+{
+ done = 1;
+}
+
+static int datasym(int argc, const char **argv)
{
- for (;;) {
+ int sec = 1;
+
+ if (argc > 0)
+ sec = atoi(argv[0]);
+
+ signal(SIGINT, sighandler);
+ signal(SIGALRM, sighandler);
+ alarm(sec);
+
+ while (!done) {
buf1.data1++;
if (buf1.data1 == 123) {
/*
--
2.48.1.711.g2feabab25a-goog
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 6/6] perf test: Simplify data symbol test
2025-03-04 2:28 [PATCH v2 0/6] perf test: Small improvements Namhyung Kim
` (4 preceding siblings ...)
2025-03-04 2:28 ` [PATCH v2 5/6] perf test: Add timeout to datasym workload Namhyung Kim
@ 2025-03-04 2:28 ` Namhyung Kim
2025-03-04 7:38 ` Thomas Richter
2025-03-04 15:15 ` Leo Yan
2025-03-04 16:17 ` [PATCH v2 0/6] perf test: Small improvements Falcon, Thomas
2025-03-06 17:14 ` Namhyung Kim
7 siblings, 2 replies; 13+ messages in thread
From: Namhyung Kim @ 2025-03-04 2:28 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo, Ian Rogers, Kan Liang
Cc: Jiri Olsa, Adrian Hunter, Peter Zijlstra, Ingo Molnar, LKML,
linux-perf-users, Thomas Richter, Leo Yan
Now the workload will end after 1 second. Just run it with perf instead
of waiting for the background process.
Cc: Thomas Richter <tmricht@linux.ibm.com>
Cc: Leo Yan <leo.yan@arm.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/tests/shell/test_data_symbol.sh | 15 ++-------------
1 file changed, 2 insertions(+), 13 deletions(-)
diff --git a/tools/perf/tests/shell/test_data_symbol.sh b/tools/perf/tests/shell/test_data_symbol.sh
index c86da02350596b35..1792b7ad4066f8cd 100755
--- a/tools/perf/tests/shell/test_data_symbol.sh
+++ b/tools/perf/tests/shell/test_data_symbol.sh
@@ -5,8 +5,6 @@
# Leo Yan <leo.yan@linaro.org>, 2022
shelldir=$(dirname "$0")
-# shellcheck source=lib/waiting.sh
-. "${shelldir}"/lib/waiting.sh
# shellcheck source=lib/perf_has_symbol.sh
. "${shelldir}"/lib/perf_has_symbol.sh
@@ -60,19 +58,10 @@ echo "Recording workload..."
# specific CPU and test in per-CPU mode.
is_amd=$(grep -E -c 'vendor_id.*AuthenticAMD' /proc/cpuinfo)
if (($is_amd >= 1)); then
- perf mem record -vvv -o ${PERF_DATA} -C 0 -- taskset -c 0 $TEST_PROGRAM 2>"${ERR_FILE}" &
+ perf mem record -vvv -o ${PERF_DATA} -C 0 -- taskset -c 0 $TEST_PROGRAM 2>"${ERR_FILE}"
else
- perf mem record -vvv --all-user -o ${PERF_DATA} -- $TEST_PROGRAM 2>"${ERR_FILE}" &
+ perf mem record -vvv --all-user -o ${PERF_DATA} -- $TEST_PROGRAM 2>"${ERR_FILE}"
fi
-PERFPID=$!
-
-wait_for_perf_to_start ${PERFPID} "${ERR_FILE}"
-
-sleep 1
-
-kill $PERFPID
-wait $PERFPID
-
check_result
exit $?
--
2.48.1.711.g2feabab25a-goog
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH v2 5/6] perf test: Add timeout to datasym workload
2025-03-04 2:28 ` [PATCH v2 5/6] perf test: Add timeout to datasym workload Namhyung Kim
@ 2025-03-04 7:37 ` Thomas Richter
2025-03-04 15:16 ` Leo Yan
1 sibling, 0 replies; 13+ messages in thread
From: Thomas Richter @ 2025-03-04 7:37 UTC (permalink / raw)
To: Namhyung Kim, Arnaldo Carvalho de Melo, Ian Rogers, Kan Liang
Cc: Jiri Olsa, Adrian Hunter, Peter Zijlstra, Ingo Molnar, LKML,
linux-perf-users, Leo Yan
On 3/4/25 03:28, Namhyung Kim wrote:
> Unlike others it has an infinite loop that make it annoying to call.
> Make it finish after 1 second and handle command-line argument to change
> the setting.
>
> Cc: Thomas Richter <tmricht@linux.ibm.com>
> Cc: Leo Yan <leo.yan@arm.com>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> ---
> tools/perf/tests/workloads/datasym.c | 23 +++++++++++++++++++++--
> 1 file changed, 21 insertions(+), 2 deletions(-)
>
> diff --git a/tools/perf/tests/workloads/datasym.c b/tools/perf/tests/workloads/datasym.c
> index 8e08fc75a973e5f7..8ddb2aa6a049e343 100644
> --- a/tools/perf/tests/workloads/datasym.c
> +++ b/tools/perf/tests/workloads/datasym.c
> @@ -1,3 +1,6 @@
> +#include <stdlib.h>
> +#include <signal.h>
> +#include <unistd.h>
> #include <linux/compiler.h>
> #include "../tests.h"
>
> @@ -12,9 +15,25 @@ static buf buf1 = {
> .reserved[0] = 1,
> };
>
> -static int datasym(int argc __maybe_unused, const char **argv __maybe_unused)
> +static volatile sig_atomic_t done;
> +
> +static void sighandler(int sig __maybe_unused)
> +{
> + done = 1;
> +}
> +
> +static int datasym(int argc, const char **argv)
> {
> - for (;;) {
> + int sec = 1;
> +
> + if (argc > 0)
> + sec = atoi(argv[0]);
> +
> + signal(SIGINT, sighandler);
> + signal(SIGALRM, sighandler);
> + alarm(sec);
> +
> + while (!done) {
> buf1.data1++;
> if (buf1.data1 == 123) {
> /*
Tested-by: Thomas Richter <tmricht@linux.ibm.com>
--
Thomas Richter, Dept 3303, IBM s390 Linux Development, Boeblingen, Germany
--
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Wolfgang Wendt
Geschäftsführung: David Faller
Sitz der Gesellschaft: Böblingen / Registergericht: Amtsgericht Stuttgart, HRB 243294
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 6/6] perf test: Simplify data symbol test
2025-03-04 2:28 ` [PATCH v2 6/6] perf test: Simplify data symbol test Namhyung Kim
@ 2025-03-04 7:38 ` Thomas Richter
2025-03-04 15:15 ` Leo Yan
1 sibling, 0 replies; 13+ messages in thread
From: Thomas Richter @ 2025-03-04 7:38 UTC (permalink / raw)
To: Namhyung Kim, Arnaldo Carvalho de Melo, Ian Rogers, Kan Liang
Cc: Jiri Olsa, Adrian Hunter, Peter Zijlstra, Ingo Molnar, LKML,
linux-perf-users, Leo Yan
On 3/4/25 03:28, Namhyung Kim wrote:
> Now the workload will end after 1 second. Just run it with perf instead
> of waiting for the background process.
>
> Cc: Thomas Richter <tmricht@linux.ibm.com>
> Cc: Leo Yan <leo.yan@arm.com>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> ---
> tools/perf/tests/shell/test_data_symbol.sh | 15 ++-------------
> 1 file changed, 2 insertions(+), 13 deletions(-)
>
> diff --git a/tools/perf/tests/shell/test_data_symbol.sh b/tools/perf/tests/shell/test_data_symbol.sh
> index c86da02350596b35..1792b7ad4066f8cd 100755
> --- a/tools/perf/tests/shell/test_data_symbol.sh
> +++ b/tools/perf/tests/shell/test_data_symbol.sh
> @@ -5,8 +5,6 @@
> # Leo Yan <leo.yan@linaro.org>, 2022
>
> shelldir=$(dirname "$0")
> -# shellcheck source=lib/waiting.sh
> -. "${shelldir}"/lib/waiting.sh
>
> # shellcheck source=lib/perf_has_symbol.sh
> . "${shelldir}"/lib/perf_has_symbol.sh
> @@ -60,19 +58,10 @@ echo "Recording workload..."
> # specific CPU and test in per-CPU mode.
> is_amd=$(grep -E -c 'vendor_id.*AuthenticAMD' /proc/cpuinfo)
> if (($is_amd >= 1)); then
> - perf mem record -vvv -o ${PERF_DATA} -C 0 -- taskset -c 0 $TEST_PROGRAM 2>"${ERR_FILE}" &
> + perf mem record -vvv -o ${PERF_DATA} -C 0 -- taskset -c 0 $TEST_PROGRAM 2>"${ERR_FILE}"
> else
> - perf mem record -vvv --all-user -o ${PERF_DATA} -- $TEST_PROGRAM 2>"${ERR_FILE}" &
> + perf mem record -vvv --all-user -o ${PERF_DATA} -- $TEST_PROGRAM 2>"${ERR_FILE}"
> fi
>
> -PERFPID=$!
> -
> -wait_for_perf_to_start ${PERFPID} "${ERR_FILE}"
> -
> -sleep 1
> -
> -kill $PERFPID
> -wait $PERFPID
> -
> check_result
> exit $?
Tested-by: Thomas Richter <tmricht@linux.ibm.com>
--
Thomas Richter, Dept 3303, IBM s390 Linux Development, Boeblingen, Germany
--
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Wolfgang Wendt
Geschäftsführung: David Faller
Sitz der Gesellschaft: Böblingen / Registergericht: Amtsgericht Stuttgart, HRB 243294
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 6/6] perf test: Simplify data symbol test
2025-03-04 2:28 ` [PATCH v2 6/6] perf test: Simplify data symbol test Namhyung Kim
2025-03-04 7:38 ` Thomas Richter
@ 2025-03-04 15:15 ` Leo Yan
1 sibling, 0 replies; 13+ messages in thread
From: Leo Yan @ 2025-03-04 15:15 UTC (permalink / raw)
To: Namhyung Kim
Cc: Arnaldo Carvalho de Melo, Ian Rogers, Kan Liang, Jiri Olsa,
Adrian Hunter, Peter Zijlstra, Ingo Molnar, LKML,
linux-perf-users, Thomas Richter
On Mon, Mar 03, 2025 at 06:28:37PM -0800, Namhyung Kim wrote:
> Now the workload will end after 1 second. Just run it with perf instead
> of waiting for the background process.
>
> Cc: Thomas Richter <tmricht@linux.ibm.com>
> Cc: Leo Yan <leo.yan@arm.com>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Reviewed-by: Leo Yan <leo.yan@arm.com>
> ---
> tools/perf/tests/shell/test_data_symbol.sh | 15 ++-------------
> 1 file changed, 2 insertions(+), 13 deletions(-)
>
> diff --git a/tools/perf/tests/shell/test_data_symbol.sh b/tools/perf/tests/shell/test_data_symbol.sh
> index c86da02350596b35..1792b7ad4066f8cd 100755
> --- a/tools/perf/tests/shell/test_data_symbol.sh
> +++ b/tools/perf/tests/shell/test_data_symbol.sh
> @@ -5,8 +5,6 @@
> # Leo Yan <leo.yan@linaro.org>, 2022
>
> shelldir=$(dirname "$0")
> -# shellcheck source=lib/waiting.sh
> -. "${shelldir}"/lib/waiting.sh
>
> # shellcheck source=lib/perf_has_symbol.sh
> . "${shelldir}"/lib/perf_has_symbol.sh
> @@ -60,19 +58,10 @@ echo "Recording workload..."
> # specific CPU and test in per-CPU mode.
> is_amd=$(grep -E -c 'vendor_id.*AuthenticAMD' /proc/cpuinfo)
> if (($is_amd >= 1)); then
> - perf mem record -vvv -o ${PERF_DATA} -C 0 -- taskset -c 0 $TEST_PROGRAM 2>"${ERR_FILE}" &
> + perf mem record -vvv -o ${PERF_DATA} -C 0 -- taskset -c 0 $TEST_PROGRAM 2>"${ERR_FILE}"
> else
> - perf mem record -vvv --all-user -o ${PERF_DATA} -- $TEST_PROGRAM 2>"${ERR_FILE}" &
> + perf mem record -vvv --all-user -o ${PERF_DATA} -- $TEST_PROGRAM 2>"${ERR_FILE}"
> fi
>
> -PERFPID=$!
> -
> -wait_for_perf_to_start ${PERFPID} "${ERR_FILE}"
> -
> -sleep 1
> -
> -kill $PERFPID
> -wait $PERFPID
> -
> check_result
> exit $?
> --
> 2.48.1.711.g2feabab25a-goog
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 5/6] perf test: Add timeout to datasym workload
2025-03-04 2:28 ` [PATCH v2 5/6] perf test: Add timeout to datasym workload Namhyung Kim
2025-03-04 7:37 ` Thomas Richter
@ 2025-03-04 15:16 ` Leo Yan
1 sibling, 0 replies; 13+ messages in thread
From: Leo Yan @ 2025-03-04 15:16 UTC (permalink / raw)
To: Namhyung Kim
Cc: Arnaldo Carvalho de Melo, Ian Rogers, Kan Liang, Jiri Olsa,
Adrian Hunter, Peter Zijlstra, Ingo Molnar, LKML,
linux-perf-users, Thomas Richter
On Mon, Mar 03, 2025 at 06:28:36PM -0800, Namhyung Kim wrote:
> Unlike others it has an infinite loop that make it annoying to call.
> Make it finish after 1 second and handle command-line argument to change
> the setting.
>
> Cc: Thomas Richter <tmricht@linux.ibm.com>
> Cc: Leo Yan <leo.yan@arm.com>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Reviewed-by: Leo Yan <leo.yan@arm.com>
> ---
> tools/perf/tests/workloads/datasym.c | 23 +++++++++++++++++++++--
> 1 file changed, 21 insertions(+), 2 deletions(-)
>
> diff --git a/tools/perf/tests/workloads/datasym.c b/tools/perf/tests/workloads/datasym.c
> index 8e08fc75a973e5f7..8ddb2aa6a049e343 100644
> --- a/tools/perf/tests/workloads/datasym.c
> +++ b/tools/perf/tests/workloads/datasym.c
> @@ -1,3 +1,6 @@
> +#include <stdlib.h>
> +#include <signal.h>
> +#include <unistd.h>
> #include <linux/compiler.h>
> #include "../tests.h"
>
> @@ -12,9 +15,25 @@ static buf buf1 = {
> .reserved[0] = 1,
> };
>
> -static int datasym(int argc __maybe_unused, const char **argv __maybe_unused)
> +static volatile sig_atomic_t done;
> +
> +static void sighandler(int sig __maybe_unused)
> +{
> + done = 1;
> +}
> +
> +static int datasym(int argc, const char **argv)
> {
> - for (;;) {
> + int sec = 1;
> +
> + if (argc > 0)
> + sec = atoi(argv[0]);
> +
> + signal(SIGINT, sighandler);
> + signal(SIGALRM, sighandler);
> + alarm(sec);
> +
> + while (!done) {
> buf1.data1++;
> if (buf1.data1 == 123) {
> /*
> --
> 2.48.1.711.g2feabab25a-goog
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 0/6] perf test: Small improvements
2025-03-04 2:28 [PATCH v2 0/6] perf test: Small improvements Namhyung Kim
` (5 preceding siblings ...)
2025-03-04 2:28 ` [PATCH v2 6/6] perf test: Simplify data symbol test Namhyung Kim
@ 2025-03-04 16:17 ` Falcon, Thomas
2025-03-06 17:14 ` Namhyung Kim
7 siblings, 0 replies; 13+ messages in thread
From: Falcon, Thomas @ 2025-03-04 16:17 UTC (permalink / raw)
To: namhyung@kernel.org, acme@kernel.org, irogers@google.com,
kan.liang@linux.intel.com
Cc: jolsa@kernel.org, peterz@infradead.org, Hunter, Adrian,
linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
mingo@kernel.org
On Mon, 2025-03-03 at 18:28 -0800, Namhyung Kim wrote:
> Hello,
>
> This is an assorted list of changes in the perf test.
>
> I've added perf stat --metric-only test and perf trace record and
> replay.
> And other changes to skip privileged tests for non-root and simplify
> data symbol test.
>
> v2 changes)
> * fix shellcheck errors
> * simplify datasym test with timeout
>
> Thanks,
> Namhyung
>
Looks good on Alder Lake and Arrow Lake.
Tested-by: Thomas Falcon <thomas.falcon@intel.com>
>
> Namhyung Kim (6):
> perf test: Add --metric-only to perf stat output tests
> perf test: Skip perf probe tests when running as non-root
> perf test: Skip perf trace tests when running as non-root
> perf test: Add trace record and replay test
> perf test: Add timeout to datasym workload
> perf test: Simplify data symbol test
>
> .../tests/shell/lib/perf_json_output_lint.py | 7 ++++++
> tools/perf/tests/shell/lib/stat_output.sh | 8 +++++++
> .../tests/shell/perftool-testsuite_probe.sh | 1 +
> tools/perf/tests/shell/probe_vfs_getname.sh | 1 +
> .../shell/record+probe_libc_inet_pton.sh | 1 +
> .../shell/record+script_probe_vfs_getname.sh | 1 +
> tools/perf/tests/shell/stat+csv_output.sh | 2 ++
> tools/perf/tests/shell/stat+json_output.sh | 9 ++++++++
> tools/perf/tests/shell/stat+std_output.sh | 8 +++++++
> tools/perf/tests/shell/test_data_symbol.sh | 15 ++----------
> .../shell/test_uprobe_from_different_cu.sh | 11 ++++-----
> .../tests/shell/trace+probe_vfs_getname.sh | 1 +
> tools/perf/tests/shell/trace_btf_enum.sh | 1 +
> tools/perf/tests/shell/trace_btf_general.sh | 1 +
> tools/perf/tests/shell/trace_exit_race.sh | 1 +
> tools/perf/tests/shell/trace_record_replay.sh | 21 +++++++++++++++++
> tools/perf/tests/workloads/datasym.c | 23
> +++++++++++++++++--
> 17 files changed, 91 insertions(+), 21 deletions(-)
> create mode 100755 tools/perf/tests/shell/trace_record_replay.sh
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 0/6] perf test: Small improvements
2025-03-04 2:28 [PATCH v2 0/6] perf test: Small improvements Namhyung Kim
` (6 preceding siblings ...)
2025-03-04 16:17 ` [PATCH v2 0/6] perf test: Small improvements Falcon, Thomas
@ 2025-03-06 17:14 ` Namhyung Kim
7 siblings, 0 replies; 13+ messages in thread
From: Namhyung Kim @ 2025-03-06 17:14 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo, Ian Rogers, Kan Liang, Namhyung Kim
Cc: Jiri Olsa, Adrian Hunter, Peter Zijlstra, Ingo Molnar, LKML,
linux-perf-users
On Mon, 03 Mar 2025 18:28:31 -0800, Namhyung Kim wrote:
> This is an assorted list of changes in the perf test.
>
> I've added perf stat --metric-only test and perf trace record and replay.
> And other changes to skip privileged tests for non-root and simplify
> data symbol test.
>
> v2 changes)
> * fix shellcheck errors
> * simplify datasym test with timeout
>
> [...]
Applied to perf-tools-next, thanks!
Best regards,
Namhyung
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2025-03-06 17:14 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-04 2:28 [PATCH v2 0/6] perf test: Small improvements Namhyung Kim
2025-03-04 2:28 ` [PATCH v2 1/6] perf test: Add --metric-only to perf stat output tests Namhyung Kim
2025-03-04 2:28 ` [PATCH v2 2/6] perf test: Skip perf probe tests when running as non-root Namhyung Kim
2025-03-04 2:28 ` [PATCH v2 3/6] perf test: Skip perf trace " Namhyung Kim
2025-03-04 2:28 ` [PATCH v2 4/6] perf test: Add trace record and replay test Namhyung Kim
2025-03-04 2:28 ` [PATCH v2 5/6] perf test: Add timeout to datasym workload Namhyung Kim
2025-03-04 7:37 ` Thomas Richter
2025-03-04 15:16 ` Leo Yan
2025-03-04 2:28 ` [PATCH v2 6/6] perf test: Simplify data symbol test Namhyung Kim
2025-03-04 7:38 ` Thomas Richter
2025-03-04 15:15 ` Leo Yan
2025-03-04 16:17 ` [PATCH v2 0/6] perf test: Small improvements Falcon, Thomas
2025-03-06 17:14 ` Namhyung Kim
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox