Re: [PATCH bpf-next v1 1/4] bpf: Add call for selecting kmalloc or kmalloc_nolock at call time

From: Peter Zijlstra

Date: Wed Nov 25 2026 - 11:04:41 EST


On Wed, Nov 25, 2026 at 02:30:52PM +0000, Harry Yoo wrote:

> > This is absolute atrocious shite. You cannot attempt a spin_trylock from
> > NMI context. That thing might be a mutex.
>
> Uh, right. We went through this when kmalloc_nolock() was introduced.
>
> > This should not work; if it does, that is an accident we need to fix.
>
> Current implementation handles this by can_spin_trylock() in
> mm/internal.h.
>
> One remaining accident we're aware is that we cannot attempt a
> spin_trylock or local_trylock under pi_lock (even on !RT).
>
> Currently I don't have a good idea to fix this :/

Yeah, me neither, other than creating specific classes of
tracepoints/whatnot where things are explicitly allowed.