From nobody Sat Oct 14 01:08:52 2023 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 4S6ld12lKjz4x4K1; Sat, 14 Oct 2023 01:08:53 +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 4S6ld06Wqnz3Xfx; Sat, 14 Oct 2023 01:08:52 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1697245732; 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=yjVOuLlK1+j/fFniDlE0ZquRSR0kQRbhmrFhq65G5Lw=; b=KcKkzhXYnUPTEiyRCagkwM1Zpo48BQ2woc64DJ+rFKEo54kYWvGYpBhZ/tQpx2TsE0DUT2 t7LvT17UamnT7NpvLnVJqZhh1cBx5fBV7xL0mLcAwUshGZfw+OEUGbounnZ1f4JU8Ubhn9 m0RkN08n1t31zuSikgvzrMW9U6yro1rVhPNn3g5BBp8+7WCG9NB2l67W/xnULPR3npdy8t aGzh5oY0DbXkFAbaosNxKWoiUJQ9J6QnGRrZ/1w9jIZH1W8J5Q2wH3JgsMG5nkLOYUABRe mo8S8VEza9o/8yC6xziEGdtKiGBDlFBTpMT5Ftx4+EDNACmbWRilIknzDzGZ3w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1697245732; a=rsa-sha256; cv=none; b=UfYDu+YBTuk13jfqkyipeYpYQsdMm2V1cS+RiV+d8dz5cg4F6ds44P29TH3zrNWMMsxCX1 /gYZSfyiQa8cJ03ewpENDg8xljFrK5qpiug91+dkzFctcdBJs3iXrZfqGsK3PLfQqgaWaU tYgwAVzRpAOQke3lOVRSRxt+TEUsr8z7IxGxQ5/R99N4Ui9TIJ0Urb20EamlEy5AT4TOHE DrXQSYvGxjh6raATUWxboMIFFS2ECcE330ZPDyOpfbV6NjhSwQhEoWMRYaqwZzGKdged58 K4aLa1YqSzzD+m7gszbVBLDOd9Wtkk9V3bSCMK0I6tAOuWBt1XIYBcyJTV7hhg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1697245732; 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=yjVOuLlK1+j/fFniDlE0ZquRSR0kQRbhmrFhq65G5Lw=; b=U/dTiUt5cN/7vuSLHIBfEnbjlZaMzaUe16b3j6gDqF6D82jTg1LKm51DZ6RvWzKJuWrm1K tSXxlT0gV2EHEP/qrAkMOx0sdEP86fePQsPwRclkAIZJzWpRBbbBcIb8SL1nnb/AL6pk8H 9zmd/8Tlf7nZCsFm0Ysmn/2NPRs0BcU/hF/UkhUNy8AoOY80ZUZmm1rofHS8bakRVq9LcY ODZwTDKHjgdwrNqDPuDGs7uGObeo7885ixLU/bVBdkHFls+CA7eD/7z/BwPDOiAgykCujx P9OEpYGf4WdGfD5HRCbEd8ugG1sBreV1Lz0Bnccf2Q60tNIVdvOGF9wO9OcKag== 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 4S6ld05dTCz19Fm; Sat, 14 Oct 2023 01:08:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 39E18qSe052392; Sat, 14 Oct 2023 01:08:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 39E18qs2052389; Sat, 14 Oct 2023 01:08:52 GMT (envelope-from git) Date: Sat, 14 Oct 2023 01:08:52 GMT Message-Id: <202310140108.39E18qs2052389@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mateusz Guzik Subject: git: 01211b4be09f - releng/14.0 - vfs: consult freevnodes in vnlru_kick_cond 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/releng/14.0 X-Git-Reftype: branch X-Git-Commit: 01211b4be09f6e1838da87339ddb3655702d254b Auto-Submitted: auto-generated The branch releng/14.0 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=01211b4be09f6e1838da87339ddb3655702d254b commit 01211b4be09f6e1838da87339ddb3655702d254b Author: Mateusz Guzik AuthorDate: 2023-10-10 16:19:53 +0000 Commit: Mateusz Guzik CommitDate: 2023-10-14 01:07:26 +0000 vfs: consult freevnodes in vnlru_kick_cond If the count is high enough there is no point trying to produce more. Not going there reduces traffic on the vnode_list mtx. This further shaves total real time in a test mentioned in: 74be676d87745eb7 ("vfs: drop one vnode list lock trip during vnlru free recycle") -- 20 instances of find each creating 1 million vnodes, while total limit is set to 400k. Time goes down from ~41 to ~35 seconds. Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit 23ef25d25d989e7213bc1d3ef32b0f48a9eb2537) (cherry picked from commit 5cf1c99d4c425ab196dfa3bafcf3a5f142eab887) Approved by: re (gjb) --- sys/kern/vfs_subr.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index e7e612254ba2..5e39a149ef36 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -1584,6 +1584,9 @@ static void vnlru_kick_cond(void) { + if (vnlru_read_freevnodes() > wantfreevnodes) + return; + if (vnlruproc_sig) return; mtx_lock(&vnode_list_mtx); @@ -1849,9 +1852,8 @@ vn_alloc_hard(struct mount *mp) } alloc: mtx_assert(&vnode_list_mtx, MA_NOTOWNED); - rnumvnodes = atomic_fetchadd_long(&numvnodes, 1) + 1; - if (vnlru_under(rnumvnodes, vlowat)) - vnlru_kick_cond(); + atomic_add_long(&numvnodes, 1); + vnlru_kick_cond(); return (uma_zalloc_smr(vnode_zone, M_WAITOK)); }