Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 18 Dec 2018 07:11:12 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r342187 - in stable/12/sys: kern x86/x86
Message-ID:  <201812180711.wBI7BCar023885@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201812180711.wBI7BCar023885>