git: b92cd6b2944a - main - lockmgr: make lockmgr_disowned public and use it
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 21 May 2024 18:16:45 UTC
The branch main has been updated by rlibby: URL: https://cgit.FreeBSD.org/src/commit/?id=b92cd6b2944af2112787c55949e0c8194305c8c4 commit b92cd6b2944af2112787c55949e0c8194305c8c4 Author: Ryan Libby <rlibby@FreeBSD.org> AuthorDate: 2024-05-21 17:21:50 +0000 Commit: Ryan Libby <rlibby@FreeBSD.org> CommitDate: 2024-05-21 17:21:50 +0000 lockmgr: make lockmgr_disowned public and use it Reviewed by: mckusick, kib, markj Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D45248 --- sys/kern/kern_lock.c | 7 ++----- sys/sys/lockmgr.h | 4 ++++ 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/sys/kern/kern_lock.c b/sys/kern/kern_lock.c index f152185f5fbf..1b4d21f064a7 100644 --- a/sys/kern/kern_lock.c +++ b/sys/kern/kern_lock.c @@ -138,9 +138,6 @@ LK_CAN_SHARE(uintptr_t x, int flags, bool fp) #define LK_TRYWIT(x) \ (LK_TRYOP(x) ? LOP_TRYLOCK : 0) -#define lockmgr_disowned(lk) \ - (((lk)->lk_lock & ~(LK_FLAGMASK & ~LK_SHARE)) == LK_KERNPROC) - #define lockmgr_xlocked_v(v) \ (((v) & ~(LK_FLAGMASK & ~LK_SHARE)) == (uintptr_t)curthread) @@ -243,7 +240,7 @@ static void lockmgr_note_exclusive_release(struct lock *lk, const char *file, int line) { - if (LK_HOLDER(lockmgr_read_value(lk)) != LK_KERNPROC) { + if (!lockmgr_disowned(lk)) { WITNESS_UNLOCK(&lk->lock_object, LOP_EXCLUSIVE, file, line); TD_LOCKS_DEC(curthread); } @@ -1135,7 +1132,7 @@ lockmgr_xunlock_hard(struct lock *lk, uintptr_t x, u_int flags, struct lock_obje * any waiter. * Fix-up the tid var if the lock has been disowned. */ - if (LK_HOLDER(x) == LK_KERNPROC) + if (lockmgr_disowned_v(x)) tid = LK_KERNPROC; /* diff --git a/sys/sys/lockmgr.h b/sys/sys/lockmgr.h index ebe238cd0e25..48eea47c60da 100644 --- a/sys/sys/lockmgr.h +++ b/sys/sys/lockmgr.h @@ -130,6 +130,10 @@ _lockmgr_args_rw(struct lock *lk, u_int flags, struct rwlock *ilk, LOCK_FILE, LOCK_LINE) #define lockmgr_disown(lk) \ _lockmgr_disown((lk), LOCK_FILE, LOCK_LINE) +#define lockmgr_disowned_v(v) \ + (LK_HOLDER((v)) == LK_KERNPROC) +#define lockmgr_disowned(lk) \ + lockmgr_disowned_v(lockmgr_read_value((lk))) #define lockmgr_recursed_v(v) \ (v & LK_WRITER_RECURSED) #define lockmgr_recursed(lk) \