Re: [RFC PATCH] mm, oom: introduce vm.sacrifice_hugepage_on_oom

From: David Hildenbrand
Date: Wed Feb 17 2021 - 04:11:58 EST


On 16.02.21 04:07, Eiichi Tsukata wrote:
Hugepages can be preallocated to avoid unpredictable allocation latency.
If we run into 4k page shortage, the kernel can trigger OOM even though
there were free hugepages. When OOM is triggered by user address page
fault handler, we can use oom notifier to free hugepages in user space
but if it's triggered by memory allocation for kernel, there is no way
to synchronously handle it in user space.

This patch introduces a new sysctl vm.sacrifice_hugepage_on_oom. If
enabled, it first tries to free a hugepage if available before invoking
the oom-killer. The default value is disabled not to change the current
behavior.

In addition to the other comments, some more thoughts:

What if you're low on kernel memory but you end up freeing huge pages residing in ZONE_MOVABLE? IOW, this is not zone aware.

--
Thanks,

David / dhildenb