From nobody Tue Mar 15 21:15:35 2022 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 9E2C11A24D34; Tue, 15 Mar 2022 21:15:36 +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 4KJ5m82rGsz3JnR; Tue, 15 Mar 2022 21:15:36 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1647378936; 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=VuUAeiU5Tfzw/+j87eXsQ0R1Te4X0yJDIIfP+4fo9X8=; b=hzoxJNOXmQIVM8qP72ZerZFPslkHBLV1m8eXMXrWszqOgq+4OmjTk9OjzYEprfVRjuTT2O qSCWKrUxe2G4Eju2iBVgUMR0NmtLzm8X/IuLQ8wj6j2rJOfyFFCT1GRhIvwZfZokzwfCpx wlrW6ruy83jIBAwheAVV62Iw9Nc5WXsxLBiQk8UIz2Jlswyp17Kcfrugqn06VJaIgr0Bpo FU+u4GM4JYClS3SAjmIdxoEkdic5l3FF68SzFZz19Enr/Wyoo+4L6n5MDkDGY9PFr7dFXe EkKhjY11hj+BxKLfgkz/WycJ1yM9Cl/FEtFerocfbf5iSjxWxmF2USWya2+fnQ== 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 28C2E1510; Tue, 15 Mar 2022 21:15:36 +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 22FLFZKv018640; Tue, 15 Mar 2022 21:15:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 22FLFZCW018639; Tue, 15 Mar 2022 21:15:35 GMT (envelope-from git) Date: Tue, 15 Mar 2022 21:15:35 GMT Message-Id: <202203152115.22FLFZCW018639@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: 981e9c148600 - stable/13 - vfs: [2/2] fix stalls in vnode reclaim by only counting attempts 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: 981e9c148600a55c7db168a29fa11a8070305cc4 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1647378936; 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=VuUAeiU5Tfzw/+j87eXsQ0R1Te4X0yJDIIfP+4fo9X8=; b=IdAmrwqGwR1TYOKg1fJd2fxtyyzmdPKPzt/OvJH//DJrZuzQ2j0tzbeGOejJAW2ae3upL7 UaeobJo4NYIxm2UxhYehv2iMgabHNeu2R72/TfnXTZP5lDbskS41NqrnI+Wy+enz2aKa5A TEMXoWN/Q0M0fWckb84JyAMiERuuXOTM0j1FCF+fnePgrGT7nq3Tlmrtrq2jnDIZRoa+1g B23YQZK8kxv3wTdhXirq/wuGZz4ScS2lClC+CJnCb7rtMNj9SHBpFvLINCbf2zTOE5uIB6 SYub+B1kiprv2UQD3clZbkSyiP13Z42iOXM78G/TqAtAyMCY6Gp596KBjGUAeg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1647378936; a=rsa-sha256; cv=none; b=WelOdWf+x7khlrX4bK5u8QYckuqJxnRJnP18tJ64kDWNUyEO8nWPWRVv4ygRm+visBrLoE XTBEjxTWwtRFtKttvdWxrPugax3TacgrYiFT0LD67z9SeYl/NevUC3oadIKH7K2gswi0F7 IEuKxYMUgWVhO+vBJDMwOXzYqu6Tuj0Rrec2gDi5L7lGXMKQAqMDnEV9stvBfeyOxik8HF wJXmULQbZFwHvCodGbj0YdwAS3OeCka2VuKt6MK599B1D4hviISrN/VYExupnAA7v4IcSc EsTkUNoj1Nocz8vTqdNNGbml2gtYAOhEy3VPJaN6qRW1a5Jd41J9NpIL+sxiCQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=981e9c148600a55c7db168a29fa11a8070305cc4 commit 981e9c148600a55c7db168a29fa11a8070305cc4 Author: Mateusz Guzik AuthorDate: 2022-03-07 10:38:17 +0000 Commit: Mateusz Guzik CommitDate: 2022-03-15 21:12: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 (cherry picked from commit 3a4c5dab9266fac93a5cb22c7cee3938466aedea) --- 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 5c5faf455f2b..d27e7a15d886 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -1307,8 +1307,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; }