From nobody Thu Jan 23 13:58:53 2025 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Yf2by0kQsz5l042; Thu, 23 Jan 2025 13:58:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Yf2bx54Rhz3byc; Thu, 23 Jan 2025 13:58:53 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1737640733; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=VBRzkyQHKUcDaon1Zk6IwjLy4ZMjiKkWYySWWY7XmSw=; b=sVza74/3yoSAakqirQXl10UPpJuYKIb6QCSR96Lwzk9SgZRYKoY0YbdRuiw1zfjtxTqTrr 7ycymXx8w/ZpFmlFOO65SiTMGQZrRjKrs0oZS63I0NsHWouinj9tCCiK9pmpTmr7uPHjA/ jM3dktRW9vJ5tcoYH/wffPIl4cKxyc89WVSRTlLKz+L6DtmL9q6N+OER4eyhJfslmNOI50 zqWjPUlaN5yJ10b+pJ/hyH362TVdpQ0t4vnop/VIVKZvvdQfliva1cVOPa1UaSX/PSLeCA Pxx2GMRVLjPwvcuj6GBpwyaKJ5zzwOJcDz6zedVxaVedxJ9K+V0UhAanP+vWuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1737640733; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=VBRzkyQHKUcDaon1Zk6IwjLy4ZMjiKkWYySWWY7XmSw=; b=QYHFXHpFdcfgKTxAHWj8HtVdCBfCZogCUaTRhPJgcM4GrGkVV2bShDLFEiUSL2HFSX/a8L Ea/W/KkAh7QAvJxokkJ/kVejfuVfJrNh26SLil75kDPnpW8Wl/6xR+q9SsOJ+qlA3t5SVM cETqzXcw0gUgN8m+vLIx5XafEE6XZy5/QRpnBcmr0ires/+dL/JvoW17oVEFZahEyd5pZT z0N2qz51rWpoOfU4BLIx77WJoK3Qq1Ih+z7NOumyzZBJ22Xw1CJ+ov4EftLYesBVJ1YP76 GV+uEtBh8nLX2fKpO4swctxnKONhjgbP5SWKyL37hMqqpxTKoX1jDB5EBCul2w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1737640733; a=rsa-sha256; cv=none; b=U48Il/OJeS2Id1D5R9Rq51KrrvIcbNihecC6S24zvi9PKo+vPNGB4w7XZ+qn7bVUBAac8M HF3VoP2xyueMx1Ar3sxuQyXbYTmk/Kt2RMU0l59aKzfx6Ytasfdmu5ovbuUy9gSdY88kpp nyZH9xusIA1hq7ObDT3PJFOhh2FINojmKWIujouTZ9C+FlwXJj4uekIE8aXTTHxTSR2mjH Go0IHcHVJ4ltRVUODQ7NXce+/YW+58PdD3B01988fvY5QbzR/DcEJBqqhVueogjaiyh7lf V9b473RHu9mO6yR7O4RH6nI1FX0KC9wZvbiqcIojF8DtQSLTQ6tk24C0JeJz+g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Yf2bx4TTjzjBt; Thu, 23 Jan 2025 13:58:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 50NDwr50026268; Thu, 23 Jan 2025 13:58:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 50NDwrVr026265; Thu, 23 Jan 2025 13:58:53 GMT (envelope-from git) Date: Thu, 23 Jan 2025 13:58:53 GMT Message-Id: <202501231358.50NDwrVr026265@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 67e54a07e948 - stable/14 - vm_pageout: Add a chicken switch for multithreaded PQ_INACTIVE scanning List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 67e54a07e948d99f97322a9933a438f5c64caf3d Auto-Submitted: auto-generated The branch stable/14 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=67e54a07e948d99f97322a9933a438f5c64caf3d commit 67e54a07e948d99f97322a9933a438f5c64caf3d Author: Mark Johnston AuthorDate: 2025-01-09 14:54:10 +0000 Commit: Mark Johnston 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. */