git: c8205c2ea8af - stable/15 - libthr: explain why pshared lock bumps locklevel

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Tue, 17 Nov 2026 01:09:38 UTC
The branch stable/15 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=c8205c2ea8af659a73af92160e29ebee42b0bd69

commit c8205c2ea8af659a73af92160e29ebee42b0bd69
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2026-11-09 16:37:11 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2026-11-17 00:24:58 +0000

    libthr: explain why pshared lock bumps locklevel
    
    (cherry picked from commit eff19ace066f133ed85a0e0c6cae5777d4b7db99)
---
 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 75e064c9fc33..90ecd1d0478c 100644
--- a/lib/libthr/thread/thr_pshared.c
+++ b/lib/libthr/thread/thr_pshared.c
@@ -68,6 +68,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)
 {