[$] Out-of-memory victim selection with BPF

Post Syndicated from corbet original https://lwn.net/Articles/941614/

In its default configuration, the Linux kernel will allow processes to
allocate more memory than the system can actually provide; this policy
enables better utilization of physical memory and works just fine — most of
the time. On occasions, though, the kernel may find itself unable to
provide memory that processes may think already belongs to them. If the
situation gets bad enough, the only solution (short of rebooting) is to
declare a sort of memory bankruptcy and write off some of the kernel’s
debts by killing one or more processes. Over the years, a great deal of
effort has gone into heuristics to select the processes that the user is
least likely to miss. This problem is still clearly not solved to
everybody’s satisfaction, though, so it was only a matter of time before
somebody introduced a way to select the out-of-memory (OOM) victim using
BPF.