]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
vm_fault: do not trigger OOM too early
authorKonstantin Belousov <kib@FreeBSD.org>
Mon, 4 Oct 2021 06:36:02 +0000 (09:36 +0300)
committerKonstantin Belousov <kib@FreeBSD.org>
Fri, 8 Oct 2021 09:24:46 +0000 (12:24 +0300)
commit174aad047e12e8f30f9a5919ca1c08919441a217
tree0d2cde193c75c827f62efd3465174a7ac6a97c37
parent7e64580b5f477ba4523799f26d1178f611f5d6cb
vm_fault: do not trigger OOM too early

Wakeup in vm_waitpfault() does not mean that the thread would get the
page on the next vm_page_alloc() call, other thread might steal the free
page we were waiting for. On the other hand, this wakeup might come much
earlier than just vm_pfault_oom_wait seconds, if the rate of the page
reclamation is high enough.

If wakeups come fast and we loose the allocation race enough times, OOM
could be undeservably triggered much earlier than vm_pfault_oom_attempts
x vm_pfault_oom_wait seconds.  Fix it by not counting the number of sleeps,
but measuring the time to th first allocation failure, and triggering OOM
when it was older than oom_attempts x oom_wait seconds.

Reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D32287
sys/vm/vm_fault.c