From owner-dev-commits-src-main@freebsd.org Tue Sep 28 18:24:07 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 860C06A99DC; Tue, 28 Sep 2021 18:24:07 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HJnvq3Fynz4dXJ; Tue, 28 Sep 2021 18:24:07 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 513CA1615; Tue, 28 Sep 2021 18:24:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 18SIO79U055998; Tue, 28 Sep 2021 18:24:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 18SIO7mY055997; Tue, 28 Sep 2021 18:24:07 GMT (envelope-from git) Date: Tue, 28 Sep 2021 18:24:07 GMT Message-Id: <202109281824.18SIO7mY055997@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Smirnoff Subject: git: 183f8e1e575b - main - Externalize nsw_cluster_max and initialize it early. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: glebius X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 183f8e1e575b526515e70400a22af243cd1a4a78 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 Sep 2021 18:24:07 -0000 The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=183f8e1e575b526515e70400a22af243cd1a4a78 commit 183f8e1e575b526515e70400a22af243cd1a4a78 Author: Gleb Smirnoff AuthorDate: 2021-09-28 18:13:33 +0000 Commit: Gleb Smirnoff CommitDate: 2021-09-28 18:23:52 +0000 Externalize nsw_cluster_max and initialize it early. GEOM_ELI needs to know the value, cause it will soon have special memory handling for IO operations associated with swap. Move initialization to swap_pager_init(), which is executed at SI_SUB_VM, unlike swap_pager_swap_init(), which would be executed only when a swap is configured. GEOM_ELI might need the value at SI_SUB_DRIVERS, when disks are tasted by GEOM. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D24400 --- sys/vm/swap_pager.c | 20 +++++++++++++------- sys/vm/swap_pager.h | 1 + 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/sys/vm/swap_pager.c b/sys/vm/swap_pager.c index 08a5ead438ba..9bc506c9b6b8 100644 --- a/sys/vm/swap_pager.c +++ b/sys/vm/swap_pager.c @@ -383,7 +383,7 @@ static int swap_pager_almost_full = 1; /* swap space exhaustion (w/hysteresis)*/ static struct mtx swbuf_mtx; /* to sync nsw_wcount_async */ static int nsw_wcount_async; /* limit async write buffers */ static int nsw_wcount_async_max;/* assigned maximum */ -static int nsw_cluster_max; /* maximum VOP I/O allowed */ +int nsw_cluster_max; /* maximum VOP I/O allowed */ static int sysctl_swap_async_max(SYSCTL_HANDLER_ARGS); SYSCTL_PROC(_vm, OID_AUTO, swap_async_max, CTLTYPE_INT | CTLFLAG_RW | @@ -572,6 +572,16 @@ swap_pager_init(void) mtx_init(&sw_dev_mtx, "swapdev", NULL, MTX_DEF); sx_init(&sw_alloc_sx, "swspsx"); sx_init(&swdev_syscall_lock, "swsysc"); + + /* + * The nsw_cluster_max is constrained by the bp->b_pages[] + * array, which has maxphys / PAGE_SIZE entries, and our locally + * defined MAX_PAGEOUT_CLUSTER. Also be aware that swap ops are + * constrained by the swap device interleave stripe size. + * + * Initialized early so that GEOM_ELI can see it. + */ + nsw_cluster_max = min(maxphys / PAGE_SIZE, MAX_PAGEOUT_CLUSTER); } /* @@ -591,11 +601,6 @@ swap_pager_swap_init(void) * initialize workable values (0 will work for hysteresis * but it isn't very efficient). * - * The nsw_cluster_max is constrained by the bp->b_pages[] - * array, which has maxphys / PAGE_SIZE entries, and our locally - * defined MAX_PAGEOUT_CLUSTER. Also be aware that swap ops are - * constrained by the swap device interleave stripe size. - * * Currently we hardwire nsw_wcount_async to 4. This limit is * designed to prevent other I/O from having high latencies due to * our pageout I/O. The value 4 works well for one or two active swap @@ -606,8 +611,9 @@ swap_pager_swap_init(void) * at least 2 per swap devices, and 4 is a pretty good value if you * have one NFS swap device due to the command/ack latency over NFS. * So it all works out pretty well. + * + * nsw_cluster_max is initialized in swap_pager_init(). */ - nsw_cluster_max = min(maxphys / PAGE_SIZE, MAX_PAGEOUT_CLUSTER); nsw_wcount_async = 4; nsw_wcount_async_max = nsw_wcount_async; diff --git a/sys/vm/swap_pager.h b/sys/vm/swap_pager.h index 6761d4f99ee4..20b9bc95b1b2 100644 --- a/sys/vm/swap_pager.h +++ b/sys/vm/swap_pager.h @@ -71,6 +71,7 @@ struct swdevt { #ifdef _KERNEL extern int swap_pager_avail; +extern int nsw_cluster_max; struct xswdev; int swap_dev_info(int name, struct xswdev *xs, char *devname, size_t len);