selftests/bpf: Fix timer_start_deadlock failure due to hrtimer change
Subsystems (3)
PATCH 1/1 selftests/bpf: Fix timer_start_deadlock failure due to hrtimer change
Since commit f2e388a019e4 ("hrtimer: Reduce trace noise in hrtimer_start()"), hrtimer_cancel tracepoint is no longer called when a hrtimer is re-armed. So instead of a hrtimer_cancel followed by hrtimer_start tracepoint events, there is now only a since hrtimer_start tracepoint event with the new was_armed field set to 1, to indicated that the hrtimer was previously armed.
Update timer_start_deadlock accordingly so it traces hrtimer_start tracepoint instead, with was_armed used as guard.
---
Currently only fails on Linus' tree since hrtimer changes haven't made its way into bpf-next yet.
--- tools/testing/selftests/bpf/progs/timer_start_deadlock.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
tools/testing/selftests/bpf/progs/timer_start_deadlock.c +4 -4
@@ -27,13 +27,13 @@ static int timer_cb(void *map, int *key, struct elem *value)return 0 ; } -SEC("tp_btf/hrtimer_cancel") -int BPF_PROG (tp_hrtimer_cancel ,struct hrtimer *hrtimer) +SEC("tp_btf/hrtimer_start") +int BPF_PROG (tp_hrtimer_start ,struct hrtimer *hrtimer,enum hrtimer_mode mode,bool was_armed) {struct bpf_timer *timer;int key =0 ; -if (!in_timer_start) +if (!in_timer_start || !was_armed)return 0 ; tp_called =1 ;
@@ -60,7 +60,7 @@ int start_timer(void *ctx)/* * call hrtimer_start() twice, so that 2nd call does -* remove_hrtimer() and trace_hrtimer_cancel() tracepoint. +* trace_hrtimer_start(was_armed=1) tracepoint. */ in_timer_start =1 ;bpf_timer_start (timer,1000000000 ,0 );
Signature · 1 line
2.53.0
Quoted 6 lines · Shung-Hsi Yu
Since commit
f2e388a019e4("hrtimer: Reduce trace noise inhrtimer_start()"),hrtimer_canceltracepoint is no longer called when a hrtimer is re-armed. So instead of ahrtimer_cancelfollowed byhrtimer_starttracepoint events, there is now only a sincehrtimer_starttracepoint event with the newwas_armedfield set to 1, to indicated that the hrtimer was previously armed.
Quoted 8 lines
Update
timer_start_deadlockaccordingly so it traceshrtimer_starttracepoint instead, withwas_armedused as guard.Signed-off-by Shung-Hsi Yu <[email protected]>---
Currently only fails on Linus' tree since hrtimer changes haven't made its way into bpf-next yet.
---
This patch fixes the failing test.
The logic is also looks correct, tracepoint used to run on timer_cancel, which was called due to the second timer_start, now it's running on timer_start with was_armed=true, so the logic is kept the same.
Quoted 33 lines
tools/testing/selftests/bpf/progs/timer_start_deadlock.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)tools/testing/selftests/bpf/progs/timer_start_deadlock.c +4
-4@@ -27,13 +27,13 @@ static int timer_cb(void *map, int *key, struct elem *value)return 0 ; } -SEC("tp_btf/hrtimer_cancel") -int BPF_PROG (tp_hrtimer_cancel ,struct hrtimer *hrtimer) +SEC("tp_btf/hrtimer_start") +int BPF_PROG (tp_hrtimer_start ,struct hrtimer *hrtimer,enum hrtimer_mode mode,bool was_armed) {struct bpf_timer *timer;int key =0 ; -if (!in_timer_start) +if (!in_timer_start || !was_armed)return 0 ; tp_called =1 ;@@ -60,7 +60,7 @@ int start_timer(void *ctx)/* * call hrtimer_start() twice, so that 2nd call does -* remove_hrtimer() and trace_hrtimer_cancel() tracepoint. +* trace_hrtimer_start(was_armed=1) tracepoint. */ in_timer_start =1 ;bpf_timer_start (timer,1000000000 ,0 );
This patch was applied to bpf/bpf.git (master) by Alexei Starovoitov <[email protected]>:
Hello:
This patch was applied to bpf/bpf.git (master)
by Alexei Starovoitov <[email protected]>:
Quoted 10 lines · On Wed, 15 Apr 2026 20:03:28 +0800 you wrote:
Since commit
f2e388a019e4("hrtimer: Reduce trace noise inhrtimer_start()"),hrtimer_canceltracepoint is no longer called when a hrtimer is re-armed. So instead of ahrtimer_cancelfollowed byhrtimer_starttracepoint events, there is now only a sincehrtimer_starttracepoint event with the newwas_armedfield set to 1, to indicated that the hrtimer was previously armed.Update
timer_start_deadlockaccordingly so it traceshrtimer_starttracepoint instead, withwas_armedused as guard.[...]
Here is the summary with links:
- [bpf-next] selftests/bpf: Fix timer_start_deadlock failure due to hrtimer change
https://git.kernel.org/bpf/bpf/c/813f336269e6
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html