git: c31580080e05 - main - Microoptimize rangelock_unlock_int()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 06 Aug 2024 04:06:37 UTC
The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=c31580080e055573a32d886b1ea83bebd9ef4e77 commit c31580080e055573a32d886b1ea83bebd9ef4e77 Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2023-10-04 18:55:49 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2024-08-06 04:05:58 +0000 Microoptimize rangelock_unlock_int() Only broadcast if there are sleepers. Suggested by: markj Reviewed by: markj, Olivier Certner <olce.freebsd@certner.fr> Tested by: pho Sponsored by: The FreeBSD Foundation Differential revision: https://reviews.freebsd.org/D41787 --- sys/kern/kern_rangelock.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sys/kern/kern_rangelock.c b/sys/kern/kern_rangelock.c index 9c6b7fb871f9..355b2125dd9b 100644 --- a/sys/kern/kern_rangelock.c +++ b/sys/kern/kern_rangelock.c @@ -160,13 +160,17 @@ rl_e_is_rlock(const struct rl_q_entry *e) static void rangelock_unlock_int(struct rangelock *lock, struct rl_q_entry *e) { + bool sleepers; + MPASS(lock != NULL && e != NULL); MPASS(!rl_e_is_marked(rl_q_load(&e->rl_q_next))); MPASS(e->rl_q_owner == curthread); rl_e_mark(e); + sleepers = lock->sleepers; lock->sleepers = false; - sleepq_broadcast(&lock->sleepers, SLEEPQ_SLEEP, 0, 0); + if (sleepers) + sleepq_broadcast(&lock->sleepers, SLEEPQ_SLEEP, 0, 0); } void