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.
This commit is contained in:
Mateusz Guzik 2023-03-21 04:23:15 +00:00
parent 245767c278
commit 138a5dafba

View File

@ -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();
}