Skip to contentSkip to conversation

selftests/tracing: Fix some testcases for recent change

PATCH In review Masami Hiramatsu (Google) 3 participants 6 messages Jan 7, 2023 – Jan 26, 2023

Subsystems (2)
lore
Share & tools
lore

Masami Hiramatsu (Google)

author maintainer
#0 lore raw

cover selftests/tracing: Fix some testcases for recent change

This includes some patches to fix 2 issues on ftrace selftests.

- eprobe filter and eprobe syntax test case were introduced but it doesn't check whether the kernel supports eprobe filter. Thus the new test case fails on the kernel which has eprobe but not support eprobe filter. To solve this issue, add a filter description to README file [1/3] and run the filter syntax error test only if the description is found in the README file [2/3].

- Recently objtool adds prefix symbols for the function padding nops, and the probepoint test case fails because this probepoint test case tests whether the kprobe event can probe the target function and the functions next to the target function. But the prefix symbols can not be probed. Thus these prefix symbols must be skipped [3/3].

Thank you,

---

Masami Hiramatsu (Google) (3):
tracing/eprobe: Fix to add filter on eprobe description in README file selftests/ftrace: Fix eprobe syntax test case to check filter support selftests/ftrace: Fix probepoint testcase to ignore __pfx_* symbols

 kernel/trace/trace.c                               |    2 +-
 .../test.d/dynevent/eprobes_syntax_errors.tc       |    4 +++-
 .../selftests/ftrace/test.d/kprobe/probepoint.tc   |    2 +-
 3 files changed, 5 insertions(+), 3 deletions(-)

--
Masami Hiramatsu (Google) <[email protected]>

author maintainer
#1 lore raw

PATCH 1/3 tracing/eprobe: Fix to add filter on eprobe description in README file

From: Masami Hiramatsu (Google) <[email protected]>

Fix to add a description of the filter on eprobe in README file. This is required to identify the kernel supports the filter on eprobe or not.

Fixes 752be5c5c910 ("tracing/eprobe: Add eprobe filter support")
---
 kernel/trace/trace.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace.c +1 -1
index a555a861b978..d0c22766dc26 100644
@@ -5598,7 +5598,7 @@ static const char readme_msg[] =
 #ifdef CONFIG_HIST_TRIGGERS
 	"\t           s:[synthetic/]<event> <field> [<field>]\n"
 #endif
-	"\t           e[:[<group>/][<event>]] <attached-group>.<attached-event> [<args>]\n"
+	"\t           e[:[<group>/][<event>]] <attached-group>.<attached-event> [<args>] [if <filter>]\n"
 	"\t           -:[<group>/][<event>]\n"
 #ifdef CONFIG_KPROBE_EVENTS
 	"\t    place: [<module>:]<symbol>[+<offset>]|<memaddr>\n"
author maintainer
#2 lore raw

PATCH 2/3 selftests/ftrace: Fix eprobe syntax test case to check filter support

In reply to Masami Hiramatsu (Google)

From: Masami Hiramatsu (Google) <[email protected]>

Fix eprobe syntax test case to check whether the kernel supports the filter on eprobe for filter syntax test command. Without this fix, this test case will fail if the kernel supports eprobe but doesn't support the filter on eprobe.

Fixes 9e14bae7d049 ("selftests/ftrace: Add eprobe syntax error testcase")
---
 .../test.d/dynevent/eprobes_syntax_errors.tc       |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tools/testing/selftests/ftrace/test.d/dynevent/eprobes_syntax_errors.tc +3 -1
index fc1daac7f066..4f5e8c665156 100644
@@ -22,6 +22,8 @@ check_error 'e:foo/^bar.1 syscalls/sys_enter_openat'	# BAD_EVENT_NAME
 check_error 'e:foo/bar syscalls/sys_enter_openat arg=^dfd'	# BAD_FETCH_ARG
 check_error 'e:foo/bar syscalls/sys_enter_openat ^arg=$foo'	# BAD_ATTACH_ARG
 
