From nobody Fri Oct 13 23:54:01 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 4S6jyd5gZYz4wyGT; Fri, 13 Oct 2023 23:54:01 +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 4S6jyd2QXWz3KTf; Fri, 13 Oct 2023 23:54:01 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1697241241; 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=o99MDK697+zN/s+bmY3KqH0XEypdZohRCmha9DZeVyY=; b=OwTyt3fsX7PgbK77/WnH2m9TgX4FXjoOGvKheiehMwPKoWLYuKNU/7ItzsBC4IhwQkiGHS a8BXQpi7A0PwrvzLiGEXJRyqEjc8qw4e1V0LzvXAHkYxTyK6mDsRSrZ70i8Y1VXac8KPYP U9+uCHl8QcpG0fsf5Vp9kJGMcAKToqPCLI2lhaRzZaS+/GHRkbCWQFRbjUAhaT6i2jJ89t Zxznbc7GmFnxSrjmMWGU9btsQpifPmDgDOPm8rJQTjUYyITeHpscs3PmSh18CWWcqhWsBk 1/qZOe9HUNRpA2M65ZVGpwUzA03plH56WlxHainGb97hOFmz4XmbHX+AdCM9Pw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1697241241; a=rsa-sha256; cv=none; b=VzkieVyMsfdsNnVCIqcujN6yzHdhOkpSi1ICj9FWAYzQABx1LB6s+p2Yy92V4xUv4Jm/r+ jYUj12S7bchYI5ge0plzWSTNTUYSjHd475xokIj2/hLZob+KWbsN91jE5W68Wip24vRbya 9kVKyAxCXygb4d256QGQio/03UnH21H0Mz1UvR8sZscyAzTdpGTYFNnOW5fhU6KPNaVKDJ HmwsnGPPOFIU6J9B2UlCHmDQS9sTgCeokQ1ib5jEd9Am6O3Llz3P0LY8Zr2/OorxAkaqz+ dIpSu3Xl7j+iCJ6NsLY7LkXvrZSHwLfUs+pPUak9NRu1qLO7BWh0AjqhFY+LXA== 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=1697241241; 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=o99MDK697+zN/s+bmY3KqH0XEypdZohRCmha9DZeVyY=; b=Oa5gsKOeMA2AqEd9y4EeqVOX7eQw9Wax/FR+7NlLfLk0t2K5TE+/lDsDKYfpte705UsF2T Cda6fMorBArWsZDsZT53PHeCgF7ZPKg9uDOAUTbc6b69NtkPH3i9kZv8mtsj2foXpP1xfD H6aNc+C1JGbVVZMNNCKXavoNN+NoiZU2ji9js3DpHDMtFCBmpkVmai//SzBDC9mL6BznKr 0wp8/pCy7+++jVV+86i1B4INCCnrmg/INv+x9do0ms01cRtH2ZnGU8ilAgOM6j5ELIipvw Uj03LlCf8lUBoe40KmGgisNmGU7H+QkloVanWg2uyvI2EYiEnZYpKOQ3MHtUiQ== 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 4S6jyd1XZQz17c1; Fri, 13 Oct 2023 23:54:01 +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 39DNs1Ti032548; Fri, 13 Oct 2023 23:54:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 39DNs1UF032545; Fri, 13 Oct 2023 23:54:01 GMT (envelope-from git) Date: Fri, 13 Oct 2023 23:54:01 GMT Message-Id: <202310132354.39DNs1UF032545@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: a6a4a57ca3e8 - stable/13 - vfs: count recycles by vnlru and by vn_alloc separately 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/stable/13 X-Git-Reftype: branch X-Git-Commit: a6a4a57ca3e8fe5ca539c31cb1fab7acf8a26dd7 Auto-Submitted: auto-generated The branch stable/13 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=a6a4a57ca3e8fe5ca539c31cb1fab7acf8a26dd7 commit a6a4a57ca3e8fe5ca539c31cb1fab7acf8a26dd7 Author: Mateusz Guzik AuthorDate: 2023-10-12 06:47:45 +0000 Commit: Mateusz Guzik CommitDate: 2023-10-13 23:52:39 +0000 vfs: count recycles by vnlru and by vn_alloc separately Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit a92fc3122d2becfbf5a627af6eda5cedfac57c31) --- sys/kern/vfs_subr.c | 52 ++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 16 deletions(-) diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 2be83da5d73f..530afbe05b3e 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -109,7 +109,7 @@ static void delmntque(struct vnode *vp); static int flushbuflist(struct bufv *bufv, int flags, struct bufobj *bo, int slpflag, int slptimeo); static void syncer_shutdown(void *arg, int howto); -static int vtryrecycle(struct vnode *vp); +static int vtryrecycle(struct vnode *vp, bool isvnlru); static void v_init_counters(struct vnode *); static void vn_seqc_init(struct vnode *); static void vn_seqc_write_end_free(struct vnode *vp); @@ -210,6 +210,11 @@ SYSCTL_COUNTER_U64(_vfs, OID_AUTO, recycles_free, CTLFLAG_RD, &recycles_free_cou SYSCTL_COUNTER_U64(_vfs_vnode_vnlru, OID_AUTO, recycles_free, CTLFLAG_RD, &recycles_free_count, "Number of free vnodes recycled to meet vnode cache targets"); +static counter_u64_t direct_recycles_free_count; +SYSCTL_COUNTER_U64(_vfs_vnode_vnlru, OID_AUTO, direct_recycles_free, CTLFLAG_RD, + &direct_recycles_free_count, + "Number of free vnodes recycled by vn_alloc callers to meet vnode cache targets"); + static counter_u64_t vnode_skipped_requeues; SYSCTL_COUNTER_U64(_vfs_vnode_stats, OID_AUTO, skipped_requeues, CTLFLAG_RD, &vnode_skipped_requeues, "Number of times LRU requeue was skipped due to lock contention"); @@ -765,6 +770,7 @@ vntblinit(void *dummy __unused) vnodes_created = counter_u64_alloc(M_WAITOK); recycles_count = counter_u64_alloc(M_WAITOK); recycles_free_count = counter_u64_alloc(M_WAITOK); + direct_recycles_free_count = counter_u64_alloc(M_WAITOK); vnode_skipped_requeues = counter_u64_alloc(M_WAITOK); /* @@ -1307,7 +1313,7 @@ SYSCTL_INT(_vfs_vnode_vnlru, OID_AUTO, max_free_per_call, CTLFLAG_RW, * Attempt to reduce the free list by the requested amount. */ static int -vnlru_free_impl(int count, struct vfsops *mnt_op, struct vnode *mvp) +vnlru_free_impl(int count, struct vfsops *mnt_op, struct vnode *mvp, bool isvnlru) { struct vnode *vp; struct mount *mp; @@ -1393,7 +1399,7 @@ vnlru_free_impl(int count, struct vfsops *mnt_op, struct vnode *mvp) * * Check nullfs for one example (null_getwritemount). */ - vtryrecycle(vp); + vtryrecycle(vp, isvnlru); count--; if (count == 0) { break; @@ -1409,22 +1415,33 @@ vnlru_free_impl(int count, struct vfsops *mnt_op, struct vnode *mvp) * XXX: returns without vnode_list_mtx locked! */ static int -vnlru_free_locked(int count) +vnlru_free_locked_direct(int count) { int ret; mtx_assert(&vnode_list_mtx, MA_OWNED); - ret = vnlru_free_impl(count, NULL, vnode_list_free_marker); + ret = vnlru_free_impl(count, NULL, vnode_list_free_marker, false); mtx_assert(&vnode_list_mtx, MA_NOTOWNED); return (ret); } static int -vnlru_free(int count) +vnlru_free_locked_vnlru(int count) +{ + int ret; + + mtx_assert(&vnode_list_mtx, MA_OWNED); + ret = vnlru_free_impl(count, NULL, vnode_list_free_marker, true); + mtx_assert(&vnode_list_mtx, MA_NOTOWNED); + return (ret); +} + +static int +vnlru_free_vnlru(int count) { mtx_lock(&vnode_list_mtx); - return (vnlru_free_locked(count)); + return (vnlru_free_locked_vnlru(count)); } void @@ -1435,7 +1452,7 @@ vnlru_free_vfsops(int count, struct vfsops *mnt_op, struct vnode *mvp) MPASS(mvp != NULL); VNPASS(mvp->v_type == VMARKER, mvp); mtx_lock(&vnode_list_mtx); - vnlru_free_impl(count, mnt_op, mvp); + vnlru_free_impl(count, mnt_op, mvp, true); mtx_assert(&vnode_list_mtx, MA_NOTOWNED); } @@ -1451,7 +1468,7 @@ vnlru_free(int count, struct vfsops *mnt_op) return; mtx_lock(&vnode_list_mtx); mvp = vnode_list_free_marker; - if (vnlru_free_impl(count, mnt_op, mvp) == 0) { + if (vnlru_free_impl(count, mnt_op, mvp, true) == 0) { /* * It is possible the marker was moved over eligible vnodes by * callers which filtered by different ops. If so, start from @@ -1461,7 +1478,7 @@ vnlru_free(int count, struct vfsops *mnt_op) TAILQ_REMOVE(&vnode_list, mvp, v_vnodelist); TAILQ_INSERT_HEAD(&vnode_list, mvp, v_vnodelist); } - vnlru_free_impl(count, mnt_op, mvp); + vnlru_free_impl(count, mnt_op, mvp, true); } mtx_unlock(&vnode_list_mtx); } @@ -1719,7 +1736,7 @@ vnlru_proc_light(void) return (false); if (freecount != 0) { - vnlru_free(freecount); + vnlru_free_vnlru(freecount); } mtx_lock(&vnode_list_mtx); @@ -1765,7 +1782,7 @@ vnlru_proc(void) * try to reduce it by discarding from the free list. */ if (rnumvnodes > desiredvnodes + 10) { - vnlru_free_locked(rnumvnodes - desiredvnodes); + vnlru_free_locked_vnlru(rnumvnodes - desiredvnodes); mtx_lock(&vnode_list_mtx); rnumvnodes = atomic_load_long(&numvnodes); } @@ -1865,7 +1882,7 @@ SYSINIT(vnlru, SI_SUB_KTHREAD_UPDATE, SI_ORDER_FIRST, kproc_start, * through vgone(). */ static int -vtryrecycle(struct vnode *vp) +vtryrecycle(struct vnode *vp, bool isvnlru) { struct mount *vnmp; @@ -1911,7 +1928,10 @@ vtryrecycle(struct vnode *vp) return (EBUSY); } if (!VN_IS_DOOMED(vp)) { - counter_u64_add(recycles_free_count, 1); + if (isvnlru) + counter_u64_add(recycles_free_count, 1); + else + counter_u64_add(direct_recycles_free_count, 1); vgonel(vp); } VOP_UNLOCK(vp); @@ -1984,7 +2004,7 @@ vn_alloc_hard(struct mount *mp, u_long rnumvnodes, bool bumped) * should be chosen so that we never wait or even reclaim from * the free list to below its target minimum. */ - if (vnlru_free_locked(1) > 0) + if (vnlru_free_locked_direct(1) > 0) goto alloc; mtx_assert(&vnode_list_mtx, MA_NOTOWNED); if (mp == NULL || (mp->mnt_kern_flag & MNTK_SUSPEND) == 0) { @@ -2001,7 +2021,7 @@ vn_alloc_hard(struct mount *mp, u_long rnumvnodes, bool bumped) msleep(&vnlruproc_sig, &vnode_list_mtx, PVFS, "vlruwk", hz); if (atomic_load_long(&numvnodes) + 1 > desiredvnodes && vnlru_read_freevnodes() > 1) - vnlru_free_locked(1); + vnlru_free_locked_direct(1); else mtx_unlock(&vnode_list_mtx); }