The branch main has been updated by markj:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=78546fb0e3215c07f970c1bcbf15bba2f5852c76

commit 78546fb0e3215c07f970c1bcbf15bba2f5852c76
Author:     Mark Johnston <ma...@freebsd.org>
AuthorDate: 2025-06-27 13:09:39 +0000
Commit:     Mark Johnston <ma...@freebsd.org>
CommitDate: 2025-06-27 13:14:22 +0000

    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
---
 sys/vm/vm_pageout.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/sys/vm/vm_pageout.c b/sys/vm/vm_pageout.c
index 6d3139e58c5a..b500eb8156bc 100644
--- a/sys/vm/vm_pageout.c
+++ b/sys/vm/vm_pageout.c
@@ -1784,8 +1784,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++;

Reply via email to