git: 660e111ebaa1 - stable/15 - sched_ule: tdq_add(): INVARIANTS: Add check, fix name in assertion strings
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 19 Nov 2026 15:32:19 UTC
The branch stable/15 has been updated by olce:
URL: https://cgit.FreeBSD.org/src/commit/?id=660e111ebaa174e4e5239fd3e786bb5fdfceab27
commit 660e111ebaa174e4e5239fd3e786bb5fdfceab27
Author: Olivier Certner <olce@FreeBSD.org>
AuthorDate: 2026-11-12 12:21:47 +0000
Commit: Olivier Certner <olce@FreeBSD.org>
CommitDate: 2026-11-19 15:31:55 +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
(cherry picked from commit 00add43b882c36ce657bc9d60d5644bf147f378b)
---
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 c0ce9cff340d..96d694f723ad 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)