Skip to contentSkip to conversation

perf test: Skip syscall enum test if no landlock syscall

PATCH Superseded Namhyung Kim 2 participants 3 messages Jan 22, 2025 perf events

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Namhyung Kim

author maintainer
#0 lore raw

PATCH 1/1 perf test: Skip syscall enum test if no landlock syscall

The perf trace enum augmentation test specifically targets landlock_ add_rule syscall but IIUC it's an optional and can be opt-out by a kernel config.

Currently trace_landlock() runs perf test -w landlock before the actual testing to check the availability but it's not enough since the workload always returns 0. Instead it could check if perf trace output has 'landlock' string.

Fixes d66763fed30f0bd8c ("perf test trace_btf_enum: Add regression test for the BTF augmentation of enums in 'perf trace'")
Cc Howard Chu <[email protected]>
---
 tools/perf/tests/shell/trace_btf_enum.sh | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
tools/perf/tests/shell/trace_btf_enum.sh +5 -1
index 5a3b8a5a9b5cf296..e57ad6913f3e9316 100755
@@ -27,7 +27,11 @@ trace_landlock() {
   echo "Tracing syscall ${syscall}"
 
   # test flight just to see if landlock_add_rule and libbpf are available
-  $TESTPROG
+  if ! perf trace $TESTPROG 2>&1 | grep -q landlock
+  then
+    echo "No landlock system call found. Fallback to non-syscall tracing."
+    return
+  fi
 
   if perf trace -e $syscall $TESTPROG 2>&1 | \
      grep -q -E ".*landlock_add_rule\(ruleset_fd: 11, rule_type: (LANDLOCK_RULE_PATH_BENEATH|LANDLOCK_RULE_NET_PORT), rule_attr: 0x[a-f0-9]+, flags: 45\) = -1.*"
Signature · 1 line
2.48.0.rc2.279.g1de40edade-goog
Reviewed-by on v1 1/1
#1 lore raw

Hello Namhyung,

Quoted 9 lines · Namhyung Kim

The perf trace enum augmentation test specifically targets landlock_ add_rule syscall but IIUC it's an optional and can be opt-out by a kernel config.

Currently trace_landlock() runs perf test -w landlock before the actual testing to check the availability but it's not enough since the workload always returns 0. Instead it could check if perf trace output has 'landlock' string.

I remember doing the landlock syscall nr ifdef checking and returning -1... Somehow it's not there... Sorry.

Quoted 13 lines
Fixes d66763fed30f0bd8c ("perf test trace_btf_enum: Add regression test for the BTF augmentation of enums in 'perf trace'")
Cc Howard Chu <[email protected]>
---
 tools/perf/tests/shell/trace_btf_enum.sh | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
tools/perf/tests/shell/trace_btf_enum.sh +0 -0
index 5a3b8a5a9b5cf296..e57ad6913f3e9316 100755

tools/perf/tests/shell/trace_btf_enum.sh trace_landlock() { · line 29

Quoted 3 lines
tools/perf/tests/shell/trace_btf_enum.sh +0 -0
@@ -27,7 +27,11 @@ trace_landlock() {
   echo "Tracing syscall ${syscall}"
 
   # test flight just to see if landlock_add_rule and libbpf are available

Wonder why I put 'libbpf' here, can you please change this comment to '# test flight just to see if landlock_add_rule is available' If you find this change appropriate?

tools/perf/tests/shell/trace_btf_enum.sh trace_landlock() { · line 32

Quoted 4 lines
tools/perf/tests/shell/trace_btf_enum.sh +3 -1
-  $TESTPROG
+  if ! perf trace $TESTPROG 2>&1 | grep -q landlock
+  then
+    echo "No landlock system call found. Fallback to non-syscall tracing."

I wouldn't say it's a fallback, because the non-syscall test gets run even if the landlock_add_rule syscall can be invoked. Why not say: 'No landlock system call found, skipping to non-syscall tracing'?

Quoted 8 lines
tools/perf/tests/shell/trace_btf_enum.sh +2 -1
+    return
+  fi
 
   if perf trace -e $syscall $TESTPROG 2>&1 | \
      grep -q -E ".*landlock_add_rule\(ruleset_fd: 11, rule_type: (LANDLOCK_RULE_PATH_BENEATH|LANDLOCK_RULE_NET_PORT), rule_attr: 0x[a-f0-9]+, flags: 45\) = -1.*"
--

2.48.0.rc2.279.g1de40edade-goog

Other things LGTM.

Thanks,
Howard

author maintainer
#2 lore raw
Quoted 8 lines · Howard Chu

Hello Namhyung,

Quoted 5 lines · Namhyung Kim

The perf trace enum augmentation test specifically targets landlock_ add_rule syscall but IIUC it's an optional and can be opt-out by a kernel config.

Quoted 7 lines
Quoted 4 lines

Currently trace_landlock() runs perf test -w landlock before the actual testing to check the availability but it's not enough since the workload always returns 0. Instead it could check if perf trace output has 'landlock' string.

I remember doing the landlock syscall nr ifdef checking and returning -1... Somehow it's not there... Sorry.

That's ok, we can fix it later. :)

Quoted 16 lines
Quoted 16 lines
Fixes d66763fed30f0bd8c ("perf test trace_btf_enum: Add regression test for the BTF augmentation of enums in 'perf trace'")
Cc Howard Chu <[email protected]>
---
 tools/perf/tests/shell/trace_btf_enum.sh | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
tools/perf/tests/shell/trace_btf_enum.sh +0 -0
index 5a3b8a5a9b5cf296..e57ad6913f3e9316 100755
@@ -27,7 +27,11 @@ trace_landlock() {
   echo "Tracing syscall ${syscall}"
 
Quoted 5 lines

tools/perf/tests/shell/trace_btf_enum.sh trace_landlock() { · line 29

Quoted 1 line
tools/perf/tests/shell/trace_btf_enum.sh +0 -0
   # test flight just to see if landlock_add_rule and libbpf are available

Wonder why I put 'libbpf' here, can you please change this comment to '# test flight just to see if landlock_add_rule is available' If you find this change appropriate?

Sure, will update.

Quoted 9 lines

tools/perf/tests/shell/trace_btf_enum.sh trace_landlock() { · line 32

Quoted 5 lines
tools/perf/tests/shell/trace_btf_enum.sh +3 -1
-  $TESTPROG
+  if ! perf trace $TESTPROG 2>&1 | grep -q landlock
+  then
+    echo "No landlock system call found. Fallback to non-syscall tracing."

I wouldn't say it's a fallback, because the non-syscall test gets run even if the landlock_add_rule syscall can be invoked. Why not say: 'No landlock system call found, skipping to non-syscall tracing'?

Ok.

Quoted 10 lines
Quoted 9 lines
tools/perf/tests/shell/trace_btf_enum.sh +2 -1
+    return
+  fi
 
   if perf trace -e $syscall $TESTPROG 2>&1 | \
      grep -q -E ".*landlock_add_rule\(ruleset_fd: 11, rule_type: (LANDLOCK_RULE_PATH_BENEATH|LANDLOCK_RULE_NET_PORT), rule_attr: 0x[a-f0-9]+, flags: 45\) = -1.*"
--

2.48.0.rc2.279.g1de40edade-goog

Quoted 3 lines

Other things LGTM.

Thanks for your review!
Namhyung