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>
This commit is contained in:
Alexei Starovoitov 2026-02-04 18:14:26 -08:00
commit 75cd3beb64

View File

@ -1257,7 +1257,7 @@ static void bpf_async_cb_rcu_tasks_trace_free(struct rcu_head *rcu)
retry = true;
break;
case BPF_ASYNC_TYPE_WQ:
if (!cancel_work(&w->work))
if (!cancel_work(&w->work) && work_busy(&w->work))
retry = true;
break;
}
@ -1664,6 +1664,7 @@ static void bpf_async_cancel_and_free(struct bpf_async_kern *async)
if (!cb)
return;
bpf_async_update_prog_callback(cb, NULL, NULL);
/*
* No refcount_inc_not_zero(&cb->refcnt) here. Dropping the last
* refcnt. Either synchronously or asynchronously in irq_work.