git: b18ab4f29540 - stable/13 - vfs: trylock vnode requeue
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 27 Aug 2023 22:45:15 UTC
The branch stable/13 has been updated by mjg:
URL: https://cgit.FreeBSD.org/src/commit/?id=b18ab4f2954019f70b5f8cf879e76675f3d4425b
commit b18ab4f2954019f70b5f8cf879e76675f3d4425b
Author: Mateusz Guzik <mjg@FreeBSD.org>
AuthorDate: 2023-03-21 04:23:15 +0000
Commit: Mateusz Guzik <mjg@FreeBSD.org>
CommitDate: 2023-08-27 22:44:12 +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.
(cherry picked from commit 138a5dafba312ff39ce0eefdbe34de95519e600d)
---
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 5cdefca60e7c..c1c474b6724d 100644
--- a/sys/kern/vfs_subr.c
+++ b/sys/kern/vfs_subr.c
@@ -3533,17 +3533,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();
}