The branch stable/14 has been updated by markj:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=67e54a07e948d99f97322a9933a438f5c64caf3d

commit 67e54a07e948d99f97322a9933a438f5c64caf3d
Author:     Mark Johnston <ma...@freebsd.org>
AuthorDate: 2025-01-09 14:54:10 +0000
Commit:     Mark Johnston <ma...@freebsd.org>
CommitDate: 2025-01-23 13:58:07 +0000

    vm_pageout: Add a chicken switch for multithreaded PQ_INACTIVE scanning
    
    Right now we have the vm.pageout_cpus_per_thread tunable which controls
    the number of threads to start up per CPU per NUMA domain, but after
    booting, it's not possible to disable multi-threaded scanning.
    
    There is at least one workload where this mechanism doesn't work well;
    let's make it possible to disable it without a reboot, to simplify
    troubleshooting.
    
    Reviewed by:    dougm, kib
    MFC after:      2 weeks
    Sponsored by:   Klara, Inc.
    Sponsored by:   Modirum MDPay
    Differential Revision:  https://reviews.freebsd.org/D48377
    
    (cherry picked from commit 55b343f4f9bc586eba5e26a2524a35f04dd60c65)
---
 sys/vm/vm_page.c      | 1 +
 sys/vm/vm_pageout.c   | 9 +++++++--
 sys/vm/vm_pagequeue.h | 5 +++--
 3 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c
index 2facdca9bf27..7eebf30e19a7 100644
--- a/sys/vm/vm_page.c
+++ b/sys/vm/vm_page.c
@@ -460,6 +460,7 @@ vm_page_domain_init(int domain)
        vmd->vmd_free_count = 0;
        vmd->vmd_segs = 0;
        vmd->vmd_oom = false;
+       vmd->vmd_helper_threads_enabled = true;
        for (i = 0; i < PQ_COUNT; i++) {
                pq = &vmd->vmd_pagequeues[i];
                TAILQ_INIT(&pq->pq_pl);
diff --git a/sys/vm/vm_pageout.c b/sys/vm/vm_pageout.c
index 3b07af2c76d4..bc946e2bb844 100644
--- a/sys/vm/vm_pageout.c
+++ b/sys/vm/vm_pageout.c
@@ -1657,8 +1657,9 @@ vm_pageout_inactive_dispatch(struct vm_domain *vmd, int 
shortage)
         * If we have more work than we can do in a quarter of our interval, we
         * fire off multiple threads to process it.
         */
-       threads = vmd->vmd_inactive_threads;
-       if (threads > 1 && vmd->vmd_inactive_pps != 0 &&
+       if ((threads = vmd->vmd_inactive_threads) > 1 &&
+           vmd->vmd_helper_threads_enabled &&
+           vmd->vmd_inactive_pps != 0 &&
            shortage > vmd->vmd_inactive_pps / VM_INACT_SCAN_RATE / 4) {
                vmd->vmd_inactive_shortage /= threads;
                slop = shortage % threads;
@@ -2295,6 +2296,10 @@ vm_pageout_init_domain(int domain)
        pidctrl_init_sysctl(&vmd->vmd_pid, SYSCTL_CHILDREN(oid));
 
        vmd->vmd_inactive_threads = get_pageout_threads_per_domain(vmd);
+       SYSCTL_ADD_BOOL(NULL, SYSCTL_CHILDREN(vmd->vmd_oid), OID_AUTO,
+           "pageout_helper_threads_enabled", CTLFLAG_RWTUN,
+           &vmd->vmd_helper_threads_enabled, 0,
+           "Enable multi-threaded inactive queue scanning");
 }
 
 static void
diff --git a/sys/vm/vm_pagequeue.h b/sys/vm/vm_pagequeue.h
index 1f1f818d3ec3..70122fef9fff 100644
--- a/sys/vm/vm_pagequeue.h
+++ b/sys/vm/vm_pagequeue.h
@@ -254,8 +254,9 @@ struct vm_domain {
 
        /* Paging control variables, used within single threaded page daemon. */
        struct pidctrl vmd_pid;         /* Pageout controller. */
-       bool vmd_oom;
-       u_int vmd_inactive_threads;
+       bool vmd_oom;                   /* An OOM kill was requested. */
+       bool vmd_helper_threads_enabled;/* Use multiple threads to scan. */
+       u_int vmd_inactive_threads;     /* Number of extra helper threads. */
        u_int vmd_inactive_shortage;            /* Per-thread shortage. */
        blockcount_t vmd_inactive_running;      /* Number of inactive threads. 
*/
        blockcount_t vmd_inactive_starting;     /* Number of threads started. */

Reply via email to