Re: [PATCH bpf-next v2] bpf: Avoid soft lockup in __htab_map_lookup_and_delete_batch()

From: Rik van Riel

Date: Wed Sep 09 2026 - 17:18:17 EST


On Wed, 2026-09-09 at 17:51 +0000, Josef Bacik wrote:
>
> Plain cond_resched() is not enough either. It is a no-op under
> PREEMPT
> and PREEMPT_LAZY, the only models arm64 and x86 have offered since
> commit 7dadeaa6e851 ("sched: Further restrict the preemption modes").
> It is also never a Tasks RCU quiescent state, in any model: the
> reschedule counts as a preemption. The walking task stays a holdout
> and
> stalls every synchronize_rcu_tasks() caller, ftrace and BPF
> trampoline
> teardown included, until the syscall returns [1].
> cond_resched_tasks_rcu_qs() is the usual tool for that [2]. It
> reports
> the quiescent state at each yield and still reschedules as
> cond_resched() does on PREEMPT_NONE and PREEMPT_VOLUNTARY kernels.
>
> Fixes: 057996380a42 ("bpf: Add batch ops to all htab bpf map")
> Cc: "Paul E. McKenney" <paulmck@xxxxxxxxxx>
> Cc: Rik van Riel <riel@xxxxxxxxxxx>
> Link:
> https://lore.kernel.org/bpf/20260715215314.44423f47@fangorn/ [1]
> Link:
> https://lore.kernel.org/bpf/9d444098-7c03-4163-af12-bd0a79a51443@paulmck-laptop/
>  [2]
> Assisted-by: LLM
> Signed-off-by: Jose Fernandez (Anthropic) <jose.fernandez@xxxxxxxxx>
> Signed-off-by: Josef Bacik <josef@xxxxxxxxxxxxxx>
>

Looks like you got an RCU quiesce in every path that
loops back.

Reviewed-by: Rik van Riel <riel@xxxxxxxxxxx>

--
All Rights Reversed.