svn commit: r342187 - in stable/12/sys: kern x86/x86

Konstantin Belousov kib at FreeBSD.org
Tue Dec 18 07:11:13 UTC 2018


Author: kib
Date: Tue Dec 18 07:11:12 2018
New Revision: 342187
URL: https://svnweb.freebsd.org/changeset/base/342187

Log:
  MFC r341810:
  Free bootstacks after AP startup.

Modified:
  stable/12/sys/kern/kern_thread.c
  stable/12/sys/x86/x86/mp_x86.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/kern/kern_thread.c
==============================================================================
--- stable/12/sys/kern/kern_thread.c	Tue Dec 18 06:09:12 2018	(r342186)
+++ stable/12/sys/kern/kern_thread.c	Tue Dec 18 07:11:12 2018	(r342187)
@@ -196,7 +196,7 @@ thread_ctor(void *mem, int size, void *arg, int flags)
 
 	td = (struct thread *)mem;
 	td->td_state = TDS_INACTIVE;
-	td->td_oncpu = NOCPU;
+	td->td_lastcpu = td->td_oncpu = NOCPU;
 
 	td->td_tid = tid_alloc();
 

Modified: stable/12/sys/x86/x86/mp_x86.c
==============================================================================
--- stable/12/sys/x86/x86/mp_x86.c	Tue Dec 18 06:09:12 2018	(r342186)
+++ stable/12/sys/x86/x86/mp_x86.c	Tue Dec 18 07:11:12 2018	(r342187)
@@ -1071,9 +1071,23 @@ init_secondary_tail(void)
 	/* NOTREACHED */
 }
 
-/*******************************************************************
- * local functions and data
- */
+static void
+smp_after_idle_runnable(void *arg __unused)
+{
+	struct thread *idle_td;
+	int cpu;
+
+	for (cpu = 1; cpu < mp_ncpus; cpu++) {
+		idle_td = pcpu_find(cpu)->pc_idlethread;
+		while (idle_td->td_lastcpu == NOCPU &&
+		    idle_td->td_oncpu == NOCPU)
+			cpu_spinwait();
+		kmem_free((vm_offset_t)bootstacks[cpu], kstack_pages *
+		    PAGE_SIZE);
+	}
+}
+SYSINIT(smp_after_idle_runnable, SI_SUB_SMP, SI_ORDER_ANY,
+    smp_after_idle_runnable, NULL);
 
 /*
  * We tell the I/O APIC code about all the CPUs we want to receive


More information about the svn-src-stable mailing list