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/alpha | |
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/alpha')
-rw-r--r-- | sys/arch/alpha/alpha/cpu.c | 7 | ||||
-rw-r--r-- | sys/arch/alpha/alpha/locore.s | 6 | ||||
-rw-r--r-- | sys/arch/alpha/alpha/vm_machdep.c | 10 |
3 files changed, 5 insertions, 18 deletions
diff --git a/sys/arch/alpha/alpha/cpu.c b/sys/arch/alpha/alpha/cpu.c index 03d035c3100..0b605f6af46 100644 --- a/sys/arch/alpha/alpha/cpu.c +++ b/sys/arch/alpha/alpha/cpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.c,v 1.47 2023/06/15 22:18:06 cheloha Exp $ */ +/* $OpenBSD: cpu.c,v 1.48 2023/10/24 13:20:09 claudio Exp $ */ /* $NetBSD: cpu.c,v 1.44 2000/05/23 05:12:53 thorpej Exp $ */ /*- @@ -569,7 +569,6 @@ cpu_hatch(struct cpu_info *ci) { u_long cpu_id = cpu_number(); u_long cpumask = (1UL << cpu_id); - int s; /* Mark the kernel pmap active on this processor. */ atomic_setbits_ulong(&pmap_kernel()->pm_cpus, cpumask); @@ -600,7 +599,6 @@ cpu_hatch(struct cpu_info *ci) clockqueue_init(&ci->ci_queue); KERNEL_LOCK(); sched_init_cpu(ci); - nanouptime(&ci->ci_schedstate.spc_runtime); ci->ci_curproc = ci->ci_fpcurproc = NULL; ci->ci_randseed = (arc4random() & 0x7fffffff) + 1; KERNEL_UNLOCK(); @@ -608,8 +606,7 @@ cpu_hatch(struct cpu_info *ci) clockintr_cpu_init(NULL); (void) alpha_pal_swpipl(ALPHA_PSL_IPL_0); - SCHED_LOCK(s); - cpu_switchto(NULL, sched_chooseproc()); + sched_toidle(); /* NOTREACHED */ } diff --git a/sys/arch/alpha/alpha/locore.s b/sys/arch/alpha/alpha/locore.s index 0c8f3cd1e64..959a6d0326c 100644 --- a/sys/arch/alpha/alpha/locore.s +++ b/sys/arch/alpha/alpha/locore.s @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.s,v 1.51 2023/01/31 15:18:51 deraadt Exp $ */ +/* $OpenBSD: locore.s,v 1.52 2023/10/24 13:20:09 claudio Exp $ */ /* $NetBSD: locore.s,v 1.94 2001/04/26 03:10:44 ross Exp $ */ /*- @@ -776,9 +776,7 @@ LEAF(cpu_idle_leave, 0) * by the s2 register. */ LEAF(proc_trampoline, 0) -#if defined(MULTIPROCESSOR) - CALL(proc_trampoline_mp) -#endif + CALL(proc_trampoline_mi) mov s0, pv mov s1, ra mov s2, a0 diff --git a/sys/arch/alpha/alpha/vm_machdep.c b/sys/arch/alpha/alpha/vm_machdep.c index 362f9908f9c..b04a12651ea 100644 --- a/sys/arch/alpha/alpha/vm_machdep.c +++ b/sys/arch/alpha/alpha/vm_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vm_machdep.c,v 1.51 2023/04/11 00:45:07 jsg Exp $ */ +/* $OpenBSD: vm_machdep.c,v 1.52 2023/10/24 13:20:09 claudio Exp $ */ /* $NetBSD: vm_machdep.c,v 1.55 2000/03/29 03:49:48 simonb Exp $ */ /* @@ -162,15 +162,7 @@ cpu_fork(struct proc *p1, struct proc *p2, void *stack, void *tcb, up->u_pcb.pcb_context[2] = (u_int64_t)arg; up->u_pcb.pcb_context[7] = (u_int64_t)proc_trampoline; /* ra: assembly magic */ -#ifdef MULTIPROCESSOR - /* - * MULTIPROCESSOR kernels will reuse the IPL of the parent - * process, and will lower to IPL_NONE in proc_trampoline_mp(). - */ up->u_pcb.pcb_context[8] = IPL_SCHED; /* ps: IPL */ -#else - up->u_pcb.pcb_context[8] = IPL_NONE; /* ps: IPL */ -#endif } struct kmem_va_mode kv_physwait = { |