From nobody Tue Oct 10 16:29:50 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 4S4hFV3NDxz4x0MC; Tue, 10 Oct 2023 16:29:50 +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 4S4hFV2Z9Hz4bSd; Tue, 10 Oct 2023 16:29:50 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1696955390; 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=ungjfCdO/c1+cC6WhP6oCa7vOZirHANLOcN2kySp4CY=; b=mK78woIj9sO8NXN+g2zkkxfr2Efe6EGU1yGdO/tx8v1tag8JkotnaulbfTYyNAwdXoKWpJ PJvLJ1O/bXU5ALTzbCLuXlldA+2gc82gKwrkM6puEwvk2fl2nvLf18KFUZVjv4x+0YMJdq 40AlqwcB/iCC9IGUruqxmu7/DEhk5qvJSjYOY4JprdXGJKH+S7czqtMrzoaHNvDILWLZcK eOoRtsksBjxgr4LI6PvxDqAM38D7lm/yBi1XGDm8uILT1UxgIqnkMyOdbtP/GssuvlM+R3 m+Qb99llf1NcUWVhYLT/R+pqYtpMDygBAqL9LknnD4exgftfJOMbJsufqteN5A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1696955390; a=rsa-sha256; cv=none; b=MqSLaepqXj5hSfM4wio0tsZrjD8tIJYBtee5xAIKTldzwWK6xtSTRZ2uFKxeWtgAGy9l2X opUmsja8eIEaBz6QZRe723jqeoQwkT/x++xcqTltwpikQBvN9ZDVRg0mwtTiJwgEftDGYH BkSUjfg5cL102eM7bYf26iJHOnUow/1IFdppVahaAvlRE2kasPIbtfPi12kGQK2Pj+Zmqw wSYnnNfweIa7pfZ0ZL1pwxiIPRYta2+P45lA6uchPSMe4889h+63DJ3yB5RnlZ0P1/BCGg hPVf7qwSsflRIK4hRntAm2mUg8fMQ7oObKO0Y/b6qaHlVM0HVm7UP2PYdeIagA== 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=1696955390; 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=ungjfCdO/c1+cC6WhP6oCa7vOZirHANLOcN2kySp4CY=; b=rrNbkX5whjolP2TW5zubzYbVZuwRCrG/l9gjweycXNra945TKh/Qr3bth8R3Dne5EZ78/C R+rwUHqiEOsClSjy+u60YURt00Iikl2NagA7aMLP5fqevdWqvFegrbSltGJrsbyVKzw/tH Bcw5GMpCqREhvUFJdOqiWbNsK2wDJBu0VBL9YMCgVlIaM3bjTBegqWXOp6WfKLwyWD4R2J eSkKtZaZ+0ZUAwywoqM++0K8Ogo5NSZW5v9R2WWNhbPFth1I/smbmkPRJjtMnPLRo5yzZt x69c9vHXwg4415UKJBOxy5DBv110Ykh3sJA0XsFmp3Sj2uhokPCZ1WxFrc6cXQ== 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 4S4hFV1b8rzlxL; Tue, 10 Oct 2023 16:29:50 +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 39AGTogI088307; Tue, 10 Oct 2023 16:29:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 39AGToN7088304; Tue, 10 Oct 2023 16:29:50 GMT (envelope-from git) Date: Tue, 10 Oct 2023 16:29:50 GMT Message-Id: <202310101629.39AGToN7088304@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: 23ef25d25d98 - main - 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/main X-Git-Reftype: branch X-Git-Commit: 23ef25d25d989e7213bc1d3ef32b0f48a9eb2537 Auto-Submitted: auto-generated The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=23ef25d25d989e7213bc1d3ef32b0f48a9eb2537 commit 23ef25d25d989e7213bc1d3ef32b0f48a9eb2537 Author: Mateusz Guzik AuthorDate: 2023-10-10 16:19:53 +0000 Commit: Mateusz Guzik CommitDate: 2023-10-10 16:19:53 +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") --- 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)); }