-check_error 'e:foo/bar syscalls/sys_enter_openat if ^'	# NO_EP_FILTER
+if grep -q '<attached-group>\.<attached-event>.*\[if <filter>\]' README; then
+  check_error 'e:foo/bar syscalls/sys_enter_openat if ^'	# NO_EP_FILTER
+fi
 
 exit 0
author maintainer
#3 lore raw

PATCH 3/3 selftests/ftrace: Fix probepoint testcase to ignore __pfx_* symbols

In reply to Masami Hiramatsu (Google)

From: Masami Hiramatsu (Google) <[email protected]>

Fix kprobe probepoint testcase to ignore __pfx_* prefix symbols. Those are introduced by commit b341b20d648b ("x86: Add prefix symbols for function padding") for identifying PADDING_BYTES of NOPs. Since kprobe events can not probe these prefix symbols, this testcase has to skip those symbols.

Fixes b341b20d648b ("x86: Add prefix symbols for function padding")
---
 .../selftests/ftrace/test.d/kprobe/probepoint.tc   |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/ftrace/test.d/kprobe/probepoint.tc +1 -1
index 624269c8d534..68425987a5dd 100644
@@ -21,7 +21,7 @@ set_offs() { # prev target next
 
 # We have to decode symbol addresses to get correct offsets.
 # If the offset is not an instruction boundary, it cause -EILSEQ.
-set_offs `grep -A1 -B1 ${TARGET_FUNC} /proc/kallsyms | cut -f 1 -d " " | xargs`
+set_offs `grep -v __pfx_ /proc/kallsyms | grep -A1 -B1 ${TARGET_FUNC} | cut -f 1 -d " " | xargs`
 
 UINT_TEST=no
 # printf "%x" -1 returns (unsigned long)-1.
maintainer Reviewed-by on the v1 series
#4 lore raw
In reply to Masami Hiramatsu (Google)
Quoted 15 lines · On Sat, 7 Jan 2023 22:32:08 +0900 "Masami Hiramatsu (Google)"…

This includes some patches to fix 2 issues on ftrace selftests.

- eprobe filter and eprobe syntax test case were introduced but it doesn't check whether the kernel supports eprobe filter. Thus the new test case fails on the kernel which has eprobe but not support eprobe filter. To solve this issue, add a filter description to README file [1/3] and run the filter syntax error test only if the description is found in the README file [2/3].

- Recently objtool adds prefix symbols for the function padding nops, and the probepoint test case fails because this probepoint test case tests whether the kprobe event can probe the target function and the functions next to the target function. But the prefix symbols can not be probed. Thus these prefix symbols must be skipped [3/3].

Quoted 10 lines

Thank you,

---

Masami Hiramatsu (Google) (3):
tracing/eprobe: Fix to add filter on eprobe description in README file selftests/ftrace: Fix eprobe syntax test case to check filter support selftests/ftrace: Fix probepoint testcase to ignore __pfx_* symbols

-- Steve

maintainer Acked-by
#5 lore raw
Quoted 29 lines · Steven Rostedt
Quoted 15 lines · On Sat, 7 Jan 2023 22:32:08 +0900 "Masami Hiramatsu (Google)"…

This includes some patches to fix 2 issues on ftrace selftests.

- eprobe filter and eprobe syntax test case were introduced but it doesn't check whether the kernel supports eprobe filter. Thus the new test case fails on the kernel which has eprobe but not support eprobe filter. To solve this issue, add a filter description to README file [1/3] and run the filter syntax error test only if the description is found in the README file [2/3].

- Recently objtool adds prefix symbols for the function padding nops, and the probepoint test case fails because this probepoint test case tests whether the kprobe event can probe the target function and the functions next to the target function. But the prefix symbols can not be probed. Thus these prefix symbols must be skipped [3/3].

Quoted 10 lines

Thank you,

---

Masami Hiramatsu (Google) (3):
tracing/eprobe: Fix to add filter on eprobe description in README file selftests/ftrace: Fix eprobe syntax test case to check filter support selftests/ftrace: Fix probepoint testcase to ignore __pfx_* symbols

Quoted 4 lines

-- Steve

For selftest patches in the series: (Assuming patches 2&3 depend on patch 1.)

thanks,
-- Shuah