diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2023-10-24 13:20:12 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2023-10-24 13:20:12 +0000 |
commit | eab399b544910d35d946debb3061295e80005445 (patch) | |
tree | 5a1bd93af430b91413ddda13e9430c33e300c0cf /sys/arch/amd64 | |
parent | 1a4745dcea2fa3ae554b1cb454a7292e44577a30 (diff) |
Normally context switches happen in mi_switch() but there are 3 cases
where a switch happens outside. Cleanup these code paths and make the
machine independent.
- when a process forks (fork, tfork, kthread), the new proc needs to
somehow be scheduled for the first time. This is done by proc_trampoline.
Since proc_trampoline is machine dependent assembler code change
the MP specific proc_trampoline_mp() to proc_trampoline_mi() and make
sure it is now always called.
- cpu_hatch: when booting APs the code needs to jump to the first proc
running on that CPU. This should be the idle thread for that CPU.
- sched_exit: when a proc exits it needs to switch away from itself and
then instruct the reaper to clean up the rest. This is done by switching
to the idle loop.
Since the last two cases require a context switch to the idle proc factor
out the common code to sched_toidle() and use it in those places.
Tested by many on all archs.
OK miod@ mpi@ cheloha@
Diffstat (limited to 'sys/arch/amd64')
-rw-r--r-- | sys/arch/amd64/amd64/cpu.c | 7 | ||||
-rw-r--r-- | sys/arch/amd64/amd64/locore.S | 7 |
2 files changed, 4 insertions, 10 deletions
diff --git a/sys/arch/amd64/amd64/cpu.c b/sys/arch/amd64/amd64/cpu.c index 60220bff4f5..bee2ff12b6d 100644 --- a/sys/arch/amd64/amd64/cpu.c +++ b/sys/arch/amd64/amd64/cpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.c,v 1.175 2023/07/31 04:01:07 guenther Exp $ */ +/* $OpenBSD: cpu.c,v 1.176 2023/10/24 13:20:09 claudio Exp $ */ /* $NetBSD: cpu.c,v 1.1 2003/04/26 18:39:26 fvdl Exp $ */ /*- @@ -1074,14 +1074,11 @@ cpu_hatch(void *v) s = splhigh(); lcr8(0); intr_enable(); - - nanouptime(&ci->ci_schedstate.spc_runtime); splx(s); lapic_startclock(); - SCHED_LOCK(s); - cpu_switchto(NULL, sched_chooseproc()); + sched_toidle(); } #if defined(DDB) diff --git a/sys/arch/amd64/amd64/locore.S b/sys/arch/amd64/amd64/locore.S index 27938da9f28..bcf30f659bd 100644 --- a/sys/arch/amd64/amd64/locore.S +++ b/sys/arch/amd64/amd64/locore.S @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.S,v 1.140 2023/07/31 04:01:07 guenther Exp $ */ +/* $OpenBSD: locore.S,v 1.141 2023/10/24 13:20:09 claudio Exp $ */ /* $NetBSD: locore.S,v 1.13 2004/03/25 18:33:17 drochner Exp $ */ /* @@ -709,10 +709,7 @@ spl_lowered: #endif NENTRY(proc_trampoline) -#ifdef MULTIPROCESSOR - call proc_trampoline_mp -#endif - movl $IPL_NONE,CPUVAR(ILEVEL) + call proc_trampoline_mi movq %r13,%rdi movq %r12,%rax call retpoline_rax |