Re: [LSF/MM/BPF TOPIC] Using BPF in MM

Roman Gushchin
2026-04-28T16:36:27Z

"David Hildenbrand (Arm)" <david@kernel.org> writes:

> On 4/28/26 01:57, Roman Gushchin wrote:
>> [LSF/MM/BPF TOPIC] Using BPF in MM
>> ----------------------------------
>>
>> Over the last decade, BPF successfully penetrated into multiple kernel
>> subsystems: started as a feature to filter (out) networking packets,
>> it captured its place in networking, tracing, security, HID drivers,
>> and scheduling. Memory management is a logical next step, and recently
>> we saw a growing number of proposals in this area.
>>
>> In (approximately) historical order:
>> - BPF OOM
>> - BPF-based memcg stats access (landed)
>> - BPF-based NUMA balancing
>> - eBPF-mm
>> - cache_ext (BPF Page Cache)
>> - memcg_ext
>
> There was also the BPF THP control.

Thanks, missed that.

>
>>
>> There are some obvious target which haven't been covered yet:
>> - BPF-driven readahead control
>> - BPF-driven KSM
>> - BPF-driven guest memory control
>>
>> Despite a large number of suggestions only a relatively small feature
>> (query memcg statistics from BPF) made it to upstream.
>>
>> It looks like using BPF in the MM subsystem comes with a set of somewhat
>> unique challenges and questions to be answered.
>
> [...]
>
> I think you are missing one of the most important points: Unclear ABI stability
> guarantees.

Totally agree, it's just not specific to mm and is not very new.
Arguments about the ABI stability are almost as old as BPF itself, e.g.
a quick search gave me a lwn article from 2019:
https://lwn.net/Articles/787856/ .

>
> One the one hand, we are told that there are no ABI stability guarantees, and
> that we can change hooks (add/remove/modify) any time we want.
>
> On the other hand, as soon as there is some ebpf program out there that we
> break, you can rest assured that there will be trouble.
>
> In the area of THP, where we don't even know which hooks we will need long term
> and how they would look like, that was one of the reasons why the BPF THP
> control was rejected.

Agree. And in my mind it's also related to safety/performance tradeoff:
if we use very generic hooks/interfaces, it's easier to keep them stable
and meaningful, but then it's hard to guarantee safety without
performance sacrifices. Or we use very targeted policy hooks, then it's
much easier to make them safe and performant, but they may become
obsolete very quickly.