Re: [PATCH bpf-next v4 12/17] mm, bpf: introduce bpf_oom_proactive_kill() for proactive OOM prevention

From: Ben Gardon

Date: Thu Dec 03 2026 - 13:35:50 EST


On Wed, Dec 2, 2026 at 5:19 PM Alexei Starovoitov
<alexei.starovoitov@xxxxxxxxx> wrote:
>
> On Wed, Dec 02, 2026 at 01:04 PM Ben Gardon <bgardon@xxxxxxxxxx> wrote:
> > It cannot directly terminate a specific task chosen by a proactive
> > userspace/BPF policy.
>
> It can with patches 2-4:
>
> proactive prog bpf_oom_ops handler
> store pid in a map
> bpf_out_of_memory(memcg)
> oc->bpf_declared is set
> bpf_task_from_pid(pid)
> bpf_oom_kill_process(oc, task, msg)
> return 1
> Drop this patch ?

Ah, your suggestion is to have a second bpf_oom_ops program, or second
hook point in the same program, which handles OOM selection by pulling
the first PID from a map.
Then the proactive logic populates the map and declares an OOM on the memcg.
Certainly that would work. It's a little less direct, but probably
more composable / BPF-y.
Good suggestion! I will drop this patch and include such an OOM
handler that is auto-loadable in the next version.

My main worry with that approach is that other BPF OOM handlers loaded
on the system might be invoked instead and terminate a different
process.
I'm not sure we have an easy mechanism to prevent that / ensure the
intended process is selected.
That would be up to the system administrator to prevent.