git: 00add43b882c - main - sched_ule: tdq_add(): INVARIANTS: Add check, fix name in assertion strings
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 14 Nov 2026 16:29:44 UTC
The branch main has been updated by olce:
URL: https://cgit.FreeBSD.org/src/commit/?id=00add43b882c36ce657bc9d60d5644bf147f378b
commit 00add43b882c36ce657bc9d60d5644bf147f378b
Author: Olivier Certner <olce@FreeBSD.org>
AuthorDate: 2026-11-12 12:21:47 +0000
Commit: Olivier Certner <olce@FreeBSD.org>
CommitDate: 2026-11-14 16:29:31 +0000
sched_ule: tdq_add(): INVARIANTS: Add check, fix name in assertion strings
Change the assertion on the to-add thread's lock so that it also fails
if the thread's lock is not that of the 'tdq' (the checks that it is
lock-unblocked and locked remain).
It is tempting to add another check that the thread's 'ts_cpu'
corresponds to the passed runqueue (in other words, that it has been set
correctly), but that requires to add a call to thread_lock_block_wait()
which should not be present in non-debug code, and that may prevent some
races from happening on INVARIANTS, so I gave up on it.
Fix the function name in assertion strings, as sched_add() is not the
only (direct or indirect) caller of tdq_add().
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
---
sys/kern/sched_ule.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/sys/kern/sched_ule.c b/sys/kern/sched_ule.c
index 76e8d922172f..1dad770fc305 100644
--- a/sys/kern/sched_ule.c
+++ b/sys/kern/sched_ule.c
@@ -2885,13 +2885,13 @@ tdq_add(struct tdq *tdq, struct thread *td, int flags)
int lowpri;
TDQ_LOCK_ASSERT(tdq, MA_OWNED);
- THREAD_LOCK_BLOCKED_ASSERT(td, MA_OWNED);
+ THREAD_LOCKPTR_BLOCKED_ASSERT(td, TDQ_LOCKPTR(tdq));
KASSERT((td->td_inhibitors == 0),
- ("sched_add: trying to run inhibited thread"));
+ ("%s: trying to run inhibited thread", __func__));
KASSERT((TD_CAN_RUN(td) || TD_IS_RUNNING(td)),
- ("sched_add: bad thread state"));
+ ("%s: bad thread state", __func__));
KASSERT(td->td_flags & TDF_INMEM,
- ("sched_add: thread swapped out"));
+ ("%s: thread swapped out", __func__));
lowpri = tdq->tdq_lowpri;
if (td->td_priority < lowpri)