Fix r356919.

Instead of waiting for pc_curthread which is overwritten by
init_secondary_tail(), wait for non-NULL pc_curpcb, to be set by the
first context switch.
Assert that pc_curpcb is not set too early.

Reported and tested by:	rlibby
Reviewed by:	markj, rlibby
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D23330
This commit is contained in:
Konstantin Belousov 2020-01-23 17:08:33 +00:00
parent 66351f5126
commit b94c55a9cb
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=357054

View File

@ -1084,6 +1084,11 @@ init_secondary_tail(void)
kcsan_cpu_init(cpuid);
/*
* Assert that smp_after_idle_runnable condition is reasonable.
*/
MPASS(PCPU_GET(curpcb) == NULL);
sched_throw(NULL);
panic("scheduler returned us to %s", __func__);
@ -1098,7 +1103,7 @@ smp_after_idle_runnable(void *arg __unused)
for (cpu = 1; cpu < mp_ncpus; cpu++) {
pc = pcpu_find(cpu);
while (atomic_load_ptr(&pc->pc_curthread) == (uintptr_t)NULL)
while (atomic_load_ptr(&pc->pc_curpcb) == (uintptr_t)NULL)
cpu_spinwait();
kmem_free((vm_offset_t)bootstacks[cpu], kstack_pages *
PAGE_SIZE);