git: eff19ace066f - main - libthr: explain why pshared lock bumps locklevel
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 10 Nov 2026 00:19:57 UTC
The branch main has been updated by kib:
URL: https://cgit.FreeBSD.org/src/commit/?id=eff19ace066f133ed85a0e0c6cae5777d4b7db99
commit eff19ace066f133ed85a0e0c6cae5777d4b7db99
Author: Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2026-11-09 16:37:11 +0000
Commit: Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2026-11-10 00:17:42 +0000
libthr: explain why pshared lock bumps locklevel
Reviewed by: markj, aokblast
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D61343
---
lib/libthr/thread/thr_pshared.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/lib/libthr/thread/thr_pshared.c b/lib/libthr/thread/thr_pshared.c
index c8086ab07560..24b98995d119 100644
--- a/lib/libthr/thread/thr_pshared.c
+++ b/lib/libthr/thread/thr_pshared.c
@@ -73,6 +73,16 @@ __thr_pshared_init(void)
LIST_INIT(&pshared_hash[i]);
}
+/*
+ * The pshared locking bumps locklevel of the thread. This prevents
+ * async cancellation from terminating a thread that owns
+ * pshared_lock. Similarly, it prevents libthr suspension from
+ * stopping a thread that owns pshared_lock, which would cause a lock
+ * cascade.
+ *
+ * It also provides async signal safety, which is not needed, since
+ * locking primitives cannot be used in signal handlers safely.
+ */
static void
pshared_rlock(struct pthread *curthread)
{