Author: kib
Date: Thu Jan 23 17:08:33 2020
New Revision: 357054
URL: https://svnweb.freebsd.org/changeset/base/357054

Log:
  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

Modified:
  head/sys/x86/x86/mp_x86.c

Modified: head/sys/x86/x86/mp_x86.c
==============================================================================
--- head/sys/x86/x86/mp_x86.c   Thu Jan 23 16:45:48 2020        (r357053)
+++ head/sys/x86/x86/mp_x86.c   Thu Jan 23 17:08:33 2020        (r357054)
@@ -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);
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to