git: 36a037f1501e - stable/13 - libthr: Patch to reduce latency to acquire+release a pthread mutex.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 14 Jul 2023 04:13:08 UTC
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=36a037f1501e0969b56f643c5e9782334bd540e3 commit 36a037f1501e0969b56f643c5e9782334bd540e3 Author: Greg Becker <becker.greg@att.net> AuthorDate: 2023-07-07 22:03:14 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2023-07-13 01:29:17 +0000 libthr: Patch to reduce latency to acquire+release a pthread mutex. (cherry picked from commit b370ef156ab9d88450e9bc0440df522aec88cc44) --- lib/libthr/thread/thr_mutex.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/libthr/thread/thr_mutex.c b/lib/libthr/thread/thr_mutex.c index 2cbfd9a459d3..40e0b7382f95 100644 --- a/lib/libthr/thread/thr_mutex.c +++ b/lib/libthr/thread/thr_mutex.c @@ -596,7 +596,7 @@ check_and_init_mutex(pthread_mutex_t *mutex, struct pthread_mutex **m) *m = *mutex; ret = 0; - if (*m == THR_PSHARED_PTR) { + if (__predict_false(*m == THR_PSHARED_PTR)) { *m = __thr_pshared_offpage(mutex, 0); if (*m == NULL) ret = EINVAL; @@ -714,7 +714,7 @@ done: return (ret); } -static inline int +static __always_inline int mutex_lock_common(struct pthread_mutex *m, const struct timespec *abstime, bool cvattach, bool rb_onlist) { @@ -728,7 +728,7 @@ mutex_lock_common(struct pthread_mutex *m, const struct timespec *abstime, if (!rb_onlist) robust = _mutex_enter_robust(curthread, m); ret = _thr_umutex_trylock2(&m->m_lock, TID(curthread)); - if (ret == 0 || ret == EOWNERDEAD) { + if (__predict_true(ret == 0) || ret == EOWNERDEAD) { enqueue_mutex(curthread, m, ret); if (ret == EOWNERDEAD) m->m_lock.m_flags |= UMUTEX_NONCONSISTENT; @@ -951,7 +951,7 @@ mutex_self_lock(struct pthread_mutex *m, const struct timespec *abstime) return (ret); } -static int +static __always_inline int mutex_unlock_common(struct pthread_mutex *m, bool cv, int *mtx_defer) { struct pthread *curthread;