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/sh | |
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/sh')
-rw-r--r-- | sys/arch/sh/sh/locore_subr.S | 7 | ||||
-rw-r--r-- | sys/arch/sh/sh/vm_machdep.c | 5 |
2 files changed, 9 insertions, 3 deletions
diff --git a/sys/arch/sh/sh/locore_subr.S b/sys/arch/sh/sh/locore_subr.S index 97ed4c4fbef..342868128b0 100644 --- a/sys/arch/sh/sh/locore_subr.S +++ b/sys/arch/sh/sh/locore_subr.S @@ -1,4 +1,4 @@ -/* $OpenBSD: locore_subr.S,v 1.16 2023/08/14 07:40:08 miod Exp $ */ +/* $OpenBSD: locore_subr.S,v 1.17 2023/10/24 13:20:10 claudio Exp $ */ /* $NetBSD: locore_subr.S,v 1.28 2006/01/23 22:52:09 uwe Exp $ */ /* @@ -471,10 +471,15 @@ NENTRY(_cpu_spin) * respectively. set by cpu_fork(). */ NENTRY(proc_trampoline) + mov.l .L_proc_trampoline_mi, r1 + jsr @r1 /* proc_trampoline_mi() */ + nop jsr @r12 mov r11, r4 __EXCEPTION_RETURN /* NOTREACHED */ +.L_proc_trampoline_mi: + .long proc_trampoline_mi SET_ENTRY_SIZE(proc_trampoline) diff --git a/sys/arch/sh/sh/vm_machdep.c b/sys/arch/sh/sh/vm_machdep.c index 5227ab70ee5..85ad32946df 100644 --- a/sys/arch/sh/sh/vm_machdep.c +++ b/sys/arch/sh/sh/vm_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vm_machdep.c,v 1.17 2022/05/27 18:55:30 kettenis Exp $ */ +/* $OpenBSD: vm_machdep.c,v 1.18 2023/10/24 13:20:10 claudio Exp $ */ /* $NetBSD: vm_machdep.c,v 1.53 2006/08/31 16:49:21 matt Exp $ */ /* @@ -227,7 +227,8 @@ cpu_fork(struct proc *p1, struct proc *p2, void *stack, void *tcb, * Enable interrupt when switch frame is restored, since * kernel thread begin to run without restoring trapframe. */ - sf->sf_sr = PSL_MD; /* kernel mode, interrupt enable */ + sf->sf_sr = PSL_MD | /* kernel mode, interrupt enable */ + (IPL_SCHED << 4); #ifdef SH4 if (CPU_IS_SH4) { |