Initialize the idle thread's lock sooner so it's not evaluated on every fork

exit and we can rely on it elsewhere.

Reviewed by:	mav, kib, jhb, markj
Differential Revision:	https://reviews.freebsd.org/D22624
This commit is contained in:
Jeff Roberson 2019-12-02 22:35:45 +00:00
parent fb6a57ef89
commit e15046952d
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=355312

View File

@ -1463,7 +1463,7 @@ sched_setup(void *dummy)
/* Add thread0's load since it's running. */
TDQ_LOCK(tdq);
thread0.td_lock = TDQ_LOCKPTR(TDQ_SELF());
thread0.td_lock = TDQ_LOCKPTR(tdq);
tdq_load_add(tdq, &thread0);
tdq->tdq_lowpri = thread0.td_priority;
TDQ_UNLOCK(tdq);
@ -2913,6 +2913,7 @@ sched_throw(struct thread *td)
spinlock_exit();
PCPU_SET(switchtime, cpu_ticks());
PCPU_SET(switchticks, ticks);
PCPU_GET(idlethread)->td_lock = TDQ_LOCKPTR(tdq);
} else {
tdq = TDQ_SELF();
MPASS(td->td_lock == TDQ_LOCKPTR(tdq));
@ -2943,8 +2944,6 @@ sched_fork_exit(struct thread *td)
*/
cpuid = PCPU_GET(cpuid);
tdq = TDQ_SELF();
if (TD_IS_IDLETHREAD(td))
td->td_lock = TDQ_LOCKPTR(tdq);
MPASS(td->td_lock == TDQ_LOCKPTR(tdq));
td->td_oncpu = cpuid;
TDQ_LOCK_ASSERT(tdq, MA_OWNED | MA_NOTRECURSED);