Skip to content

Commit 75cd3be

Browse files
author
Alexei Starovoitov
committed
Merge branch 'fix-for-bpf_wq-retry-loop-during-free'
Kumar Kartikeya Dwivedi says: ==================== Fix for bpf_wq retry loop during free Small fix and improvement to ensure cancel_work() can handle the case where wq callback is running, and doesn't lead to call_rcu_tasks_trace() repeatedly after failing cancel_work, if wq callback is not pending. ==================== Link: https://patch.msgid.link/20260205003853.527571-1-memxor@gmail.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
2 parents 6e951a9 + 5000a09 commit 75cd3be

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

kernel/bpf/helpers.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1257,7 +1257,7 @@ static void bpf_async_cb_rcu_tasks_trace_free(struct rcu_head *rcu)
12571257
retry = true;
12581258
break;
12591259
case BPF_ASYNC_TYPE_WQ:
1260-
if (!cancel_work(&w->work))
1260+
if (!cancel_work(&w->work) && work_busy(&w->work))
12611261
retry = true;
12621262
break;
12631263
}
@@ -1664,6 +1664,7 @@ static void bpf_async_cancel_and_free(struct bpf_async_kern *async)
16641664
if (!cb)
16651665
return;
16661666

1667+
bpf_async_update_prog_callback(cb, NULL, NULL);
16671668
/*
16681669
* No refcount_inc_not_zero(&cb->refcnt) here. Dropping the last
16691670
* refcnt. Either synchronously or asynchronously in irq_work.

0 commit comments

Comments
 (0)