On Sun, 3 Apr 2016, Philip Guenther wrote:
> amd64's savectx() only updates pcb_rsp and pcb_rbp, which in cpu_fork()
> are promptly overwriten in the child's pcb, so do the same
> simplification as on i386.
Thinking about this more, I believe these savectx() calls date from when
cpu_fork() worked completely differently, with the child actually
returning back through cpu_fork(). Now, the child's stack frame is
updated to make it start in proc_trampoline() when it's first switched to,
so the registers that savectx() saves (stack/frame pointers, maybe
callee-saved registers) are useless to the child.
On that theory, I'm going to test the mips64 part of this diff. I don't
have arm or m88k to test; anyone?
(This reduces savectx to almost only being called from dumpsys(). I don't
understand why mips64 and m88k platforms call it from boot(); something
evil about the reset stuff, or just debug bits? m88k also calls it from
cpu_switchto; other archs have inlined it...)
Philip Guenther
Index: arm/arm/vm_machdep.c
===================================================================
RCS file: /cvs/src/sys/arch/arm/arm/vm_machdep.c,v
retrieving revision 1.16
diff -u -p -r1.16 vm_machdep.c
--- arm/arm/vm_machdep.c 15 Aug 2015 22:20:20 -0000 1.16
+++ arm/arm/vm_machdep.c 3 Apr 2016 19:34:00 -0000
@@ -108,11 +108,6 @@ cpu_fork(p1, p2, stack, stacksize, func,
struct trapframe *tf;
struct switchframe *sf;
- if (p1 == curproc) {
- /* Sync the PCB before we copy it. */
- savectx(curpcb);
- }
-
/* Copy the pcb */
*pcb = p1->p_addr->u_pcb;
Index: m88k/m88k/vm_machdep.c
===================================================================
RCS file: /cvs/src/sys/arch/m88k/m88k/vm_machdep.c,v
retrieving revision 1.24
diff -u -p -r1.24 vm_machdep.c
--- m88k/m88k/vm_machdep.c 5 May 2015 02:13:47 -0000 1.24
+++ m88k/m88k/vm_machdep.c 3 Apr 2016 19:34:00 -0000
@@ -86,13 +86,8 @@ cpu_fork(p1, p2, stack, stacksize, func,
} *ksfp;
extern void proc_trampoline(void);
- /* Copy pcb from p1 to p2. */
- if (p1 == curproc) {
- /* Sync the PCB before we copy it. */
- savectx(curpcb);
- }
#ifdef DIAGNOSTIC
- else if (p1 != &proc0)
+ if (p1 != curproc && p1 != &proc0)
panic("cpu_fork: curproc");
#endif
Index: mips64/mips64/vm_machdep.c
===================================================================
RCS file: /cvs/src/sys/arch/mips64/mips64/vm_machdep.c,v
retrieving revision 1.33
diff -u -p -r1.33 vm_machdep.c
--- mips64/mips64/vm_machdep.c 6 Mar 2016 19:42:27 -0000 1.33
+++ mips64/mips64/vm_machdep.c 3 Apr 2016 19:34:00 -0000
@@ -104,13 +104,8 @@ cpu_fork(p1, p2, stack, stacksize, func,
KASSERT((p2->p_md.md_flags & MDP_FPUSED) == 0);
#endif
- /* Copy pcb from p1 to p2 */
- if (p1 == curproc) {
- /* Sync the PCB before we copy it. */
- savectx(p1->p_addr, 0);
- }
#ifdef DIAGNOSTIC
- else if (p1 != &proc0)
+ if (p1 != curproc && p1 != &proc0)
panic("cpu_fork: curproc");
#endif
*pcb = p1->p_addr->u_pcb;