Fix the !SMP case in sched_add() after r355779.

If the thread's lock is already that of the runqueue, don't recurse on
the queue lock.

Reviewed by:	jeff, kib
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D23492
This commit is contained in:
markj 2020-02-03 22:49:05 +00:00
parent 4fae937212
commit b7b7769e94

View File

@ -2605,15 +2605,17 @@ sched_add(struct thread *td, int flags)
sched_setpreempt(td);
#else
tdq = TDQ_SELF();
TDQ_LOCK(tdq);
/*
* Now that the thread is moving to the run-queue, set the lock
* to the scheduler's lock.
*/
if ((flags & SRQ_HOLD) != 0)
td->td_lock = TDQ_LOCKPTR(tdq);
else
thread_lock_set(td, TDQ_LOCKPTR(tdq));
if (td->td_lock != TDQ_LOCKPTR(tdq)) {
TDQ_LOCK(tdq);
if ((flags & SRQ_HOLD) != 0)
td->td_lock = TDQ_LOCKPTR(tdq);
else
thread_lock_set(td, TDQ_LOCKPTR(tdq));
}
tdq_add(tdq, td, flags);
if (!(flags & SRQ_YIELDING))
sched_setpreempt(td);