aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2025-06-27 13:09:39 +0000
committerMark Johnston <markj@FreeBSD.org>2025-07-15 13:46:24 +0000
commit025287a38dacfbeaa570f35650396fb016f54c9e (patch)
tree80fe26fc97dca3285478900f14452c9ce61a0691
parentf668b5a413d90084f02f0f2f204c7dbf3563b3a9 (diff)
vm_pageout: Make the OOM killer less aggressive
A problem can arise if we enter a shortfall of clean, inactive pages. The PID controller will attempt to overshoot the reclamation target because repeated scans of the inactive queue are just moving pages to the laundry queue, so inactive queue scans fail to address an instantaneous page shortage. The laundry thread will launder pages and move them back to the head of the inactive queue to be reclaimed, but this does not happen immediately, so the integral term of the PID controller grows and the page daemon tries to reclaim pages in excess of the setpoint. However, the laundry thread will only launder enough pages to meet the shortfall: vm_laundry_target(), which is the same as the setpoint. Oonce the shortfall is addressed by the laundry thread, no more clean pages will appear in the inactive queue, but the page daemon may keep scanning dirty pages due to this overshooting. This can result in a spurious OOM kill. Thus, reset the sequence counter if we observe that there is no instantaneous free page shortage. Reviewed by: alc, kib MFC after: 2 weeks Sponsored by: Klara, Inc. Sponsored by: Modirum MDPay Differential Revision: https://reviews.freebsd.org/D51015 (cherry picked from commit 78546fb0e3215c07f970c1bcbf15bba2f5852c76)
-rw-r--r--sys/vm/vm_pageout.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/sys/vm/vm_pageout.c b/sys/vm/vm_pageout.c
index 83f655eb852e..378fd3b834de 100644
--- a/sys/vm/vm_pageout.c
+++ b/sys/vm/vm_pageout.c
@@ -1821,8 +1821,14 @@ vm_pageout_mightbe_oom(struct vm_domain *vmd, int page_shortage,
{
int old_vote;
+ /*
+ * Do not trigger an OOM kill if the page daemon is able to make
+ * progress, or if there is no instantaneous shortage. The latter case
+ * can happen if the PID controller is still reacting to an acute
+ * shortage, and the inactive queue is full of dirty pages.
+ */
if (starting_page_shortage <= 0 || starting_page_shortage !=
- page_shortage)
+ page_shortage || !vm_paging_needed(vmd, vmd->vmd_free_count))
vmd->vmd_oom_seq = 0;
else
vmd->vmd_oom_seq++;