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/sparc64 | |
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/sparc64')
-rw-r--r-- | sys/arch/sparc64/sparc64/cpu.c | 10 | ||||
-rw-r--r-- | sys/arch/sparc64/sparc64/locore.s | 9 |
2 files changed, 5 insertions, 14 deletions
diff --git a/sys/arch/sparc64/sparc64/cpu.c b/sys/arch/sparc64/sparc64/cpu.c index be893f6b191..fb696a1fb0c 100644 --- a/sys/arch/sparc64/sparc64/cpu.c +++ b/sys/arch/sparc64/sparc64/cpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.c,v 1.74 2023/06/15 22:18:08 cheloha Exp $ */ +/* $OpenBSD: cpu.c,v 1.75 2023/10/24 13:20:10 claudio Exp $ */ /* $NetBSD: cpu.c,v 1.13 2001/05/26 21:27:15 chs Exp $ */ /* @@ -723,21 +723,15 @@ void cpu_hatch(void) { struct cpu_info *ci = curcpu(); - int s; cpu_init(ci); ci->ci_flags |= CPUF_RUNNING; membar_sync(); - s = splhigh(); - nanouptime(&ci->ci_schedstate.spc_runtime); - splx(s); - cpu_start_clock(); - SCHED_LOCK(s); - cpu_switchto(NULL, sched_chooseproc()); + sched_toidle(); } #endif diff --git a/sys/arch/sparc64/sparc64/locore.s b/sys/arch/sparc64/sparc64/locore.s index 88f5fe146f0..17ec463d16e 100644 --- a/sys/arch/sparc64/sparc64/locore.s +++ b/sys/arch/sparc64/sparc64/locore.s @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.s,v 1.201 2023/04/28 18:27:55 cheloha Exp $ */ +/* $OpenBSD: locore.s,v 1.202 2023/10/24 13:20:11 claudio Exp $ */ /* $NetBSD: locore.s,v 1.137 2001/08/13 06:10:10 jdolecek Exp $ */ /* @@ -6077,7 +6077,7 @@ END(snapshot) /* * cpu_set_kpc() and cpu_fork() arrange for proc_trampoline() to run - * after after a process gets chosen in switch(). The stack frame will + * after a process gets chosen in mi_switch(). The stack frame will * contain a function pointer in %l0, and an argument to pass to it in %l2. * * If the function *(%l0) returns, we arrange for an immediate return @@ -6085,13 +6085,10 @@ END(snapshot) * and when returning a child to user mode after a fork(2). */ ENTRY(proc_trampoline) -#ifdef MULTIPROCESSOR save %sp, -CC64FSZ, %sp - call proc_trampoline_mp + call proc_trampoline_mi nop restore -#endif - wrpr %g0, 0, %pil ! Reset interrupt level call %l0 ! re-use current frame mov %l1, %o0 |