summaryrefslogtreecommitdiffstats
path: root/sys/i386
diff options
context:
space:
mode:
authorjeff <jeff@FreeBSD.org>2007-06-04 23:56:08 +0000
committerjeff <jeff@FreeBSD.org>2007-06-04 23:56:08 +0000
commit20e0f793e8b39e029f1d93f5525c9e9bb8ee0563 (patch)
treee45a363116d84ec42124068f195dafe332abbdf5 /sys/i386
parent3a4cdc52dcc2679fea1c55cd0fac1ee071c4dac7 (diff)
downloadFreeBSD-src-20e0f793e8b39e029f1d93f5525c9e9bb8ee0563.zip
FreeBSD-src-20e0f793e8b39e029f1d93f5525c9e9bb8ee0563.tar.gz
Commit 10/14 of sched_lock decomposition.
- Use sched_throw() rather than replicating the same cpu_throw() code for each architecture. This also allows the scheduler to use any locking it may want to. - Use the thread_lock() rather than sched_lock when preempting. - The scheduler lock is not required to synchronize release_aps. Tested by: kris, current@ Tested on: i386, amd64, ULE, 4BSD, libthr, libkse, PREEMPTION, etc. Discussed with: kris, attilio, kmacy, jhb, julian, bde (small parts each)
Diffstat (limited to 'sys/i386')
-rw-r--r--sys/i386/i386/mp_machdep.c26
1 files changed, 5 insertions, 21 deletions
diff --git a/sys/i386/i386/mp_machdep.c b/sys/i386/i386/mp_machdep.c
index e67a99d..e6d136e 100644
--- a/sys/i386/i386/mp_machdep.c
+++ b/sys/i386/i386/mp_machdep.c
@@ -61,6 +61,7 @@ __FBSDID("$FreeBSD$");
#include <sys/mutex.h>
#include <sys/pcpu.h>
#include <sys/proc.h>
+#include <sys/sched.h>
#include <sys/smp.h>
#include <sys/sysctl.h>
@@ -642,25 +643,8 @@ init_secondary(void)
while (smp_started == 0)
ia32_pause();
- /* ok, now grab sched_lock and enter the scheduler */
- mtx_lock_spin(&sched_lock);
-
- /*
- * Correct spinlock nesting. The idle thread context that we are
- * borrowing was created so that it would start out with a single
- * spin lock (sched_lock) held in fork_trampoline(). Since we've
- * explicitly acquired locks in this function, the nesting count
- * is now 2 rather than 1. Since we are nested, calling
- * spinlock_exit() will simply adjust the counts without allowing
- * spin lock using code to interrupt us.
- */
- spinlock_exit();
- KASSERT(curthread->td_md.md_spinlock_count == 1, ("invalid count"));
-
- PCPU_SET(switchtime, cpu_ticks());
- PCPU_SET(switchticks, ticks);
-
- cpu_throw(NULL, choosethread()); /* doesn't return */
+ /* enter the scheduler */
+ sched_throw(NULL);
panic("scheduler returned us to %s", __func__);
/* NOTREACHED */
@@ -1194,12 +1178,12 @@ ipi_bitmap_handler(struct trapframe frame)
#ifdef COUNT_IPIS
(*ipi_preempt_counts[cpu])++;
#endif
- mtx_lock_spin(&sched_lock);
+ thread_lock(running_thread);
if (running_thread->td_critnest > 1)
running_thread->td_owepreempt = 1;
else
mi_switch(SW_INVOL | SW_PREEMPT, NULL);
- mtx_unlock_spin(&sched_lock);
+ thread_unlock(running_thread);
}
if (ipi_bitmap & (1 << IPI_AST)) {
OpenPOWER on IntegriCloud