git: df436036e82b - main - umtx: Don't sleep after casueword32 failure in do_sem2_wake
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 17 Feb 2025 16:41:07 UTC
The branch main has been updated by bnovkov:
URL: https://cgit.FreeBSD.org/src/commit/?id=df436036e82b895a6233d803bc8bf14d2cfe90d7
commit df436036e82b895a6233d803bc8bf14d2cfe90d7
Author: Bojan Novković <bnovkov@FreeBSD.org>
AuthorDate: 2025-01-30 15:10:04 +0000
Commit: Bojan Novković <bnovkov@FreeBSD.org>
CommitDate: 2025-02-17 16:40:34 +0000
umtx: Don't sleep after casueword32 failure in do_sem2_wake
When a casueword32 operation fails, 'do_sem2_wake' will call
'thread_check_susp' to avoid a potential livelock. However, it
instructs 'thread_check_susp' to sleep while holding a previously busied
umtxq key. This is explicitly discouraged by the comments in
'thread_check_susp' which state that a thread shouldn't sleep if it
owns a kernel resource. Fix this by passing 'false'
to 'thread_check_susp'.
Reviewed by: kib
PR: 282713
Differential Revision: https://reviews.freebsd.org/D48728
Sponsored by: Klara Inc.
---
sys/kern/kern_umtx.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sys/kern/kern_umtx.c b/sys/kern/kern_umtx.c
index a9294c324cb4..938dcf2ff1cb 100644
--- a/sys/kern/kern_umtx.c
+++ b/sys/kern/kern_umtx.c
@@ -3789,7 +3789,7 @@ do_sem2_wake(struct thread *td, struct _usem2 *sem)
rv = casueword32(&sem->_count, count, &count,
count & ~USEM_HAS_WAITERS);
if (rv == 1) {
- rv = thread_check_susp(td, true);
+ rv = thread_check_susp(td, false);
if (rv != 0)
break;
}