The branch stable/13 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=4869c1571f34b603279a9addd18181aefc4f17e9
commit 4869c1571f34b603279a9addd18181aefc4f17e9 Author: Mateusz Guzik <[email protected]> AuthorDate: 2021-05-07 14:04:27 +0000 Commit: Mateusz Guzik <[email protected]> CommitDate: 2021-05-22 18:22:03 +0000 vfs: lockless writecount adjustment in set/unset text ... for cases where this is not the first/last exec. (cherry picked from commit b5fb9ae6872c499f1a02bec41f48b163a73a2aaa) --- sys/kern/vfs_default.c | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/sys/kern/vfs_default.c b/sys/kern/vfs_default.c index 4b9b1b43f1ce..eb584feb6c41 100644 --- a/sys/kern/vfs_default.c +++ b/sys/kern/vfs_default.c @@ -1177,9 +1177,23 @@ vop_stdset_text(struct vop_set_text_args *ap) { struct vnode *vp; struct mount *mp; - int error; + int error, n; vp = ap->a_vp; + + /* + * Avoid the interlock if execs are already present. + */ + n = atomic_load_int(&vp->v_writecount); + for (;;) { + if (n > -1) { + break; + } + if (atomic_fcmpset_int(&vp->v_writecount, &n, n - 1)) { + return (0); + } + } + VI_LOCK(vp); if (vp->v_writecount > 0) { error = ETXTBSY; @@ -1207,10 +1221,24 @@ static int vop_stdunset_text(struct vop_unset_text_args *ap) { struct vnode *vp; - int error; + int error, n; bool last; vp = ap->a_vp; + + /* + * Avoid the interlock if this is not the last exec. + */ + n = atomic_load_int(&vp->v_writecount); + for (;;) { + if (n >= -1) { + break; + } + if (atomic_fcmpset_int(&vp->v_writecount, &n, n + 1)) { + return (0); + } + } + last = false; VI_LOCK(vp); if (vp->v_writecount < 0) { _______________________________________________ [email protected] mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all To unsubscribe, send any mail to "[email protected]"
