From nobody Sat Mar 25 13:42:34 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 4PkKyM1125z41BxS; Sat, 25 Mar 2023 13:42:35 +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 4PkKyL63KDz3vsZ; Sat, 25 Mar 2023 13:42:34 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1679751754; 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=MCqqUbdf6Ivmn/zGLGokOXPcGQcrH5v2V4pSblFuB/4=; b=hhGl+EMjrj11PXg3c3A6XsXU+OPZLgnVxAqB6Hdt69GHa1kqZv4byHWcNFoMNau+vcfWKT sD8asRGZg+YMk/3RL0V2aCheVqmj9WX3LhzFfUdtWbpQDX+bSF0nlOYyXnDVQOBmFhKqRi jQT6NuXfB4ARkDnHwcUBPJU9Bpe28+tuut8O4zqw/Y7mHYxVW3/6RSQCSL3z5OsK/QbuYC rOfqKLQ0oJG6ZtcmwSE64g30IfokdGVqFRZwAzW1bMa0jqo8jRigzm19Zn7xIdwlMDi7bH 4mfoMvn/NnE13j/5veMU0UjdlvTHfvZjhZBLnWyPX5OLKd7bHGMnIlKTRLz65w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1679751754; 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=MCqqUbdf6Ivmn/zGLGokOXPcGQcrH5v2V4pSblFuB/4=; b=F3TTp0E6zDBdwD2BgjhyI4ave+lJGXAeesFooQY4nqglizwURWAiSf0HLlZB1316ey8Yos zkuO1KJdvYD2Kcq/DI+o3uSkD1eYIii3AYMRKL8mHggmYjC+3C7t2PTwInk8V3NXlADsBX bTOITHSYdjGIfo5WS6xEcOrMdIT4bTM7830GHCwqrznnErXPaIM7PPvgg+aNd6A9cuLP8K SmXB3ZuE0/ClqiYpl6Xer66NKZ4SBxvtaVylzKt2RkChSXoDYyF9f3y0z6GsQi6EMJTFTs QJaDHb08Ys07FS/oYwhkjpnLFC3+UeiXk+VASOVZJr/fdCi4/pF25HELRbNA4Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1679751754; a=rsa-sha256; cv=none; b=u7Y0iSSM/3I2j/KFkWU7iS/hdv58MTfNP+2gm5GuYlGnQ+Md0OJa9GYXZfvEh/WQPr1WpB uBOydN99EH1KnVx2zwuvrYwuXok6KUcscNnoBQuE6dG5b02UHwwfmKtvUaRRBW1YEgKHdm 4NNjs56oXksBSVngQCnKSgokBt3z1N02rE6l+Za4rSD1M+1U3az8+JeAhi19eyUk49IWev SpnBmK4yoGqy6FI4UhBNwQLOHb3GlGaNB2CEN5+aTHlhFcP7jwYS5rJXW7e9mDdCVgbThP omCQ5sNNu1XmghX89DKYcfdsXjn6fwZmTLWS9XjNeno5tfHsWHyTMrzoTQC0ng== 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 4PkKyL5272z11wQ; Sat, 25 Mar 2023 13:42:34 +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 32PDgYNS048576; Sat, 25 Mar 2023 13:42:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 32PDgYrM048575; Sat, 25 Mar 2023 13:42:34 GMT (envelope-from git) Date: Sat, 25 Mar 2023 13:42:34 GMT Message-Id: <202303251342.32PDgYrM048575@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: 138a5dafba31 - main - vfs: trylock vnode requeue 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: 138a5dafba312ff39ce0eefdbe34de95519e600d Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=138a5dafba312ff39ce0eefdbe34de95519e600d commit 138a5dafba312ff39ce0eefdbe34de95519e600d Author: Mateusz Guzik AuthorDate: 2023-03-21 04:23:15 +0000 Commit: Mateusz Guzik CommitDate: 2023-03-25 13:42:27 +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. --- 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 72be478e310d..48aea3b6c8ff 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -3521,17 +3521,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(); }