Page MenuHomeFreeBSD

vm_fault: do not trigger OOM too early
ClosedPublic

Authored by kib on Oct 4 2021, 6:43 AM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Apr 12, 7:54 PM
Unknown Object (File)
Mar 2 2024, 4:40 PM
Unknown Object (File)
Feb 19 2024, 10:10 PM
Unknown Object (File)
Feb 12 2024, 1:05 AM
Unknown Object (File)
Jan 12 2024, 8:38 AM
Unknown Object (File)
Dec 20 2023, 3:28 AM
Unknown Object (File)
Nov 28 2023, 9:32 PM
Unknown Object (File)
Sep 2 2023, 2:53 PM
Subscribers

Details

Summary
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.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kib requested review of this revision.Oct 4 2021, 6:43 AM
kib created this revision.
sys/vm/vm_fault.c
128–129

oom_start_time would be a better name, IMO. first_tick sounds like a ticks value.

1585

Suppose fs.oom_started is true here, i.e., the faulting thread slept for some time but allocated a page before triggering an OOM kill. Shouldn't we reset OOM state before trying the allocation here?

kib marked an inline comment as done.Oct 4 2021, 3:31 PM
kib added inline comments.
sys/vm/vm_fault.c
1585

Don't we reset oom_started (it was oom counter before this patch) at line 1176?

This revision is now accepted and ready to land.Oct 4 2021, 3:44 PM
This revision was automatically updated to reflect the committed changes.