From nobody Sun Aug 27 22:45:15 2023 X-Original-To: dev-commits-src-branches@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 4RYpg00thRz4rkcL; Sun, 27 Aug 2023 22:45:16 +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 4RYpg00MD1z3Pry; Sun, 27 Aug 2023 22:45:16 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1693176316; 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=kkDBT1h9L0lWiRTN0ynGXJKK01jB51S32/2Ssr8ATRk=; b=J+1JmLb+pNEO5lqxVbmaR1FWgtFThUO0CbHcgXj27+IC8FqhUN47/lIRg8tI58UztacEf1 wW5A2qVWidZ8I80xaNNamDE2PsqF7HKvioEt0xX9ccQhod7Yt1/yaXmUm48P1I2P8Tty8s zJk/BJZml+6tob3mqHoHMVXcjycELMYOSUADiM2hKLeV5r54POAsjZ/jO457JpqabLLLvt xZU7E/iCkjA5sK1526HSkr+ovJ9Is8jDSoohM6JvkXPfPFKg4b11fq4v2xFCxjUyVnc4+S HKM5oaxah3E7r004K0FiKan7JMJieM/yeN3sVFJev8r8uiLBY1cMq8wwls0WyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1693176316; 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=kkDBT1h9L0lWiRTN0ynGXJKK01jB51S32/2Ssr8ATRk=; b=tLeEpss+tx6LneGIMenkiQnrlOSqLfpQURSDfbdilLgXm+ER9E2+BfvcgqD+UPw4g78V5E yqCC52cpKvCcWDYiA55+9kIIK+VCQP4bXyk1Ito4NtBZEJtctxMgIiWN1B8RfkXzdFxpP8 Dn7E8qvols9n1Ok9hoae3jO3sfsf0pFGV8LjRX3xnGmUeEGxNXx2/M7wthGKwFCok3fReB CWOMrJ2BGpg2WpxSCB68vfqSthvAV4K6AdG6d3ebrYV7sU8Zvc076yuQ2S0CLkgQSJ/1Lt pkGMfx76Qvsa3esnpGYvwcwzbg8hxiGcBEYnkqBHZncaCF7JvLrWBoVQabLARQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1693176316; a=rsa-sha256; cv=none; b=RSY9SS5obUQYIgC7dymxHVLtZQdXiFwmyU32K//PcVjt+LCEGHQ7fG4FpBqYoN4XKF74EA GEuxCP2Lrx9O3obXBnQFkRIPKYJ8IVRNHmV4vm8qT22K/uPdrEsjSwe9+Zt2waolUdMuvV PC1faii6ByP0jkApmV3uWZpPD8QyVxzZxyJTrablus5H/RbhwxhXkF3Km9af1NBcL5fUQh PYRIVyUcI1t6MalwrYg1v0PuabaI5d0DPtV2ymJmVCMz7oLTmZemF6aZW9yGTwuovP1ek5 tHuiauJDsYOvHvuzLku+YODgjBXrM/NmZin5t2wMLCmCWDXl2t/ZmmFUt1XRWw== 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 4RYpfz6WJVzl0W; Sun, 27 Aug 2023 22:45:15 +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 37RMjFNv003050; Sun, 27 Aug 2023 22:45:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 37RMjFqw003047; Sun, 27 Aug 2023 22:45:15 GMT (envelope-from git) Date: Sun, 27 Aug 2023 22:45:15 GMT Message-Id: <202308272245.37RMjFqw003047@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: b18ab4f29540 - stable/13 - vfs: trylock vnode requeue List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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/stable/13 X-Git-Reftype: branch X-Git-Commit: b18ab4f2954019f70b5f8cf879e76675f3d4425b Auto-Submitted: auto-generated The branch stable/13 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=b18ab4f2954019f70b5f8cf879e76675f3d4425b commit b18ab4f2954019f70b5f8cf879e76675f3d4425b Author: Mateusz Guzik AuthorDate: 2023-03-21 04:23:15 +0000 Commit: Mateusz Guzik CommitDate: 2023-08-27 22:44:12 +0000 vfs: trylock vnode requeue The quasi-LRU still gets in the way for example when doing an incremental bzImage build, with vnode_list lock being at the top of the profile. Further damage control the problem by trylocking. Note the entire mechanism desperately wants to be reaped out in favor of something(tm) which both scales in a multicore setting and provides sensible replacement policy. With this change everything vfs almost disappears from the on CPU flamegraph, what is left is tons of contention in the VM. (cherry picked from commit 138a5dafba312ff39ce0eefdbe34de95519e600d) --- sys/kern/vfs_subr.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 5cdefca60e7c..c1c474b6724d 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -3533,17 +3533,25 @@ vdbatch_process(struct vdbatch *vd) MPASS(curthread->td_pinned > 0); MPASS(vd->index == VDBATCH_SIZE); - mtx_lock(&vnode_list_mtx); critical_enter(); - for (i = 0; i < VDBATCH_SIZE; i++) { - vp = vd->tab[i]; - TAILQ_REMOVE(&vnode_list, vp, v_vnodelist); - TAILQ_INSERT_TAIL(&vnode_list, vp, v_vnodelist); - MPASS(vp->v_dbatchcpu != NOCPU); - vp->v_dbatchcpu = NOCPU; + if (mtx_trylock(&vnode_list_mtx)) { + for (i = 0; i < VDBATCH_SIZE; i++) { + vp = vd->tab[i]; + vd->tab[i] = NULL; + TAILQ_REMOVE(&vnode_list, vp, v_vnodelist); + TAILQ_INSERT_TAIL(&vnode_list, vp, v_vnodelist); + MPASS(vp->v_dbatchcpu != NOCPU); + vp->v_dbatchcpu = NOCPU; + } + mtx_unlock(&vnode_list_mtx); + } else { + for (i = 0; i < VDBATCH_SIZE; i++) { + vp = vd->tab[i]; + vd->tab[i] = NULL; + MPASS(vp->v_dbatchcpu != NOCPU); + vp->v_dbatchcpu = NOCPU; + } } - mtx_unlock(&vnode_list_mtx); - bzero(vd->tab, sizeof(vd->tab)); vd->index = 0; critical_exit(); }