git: 138a5dafba31 - main - vfs: trylock vnode requeue
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 25 Mar 2023 13:42:34 UTC
The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=138a5dafba312ff39ce0eefdbe34de95519e600d commit 138a5dafba312ff39ce0eefdbe34de95519e600d Author: Mateusz Guzik <mjg@FreeBSD.org> AuthorDate: 2023-03-21 04:23:15 +0000 Commit: Mateusz Guzik <mjg@FreeBSD.org> 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(); }