Skip to contentSkip to conversation

selftests/ftrace: Fix unique symbol check in kprobe_non_uniq_symbol.tc

PATCH In review Sven Schnelle 3 participants 4 messages Sep 9 – Sep 10

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

PATCH 1/1 selftests/ftrace: Fix unique symbol check in kprobe_non_uniq_symbol.tc

The current regex also matches symbols in modules, which makes the test fail on s390 where name_show is present only once in the kernel, but also multiple times in modules:

000001b1401cdc20 t name_show
000001b0c05e6c40 t name_show [mdev]
000001b0c0495f30 t name_show [i2c_core]

Fix this by changing the regular expression to only match the function name.

---
 .../selftests/ftrace/test.d/kprobe/kprobe_non_uniq_symbol.tc    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_non_uniq_symbol.tc +1 -1
index bc9514428dba..07b1177c1634 100644
@@ -6,7 +6,7 @@
 SYMBOL='name_show'
 
 # We skip this test on kernel where SYMBOL is unique or does not exist.
-if [ "$(grep -c -E "[[:alnum:]]+ t ${SYMBOL}" /proc/kallsyms)" -le '1' ]; then
+if [ "$(grep -c -E "[[:alnum:]]+ t ${SYMBOL}$" /proc/kallsyms)" -le '1' ]; then
 	exit_unsupported
 fi
 
Signature · 1 line
2.53.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 21 lines · On Wed, 9 Sep 2026 11:29:53 +0200 Sven Schnelle <[email protected]> wrote:

The current regex also matches symbols in modules, which makes the test fail on s390 where name_show is present only once in the kernel, but also multiple times in modules:

000001b1401cdc20 t name_show
000001b0c05e6c40 t name_show [mdev]
000001b0c0495f30 t name_show [i2c_core]

Fix this by changing the regular expression to only match the function name.

---
 .../selftests/ftrace/test.d/kprobe/kprobe_non_uniq_symbol.tc    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_non_uniq_symbol.tc +0 -0
index bc9514428dba..07b1177c1634 100644

tools/testing/selftests/ftrace/test.d/kprobe/kprobe_non_uniq_symbol.tc line 12

Quoted 8 lines
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_non_uniq_symbol.tc +1 -1
@@ -6,7 +6,7 @@
 SYMBOL='name_show'
 
 # We skip this test on kernel where SYMBOL is unique or does not exist.
-if [ "$(grep -c -E "[[:alnum:]]+ t ${SYMBOL}" /proc/kallsyms)" -le '1' ]; then
+if [ "$(grep -c -E "[[:alnum:]]+ t ${SYMBOL}$" /proc/kallsyms)" -le '1' ]; then
 	exit_unsupported
 fi
 

But I wonder if "type_show" or "init_once" is a better option than "name_show"?

-- Steve

#3 lore raw
In reply to Sven Schnelle
Quoted 10 lines · On Wed, 9 Sep 2026 11:29:53 +0200 Sven Schnelle <[email protected]> wrote:

The current regex also matches symbols in modules, which makes the test fail on s390 where name_show is present only once in the kernel, but also multiple times in modules:

000001b1401cdc20 t name_show
000001b0c05e6c40 t name_show [mdev]
000001b0c0495f30 t name_show [i2c_core]

Fix this by changing the regular expression to only match the function name.

Ah, nice catch! I'll add this fixes tag.

Fixes 03b80ff8023a ("selftests/ftrace: Add new test case which checks non unique symbol")

Thanks,

Quoted 22 lines
---
 .../selftests/ftrace/test.d/kprobe/kprobe_non_uniq_symbol.tc    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_non_uniq_symbol.tc +1 -1
index bc9514428dba..07b1177c1634 100644
@@ -6,7 +6,7 @@
 SYMBOL='name_show'
 
 # We skip this test on kernel where SYMBOL is unique or does not exist.
-if [ "$(grep -c -E "[[:alnum:]]+ t ${SYMBOL}" /proc/kallsyms)" -le '1' ]; then
+if [ "$(grep -c -E "[[:alnum:]]+ t ${SYMBOL}$" /proc/kallsyms)" -le '1' ]; then
 	exit_unsupported
 fi
 
Signature · 1 line
2.53.0
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
#2 lore raw
In reply to Steven Rostedt
Quoted 35 lines · On Wed, 9 Sep 2026 13:41:56 -0400 Steven Rostedt <[email protected]> wrote:
Quoted 21 lines · On Wed, 9 Sep 2026 11:29:53 +0200 Sven Schnelle <[email protected]> wrote:

The current regex also matches symbols in modules, which makes the test fail on s390 where name_show is present only once in the kernel, but also multiple times in modules:

000001b1401cdc20 t name_show
000001b0c05e6c40 t name_show [mdev]
000001b0c0495f30 t name_show [i2c_core]

Fix this by changing the regular expression to only match the function name.

---
 .../selftests/ftrace/test.d/kprobe/kprobe_non_uniq_symbol.tc    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_non_uniq_symbol.tc +0 -0
index bc9514428dba..07b1177c1634 100644

tools/testing/selftests/ftrace/test.d/kprobe/kprobe_non_uniq_symbol.tc line 12

Quoted 8 lines
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_non_uniq_symbol.tc +1 -1
@@ -6,7 +6,7 @@
 SYMBOL='name_show'
 
 # We skip this test on kernel where SYMBOL is unique or does not exist.
-if [ "$(grep -c -E "[[:alnum:]]+ t ${SYMBOL}" /proc/kallsyms)" -le '1' ]; then
+if [ "$(grep -c -E "[[:alnum:]]+ t ${SYMBOL}$" /proc/kallsyms)" -le '1' ]; then
 	exit_unsupported
 fi
 
Quoted 2 lines

But I wonder if "type_show" or "init_once" is a better option than "name_show"?

Yeah, we have many other candidates :)

$ grep -E '[[:alnum:]]+ t [[:alpha:]][[:alnum:]_]+$' /proc/kallsyms | cut -d " " -f 3  | sort | uniq -cd | sort -nr | head 
     27 p4d_offset
     20 type_show
     20 dev_attr_name
     17 dev_attr_modalias
     16 pfn_to_mfn
     15 name_show
     14 modalias_show
     14 dev_attr_type
     13 init_once
     13 format_attr_event

Maybe we can just fallback to this logic for finding available symbols?

Thanks,

Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>