From nobody Thu Mar 10 09:42:18 2022 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 1ED401A0FFE6; Thu, 10 Mar 2022 09:42:19 +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 4KDkcV6x88z4j34; Thu, 10 Mar 2022 09:42:18 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1646905339; 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=rZ3w/TVqhH9JeSzS9G01bY/Va+7w7ZswW1l/ymqjYds=; b=BQ+Xg19fegIhhiWytrAuw37bkBxliyB4P/5SfcBw1wctQY+WBz/W5x4B98gP4aUo3xyCYz ZB9JJIBPvxDPZ1OAc/OSNErVpe9kbU3NXC2p48bpfVh2G0I+2kxu7TyblbdyB5uImD9cG2 aYiKLfZfZ9a9b/5MqW3SH3qCLROfJ/giBJTRxIeS5BlMKFL/clx+IFcKgy7siZokDpehJb X0XHND8nw8DNe4r9Z0O952aVoH64hnyzu5qyxjBZ9McplS3TWao8VNY+eyfT2YWfJy3PFW NP9DDcsuQ9R6cPy6H1LtYTq0CMiWatce1uq5ESoQt5joi75qwn8tp2N5S+pu/w== 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 CCABE228FA; Thu, 10 Mar 2022 09:42:18 +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 22A9gIig095977; Thu, 10 Mar 2022 09:42:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 22A9gIoG095976; Thu, 10 Mar 2022 09:42:18 GMT (envelope-from git) Date: Thu, 10 Mar 2022 09:42:18 GMT Message-Id: <202203100942.22A9gIoG095976@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: 3a4c5dab9266 - main - vfs: [2/2] fix stalls in vnode reclaim by only counting attempts 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: 3a4c5dab9266fac93a5cb22c7cee3938466aedea Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1646905339; 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=rZ3w/TVqhH9JeSzS9G01bY/Va+7w7ZswW1l/ymqjYds=; b=McrEDF+buZh9hKngCncqMjxW+eIOcHb79xd/Cw5KR1BZCMfwcSuSYW+RP5qVZSbND4unky 3I58q8nS/T1PNSZF3GQWIB84nFRXsBeWb7wlgr1sdvHKDBEKEwTGRx3KNypLssMrzZIY1H RrNIPpDhk/zNxbBCiAdy+G/7StGbuqa3dTMykctKLxKHBrqTeuoCuFPZN4tYezY5wUY4Rj 3huUGR29hvabj+32o8QQQ8t6kRsnkChJdxSv2h3P5kb68fkSUEQtohGWzpwkq37kqUoYF6 IlThtpcDmg7Cex7WxTwsOapE2aUcIg+CkluppDUWph5yc0rL4bA6mqaoivyntA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1646905339; a=rsa-sha256; cv=none; b=QU0QixG7taO19W0Vo59s+pLUPjL12oUGwOyFemD8GSgb2D/xYNsnhp1N4NN3wSA8Vjuz+K GhC26huyVlwD5hlEkdefIoOhWjOn6IlXtIa37vhFbqm7awTNUhE57i3c78JdpxTIRQZx9p kNCVB7Nt+FM3Pn/cMT71FuV/0sW03Yb+ClLR+SF7IsuhhHoMHcZBotbHw3YGP0TYD3V7F/ rNq+5SlXeJdF7TM3+UCgsRYXXb+5ks3SuHRgOp6N6rd0haXl/DhYZAij15B0SFk25uR67p XNu5BJSp4VIU/hM+jwW0A7VeX4vLNJYVGbTtQ+N97KJIM7U/g89N7zCR7SMJZw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=3a4c5dab9266fac93a5cb22c7cee3938466aedea commit 3a4c5dab9266fac93a5cb22c7cee3938466aedea Author: Mateusz Guzik AuthorDate: 2022-03-07 10:38:17 +0000 Commit: Mateusz Guzik CommitDate: 2022-03-10 09:41:50 +0000 vfs: [2/2] fix stalls in vnode reclaim by only counting attempts ... and ignoring if they succeded, which matches historical behavior. Reported by: pho --- sys/kern/vfs_subr.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 436323873f7f..c184530bbda6 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -1311,8 +1311,29 @@ vnlru_free_impl(int count, struct vfsops *mnt_op, struct vnode *mvp) TAILQ_REMOVE(&vnode_list, mvp, v_vnodelist); TAILQ_INSERT_AFTER(&vnode_list, vp, mvp, v_vnodelist); mtx_unlock(&vnode_list_mtx); - if (vtryrecycle(vp) == 0) - count--; + /* + * FIXME: ignores the return value, meaning it may be nothing + * got recycled but it claims otherwise to the caller. + * + * Originally the value started being ignored in 2005 with + * 114a1006a8204aa156e1f9ad6476cdff89cada7f . + * + * Respecting the value can run into significant stalls if most + * vnodes belong to one file system and it has writes + * suspended. In presence of many threads and millions of + * vnodes they keep contending on the vnode_list_mtx lock only + * to find vnodes they can't recycle. + * + * The solution would be to pre-check if the vnode is likely to + * be recycle-able, but it needs to happen with the + * vnode_list_mtx lock held. This runs into a problem where + * VOP_GETWRITEMOUNT (currently needed to find out about if + * writes are frozen) can take locks which LOR against it. + * + * Check nullfs for one example (null_getwritemount). + */ + vtryrecycle(vp); + count--; mtx_lock(&vnode_list_mtx); vp = mvp; }