Re: [PATCH bpf-next v8 1/3] bpf: arena: allocate the fault-in page outside the lock

From: Alexei Starovoitov

Date: Fri Sep 18 2026 - 14:13:19 EST


On Fri, Sep 18, 2026 at 04:40 PM Jiayuan Chen <jiayuan.chen@xxxxxxxxx> wrote:
> @@ -489,59 +490,108 @@ static vm_fault_t arena_vm_fault(struct vm_fault *vmf)
> kbase = bpf_arena_get_kern_vm_start(arena);
> kaddr = kbase + (u32)(vmf->address);
>
> - if (raw_res_spin_lock_irqsave(&arena->spinlock, flags))
> + page = vmalloc_to_page((void *)kaddr);
> + if (!page && !(arena->map.map_flags & BPF_F_SEGV_ON_FAULT)) {
> + /*
> + * Preallocate outside the lock so the allocation can sleep and
> + * reclaim, which the non-blocking allocator under
> + * arena->spinlock cannot. __GFP_RETRY_MAYFAIL: reclaim, but
> + * never OOM-kill in the map's memcg, which need not be the
> + * faulting task's. On failure, fallthrough: the locked
> + * recheck below picks up a page a concurrent allocator may
> + * have installed meanwhile, and otherwise the non-blocking
> + * fallback fails and we return VM_FAULT_SIGBUS. Not
> + * VM_FAULT_OOM: nothing ran the OOM killer, an
d the fault path
> + * would just retry it forever.
> + */

I asked for one line comment. This block and the one in !new_page
branch below repeat the commit log. Trim both to a sentence or two.

pw-bot: cr