Re: [PATCH 3/6] selftests/bpf: libarena: Disable IRQs during allocation
| Newsgroups | org.kernel.vger.bpf |
|---|---|
| Message-ID | <fa0d9a7b2cf4f9806b4e7e75673d135099da380e3b74a54c0a6a657e00956337@mail.kernel.org> |
> selftests/bpf: libarena: Disable IRQs during allocation > > The libarena buddy allocator currently uses arena_spin_lock/unlock > to protect its internal data structures in its critical section. > These locks disable preemption, but not IRQs. This in turns can cause > ABBA deadlocks when an allocation/free operation gets an IRQ while > in the critical section, and can only resume after another operation > that in turn blocks on the buddy lock. We have concretely seen this > with sched_ext schedulers: > > a) Task 1 on CPU A attempts an allocation during initialization, > which is done without holding an rq lock. The task takes an IRQ > in the middle of the allocation. > b) Task 2 on CPU B exits. It attempts to take the buddy allocator > lock during its sched-ext state teardown, and blocks on the spinlock. > It does so while holding CPU B's rq lock. > c) The scheduler run on CPU A and attempts to move tasks from CPU > B's rq to CPU A's rq before resuming running Task 1. This requires > B's rq lock, which requires Task 2 to take the buddy allocator lock > first. > > Fix this by disabling IRQs when taking the buddy lock. We use the > already existing arena_spin_[lock_irqsave, unlock_irqrestore] calls > for this. > > Signed-off-by: Emil Tsalapatis <[email protected]> This looks like a bug fix for the buddy allocator's locking. Should this include: Fixes: 86426a28c52d ("selftests/bpf: Add buddy allocator for libarena") --- AI reviewed your patch. Please fix the bug or email reply why it's not a bug. See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md CI run summary: https://github.com/kernel-patches/bpf/actions/runs/32062809860