Re: [PATCH v20 09/11] selftests: tracing: Add wprobe trigger testcases

From
sashiko-bot@kernel.org
Date
2026-11-16 05:52:03
Also in
linux-perf-users
Reply to
Masami Hiramatsu (Google), 2026-11-16
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Low] selftests: ftrace: race checking count=1 on active timer in
  trigger-wprobe.tc
- [Low] selftests: ftrace: race truncating dynamic_events after wprobe
  trigger removal
--

commit 99426394cee3a23084f980a46322a802a391dabe
Author: Masami Hiramatsu (Google) [off-list ref]

selftests: tracing: Add wprobe trigger testcases

This commit adds ftrace selftests covering set_wprobe and clear_wprobe
event triggers, including CPU hotplug and trigger syntax error checks.

Link: https://lore.kernel.org/all/59637b96946653393a7ad3c7de094094796b39c2.1785067572.git.wangjinchao600@gmail.com/ (local)
quoted hunk ↗ jump to hunk
diff --git a/tools/testing/selftests/ftrace/test.d/trigger/trigger-wprobe.tc b/tools/testing/selftests/ftrace/test.d/trigger/trigger-wprobe.tc
new file mode 100644
index 0000000000000..13cacfd376e79
--- /dev/null
+++ b/tools/testing/selftests/ftrace/test.d/trigger/trigger-wprobe.tc
[ ... ]
quoted hunk ↗ jump to hunk
+:;: "Test field offset, count limit, and conditional clear_wprobe" ;:
+clear_trace
+echo 'set_wprobe:watch:timer+16:1' >> events/fprobes/testevent/trigger
+if ! grep -q '^set_wprobe:watch:timer+16:count=1' events/fprobes/testevent/trigger; then
+  fail "Failed to set counted set_wprobe trigger with offset"
+fi
[Severity: Low]
Can sample_timer_cb() fire before grep reads events/fprobes/testevent/trigger
here?

events/fprobes/testevent/enable is already set to 1 while sample_timer_cb()
runs every second on a timer.  If the timer expires between registering the
trigger and spawning grep, wprobe_trigger() decrements data->count from 1 to
0:

shell                             <softirq>
write()
  wprobe_register_trigger()
                                  sample_timer_cb()
                                    wprobe_trigger()
                                      data->count-- (1 -> 0)
grep
  wprobe_trigger_print()
    prints count=0  <-- grep for count=1 fails

Disabling testevent while registering and checking count=1, or matching
count=[01] before the post-sleep count=0 check, would avoid a spurious test
failure.
quoted hunk ↗ jump to hunk
+
+sleep 2
+if ! grep -q watch trace; then
+  fail "Failed to trigger watchpoint with field offset and count"
+fi
+if ! grep -q '^set_wprobe:watch:timer+16:count=0' events/fprobes/testevent/trigger; then
+  fail "Counted set_wprobe trigger did not decrement count to 0"
+fi
+
+echo 'clear_wprobe:watch:timer+16' >> events/fprobes/testevent/trigger
+echo '!set_wprobe:watch:timer+16' >> events/fprobes/testevent/trigger
+sleep 2
+clear_trace
+sleep 1
+if ! grep -q '^0\*' events/wprobes/watch/enable; then
+  fail "Conditional clear_wprobe did not soft-disable watchpoint"
+fi
+if grep -q watch trace; then
+  fail "Failed to clear watchpoint with conditional clear_wprobe"
+fi
+echo '!clear_wprobe:watch:timer+16' >> events/fprobes/testevent/trigger
+
+:;: "Disable events and remove dynamic events" ;:
+echo 0 > events/enable
+echo > dynamic_events
[Severity: Low]
Can truncating dynamic_events immediately after removing clear_wprobe fail
with -EBUSY?

When a wprobe trigger is registered, wprobe_trigger_cmd_parse() takes a
reference on the target wprobe event via trace_event_try_get_ref().
Unregistering the trigger calls wprobe_trigger_free() -> trigger_data_free(),
which defers release_private_wprobe_trigger_data() -> trace_event_put_ref()
to trigger_kthread after tracepoint_synchronize_unregister() finishes:

shell                             trigger_kthread
write("!clear_wprobe:...")
  wprobe_unregister_trigger()
    trigger_data_free()
write("" > dynamic_events)
  dyn_events_release_all()
    unregister_trace_wprobe()
      trace_event_dyn_busy()  <-- returns -EBUSY
                                  tracepoint_synchronize_unregister()
                                  release_private_wprobe_trigger_data()
                                    trace_event_put_ref()

The same race applies to cleanup_wprobe_triggers() and to
trigger-wprobe-hotplug.tc where echo > dynamic_events runs immediately after
removing the triggers; calling clear_dynamic_events (which retries in a loop)
or sleeping before truncating dynamic_events would avoid this.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/179480675130.38065.3086970856119381693.stgit@devnote2?part=9
Thread (17 messages) 17 messages, 2 authors, last reply 15h ago
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help