From nobody Thu Jan 09 14:56:20 2025 X-Original-To: dev-commits-src-main@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 4YTSXj1WJ8z5kx8M; Thu, 09 Jan 2025 14:56:21 +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 4YTSXj0PfKz48cf; Thu, 9 Jan 2025 14:56:21 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1736434581; 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=Q5CIb5uxew8TxEcYYekukF7dCTwbtBtGMXHc58Mo/UI=; b=x+xIf6yMFwMPzSBkyxRcKpWJkcrQ+tfpA7zuehQ4P402e2Gg/doSCaMmsTqE83v0epcS6Q yh/dGKr35OUrSUoNlUChTrVyE8Sx3GnwNIINlfAZmYFTTlpuEhUxGzlMMVDX+WDqMwQrKr CWA9ovZdJBrOalte/ikQSI5gsFKWYEg4+2qozLO6bJTeKNW2ZnlJ2zSM/pfMRmZlZq04AF HKU0T5rZmPjtPJPlMhy7W/f2oIPzLSfzrCfcOZDX4r5iLO/9u9CCbJD/kV55/X+8RcuEyC 6Z0vcxD0RI7h4BBBkCWKKUvw6eeY13rx7d9m6+4SnEKC6V0KHNE/QJ/jPTnzQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1736434581; 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=Q5CIb5uxew8TxEcYYekukF7dCTwbtBtGMXHc58Mo/UI=; b=PkOXzUvgvSQXxqXeXxeDxCbiJjSFZdNYSpDwj8pgfiVFECBUPTAoLAqqu4tFuZLZZ7eOpn zq65wpb/aqTOvqTyH/ItlnPGy0Qu17f4ByMATF/GBF4y9oZTpUNgAA0wk1YQznNeE0FnAz aYBlTeWPayVxN1s3WM8xwNXQ+NVtXLC0uP/65sWl9GJD4gAsk0omGfdAxIT0++PbWFLB7h mmUoDoYZEgMBVUHDx/VurAaBHew/PLW3wcpGtp6JU6Z5oq4i5LVhxqOEHRhpc3YNHxGfox fGOTYAzb1x+rj9jDy0yQ0wM719ty02fqB/yyHeFh+2pMunl2MaBuZUYxgXSuyg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1736434581; a=rsa-sha256; cv=none; b=WQDl7MezmStUyxuv9qLJ6uTVIW7Xnd3kx54EK3zclX0XGmMnkcGe68qpgWP5612zcLeQjD AzVHboLdiAoTv94SqFryhvErtHWc/bt1xJL0wH/U3/3r93A8b9sBcJIBq/hH/rKR6N2Kah WTYtzZsKHlGchncnY/S9BWes4wH8ijqsRIj44rFDAIBzHHNsLL0BYaQdOccR5bDjvigivo HdAhv2T5bmj55H2A3TmwhGMAKWQGm7fBJ1js5lcsUB0L5MEaZZgH6D1kASbZY2UdwIOe6M fpYaytw8VA+q6Yuhr1BiOPYJ+K70WgK8LGshzL4t0X6r67B3I0nBkNawECothw== 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 4YTSXh74pVzVb0; Thu, 09 Jan 2025 14:56:20 +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 509EuKLd047221; Thu, 9 Jan 2025 14:56:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 509EuKPv047218; Thu, 9 Jan 2025 14:56:20 GMT (envelope-from git) Date: Thu, 9 Jan 2025 14:56:20 GMT Message-Id: <202501091456.509EuKPv047218@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 55b343f4f9bc - main - vm_pageout: Add a chicken switch for multithreaded PQ_INACTIVE scanning List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: 55b343f4f9bc586eba5e26a2524a35f04dd60c65 Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=55b343f4f9bc586eba5e26a2524a35f04dd60c65 commit 55b343f4f9bc586eba5e26a2524a35f04dd60c65 Author: Mark Johnston AuthorDate: 2025-01-09 14:54:10 +0000 Commit: Mark Johnston CommitDate: 2025-01-09 14:54:10 +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 --- 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 f042d4767b36..ba22c7f97f2f 100644 --- a/sys/vm/vm_page.c +++ b/sys/vm/vm_page.c @@ -461,6 +461,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 d26e04f60c00..e2efa11842b5 100644 --- a/sys/vm/vm_pageout.c +++ b/sys/vm/vm_pageout.c @@ -1644,8 +1644,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; @@ -2269,6 +2270,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 23a3ea96d80c..72fd1bb47318 100644 --- a/sys/vm/vm_pagequeue.h +++ b/sys/vm/vm_pagequeue.h @@ -257,8 +257,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. */