Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch oldlwp is always non-NULL in cpu_switchto so remove...



details:   https://anonhg.NetBSD.org/src/rev/c6f9b3fb25af
branches:  trunk
changeset: 968258:c6f9b3fb25af
user:      skrll <skrll%NetBSD.org@localhost>
date:      Wed Jan 08 20:59:18 2020 +0000

description:
oldlwp is always non-NULL in cpu_switchto so remove the test for NULL.

diffstat:

 sys/arch/aarch64/aarch64/cpuswitch.S   |   9 +++------
 sys/arch/alpha/alpha/locore.s          |   7 ++-----
 sys/arch/amd64/amd64/locore.S          |   6 +++---
 sys/arch/arm/arm32/cpuswitch.S         |  26 +++-----------------------
 sys/arch/hppa/hppa/locore.S            |   6 +-----
 sys/arch/m68k/m68k/switch_subr.s       |  11 +----------
 sys/arch/mips/mips/locore.S            |  10 ++++------
 sys/arch/powerpc/powerpc/locore_subr.S |  11 ++---------
 sys/arch/riscv/riscv/locore.S          |   6 ++----
 sys/arch/sh3/sh3/locore_subr.S         |   9 +++------
 sys/arch/sparc/sparc/locore.s          |   7 ++-----
 sys/arch/sparc64/sparc64/locore.s      |   6 ++----
 12 files changed, 28 insertions(+), 86 deletions(-)

diffs (truncated from 408 to 300 lines):

diff -r 7c456520eed2 -r c6f9b3fb25af sys/arch/aarch64/aarch64/cpuswitch.S
--- a/sys/arch/aarch64/aarch64/cpuswitch.S      Wed Jan 08 20:49:22 2020 +0000
+++ b/sys/arch/aarch64/aarch64/cpuswitch.S      Wed Jan 08 20:59:18 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpuswitch.S,v 1.14 2020/01/08 17:38:41 ad Exp $ */
+/* $NetBSD: cpuswitch.S,v 1.15 2020/01/08 20:59:18 skrll Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -37,18 +37,16 @@
 #include "opt_ddb.h"
 #include "opt_kasan.h"
 
-RCSID("$NetBSD: cpuswitch.S,v 1.14 2020/01/08 17:38:41 ad Exp $")
+RCSID("$NetBSD: cpuswitch.S,v 1.15 2020/01/08 20:59:18 skrll Exp $")
 
 /*
  * At IPL_SCHED:
- *     x0 = oldlwp (maybe be NULL)
+ *     x0 = oldlwp
  *     x1 = newlwp
  *     x2 = returning
  * returns x0-x2 unchanged
  */
 ENTRY_NP(cpu_switchto)
-       cbz     x0, .Lrestore_lwp
-
        /*
         * Store the callee saved register on the stack.
         */
@@ -72,7 +70,6 @@
 
        /* We are done with the old lwp */
 
-.Lrestore_lwp:
        DISABLE_INTERRUPT
        ldr     x6, [x1, #L_PCB]        /* x6 = lwp_getpcb(newlwp) */
        ldr     x4, [x6, #PCB_TF]       /* get trapframe ptr (aka SP) */
diff -r 7c456520eed2 -r c6f9b3fb25af sys/arch/alpha/alpha/locore.s
--- a/sys/arch/alpha/alpha/locore.s     Wed Jan 08 20:49:22 2020 +0000
+++ b/sys/arch/alpha/alpha/locore.s     Wed Jan 08 20:59:18 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: locore.s,v 1.123 2019/04/06 03:06:24 thorpej Exp $ */
+/* $NetBSD: locore.s,v 1.124 2020/01/08 20:59:18 skrll Exp $ */
 
 /*-
  * Copyright (c) 1999, 2000, 2019 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
 
 #include <machine/asm.h>
 
-__KERNEL_RCSID(0, "$NetBSD: locore.s,v 1.123 2019/04/06 03:06:24 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locore.s,v 1.124 2020/01/08 20:59:18 skrll Exp $");
 
 #include "assym.h"
 
@@ -663,8 +663,6 @@
 LEAF(cpu_switchto, 0)
        LDGP(pv)
 
-       beq     a0, 1f
-
        /*
         * do an inline savectx(), to save old context
         */
@@ -679,7 +677,6 @@
        stq     s6, PCB_CONTEXT+(6 * 8)(a2)
        stq     ra, PCB_CONTEXT+(7 * 8)(a2)     /* store ra */
 
-1:
        mov     a0, s4                          /* save old curlwp */
        mov     a1, s2                          /* save new lwp */
        ldq     a0, L_MD_PCBPADDR(s2)           /* save new pcbpaddr */
diff -r 7c456520eed2 -r c6f9b3fb25af sys/arch/amd64/amd64/locore.S
--- a/sys/arch/amd64/amd64/locore.S     Wed Jan 08 20:49:22 2020 +0000
+++ b/sys/arch/amd64/amd64/locore.S     Wed Jan 08 20:59:18 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: locore.S,v 1.196 2020/01/08 17:38:41 ad Exp $  */
+/*     $NetBSD: locore.S,v 1.197 2020/01/08 20:59:18 skrll Exp $       */
 
 /*
  * Copyright-o-rama!
@@ -1819,8 +1819,8 @@
  * struct lwp *cpu_switchto(struct lwp *oldlwp, struct lwp *newlwp,
  *     bool returning)
  *
- *     1. if (oldlwp != NULL), save its context.
- *     2. then, restore context of newlwp.
+ *     1. save context of oldlwp.
+ *     2. restore context of newlwp.
  *
  * Note that the stack frame layout is known to "struct switchframe" in
  * <machine/frame.h> and to the code in cpu_lwp_fork() which initializes
diff -r 7c456520eed2 -r c6f9b3fb25af sys/arch/arm/arm32/cpuswitch.S
--- a/sys/arch/arm/arm32/cpuswitch.S    Wed Jan 08 20:49:22 2020 +0000
+++ b/sys/arch/arm/arm32/cpuswitch.S    Wed Jan 08 20:59:18 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpuswitch.S,v 1.96 2020/01/08 17:38:41 ad Exp $        */
+/*     $NetBSD: cpuswitch.S,v 1.97 2020/01/08 20:59:18 skrll Exp $     */
 
 /*
  * Copyright 2003 Wasabi Systems, Inc.
@@ -87,7 +87,7 @@
 #include <arm/asm.h>
 #include <arm/locore.h>
 
-       RCSID("$NetBSD: cpuswitch.S,v 1.96 2020/01/08 17:38:41 ad Exp $")
+       RCSID("$NetBSD: cpuswitch.S,v 1.97 2020/01/08 20:59:18 skrll Exp $")
 
 /* LINTSTUB: include <sys/param.h> */
 
@@ -128,7 +128,7 @@
  * Switch to the specified next LWP
  * Arguments:
  *
- *     r0      'struct lwp *' of the current LWP (or NULL if exiting)
+ *     r0      'struct lwp *' of the current LWP
  *     r1      'struct lwp *' of the LWP to switch to
  *     r2      returning
  */
@@ -151,20 +151,6 @@
        /* rem: r6 = new lwp */
        /* rem: interrupts are enabled */
 
-       /*
-        * If the old lwp on entry to cpu_switchto was zero then the
-        * process that called it was exiting. This means that we do
-        * not need to save the current context. Instead we can jump
-        * straight to restoring the context for the new process.
-        */
-       teq     r4, #0
-       beq     .Ldo_switch
-
-       /* rem: r4 = old lwp */
-       /* rem: r5 = curcpu() */
-       /* rem: r6 = new lwp */
-       /* rem: interrupts are enabled */
-
        /* Save old context */
 
        /* Get the user structure for the old lwp. */
@@ -192,14 +178,8 @@
         * them for the new process.
         */
 
-       /* rem: r4 = old lwp */
-       /* rem: r5 = curcpu() */
-       /* rem: r6 = new lwp */
-       /* rem: interrupts are enabled */
-
        /* Restore saved context */
 
-.Ldo_switch:
        /* rem: r4 = old lwp */
        /* rem: r5 = curcpu() */
        /* rem: r6 = new lwp */
diff -r 7c456520eed2 -r c6f9b3fb25af sys/arch/hppa/hppa/locore.S
--- a/sys/arch/hppa/hppa/locore.S       Wed Jan 08 20:49:22 2020 +0000
+++ b/sys/arch/hppa/hppa/locore.S       Wed Jan 08 20:59:18 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: locore.S,v 1.3 2019/04/16 20:33:36 skrll Exp $ */
+/*     $NetBSD: locore.S,v 1.4 2020/01/08 20:59:18 skrll Exp $ */
 /*     $OpenBSD: locore.S,v 1.158 2008/07/28 19:08:46 miod Exp $       */
 
 /*
@@ -836,9 +836,6 @@
 kstack_ok:
 #endif
 
-       /* If old LWP exited, don't bother saving anything. */
-       comb,=,n %r0, %arg0, switch_exited
-
        /*
         * save old LWP context
         *
@@ -876,7 +873,6 @@
         * arg0: old LWP (oldl)
         * arg1: new LWP (newl)
         */
-switch_exited:
        ldw     L_MD(%arg1), %t1
        ldw     L_PCB(%arg1), %t3
        ldw     PCB_KSP(%t3), %sp               /* restore stack of newl */
diff -r 7c456520eed2 -r c6f9b3fb25af sys/arch/m68k/m68k/switch_subr.s
--- a/sys/arch/m68k/m68k/switch_subr.s  Wed Jan 08 20:49:22 2020 +0000
+++ b/sys/arch/m68k/m68k/switch_subr.s  Wed Jan 08 20:59:18 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: switch_subr.s,v 1.33 2018/10/02 18:37:31 mrg Exp $     */
+/*     $NetBSD: switch_subr.s,v 1.34 2020/01/08 20:59:18 skrll Exp $   */
 
 /*
  * Copyright (c) 2001 The NetBSD Foundation.
@@ -89,14 +89,6 @@
  */
 ENTRY(cpu_switchto)
        movl    4(%sp),%a1              | fetch `current' lwp
-#ifdef M68010
-       movl    %a1,%d0
-       tstl    %d0
-#else
-       tstl    %a1                     | Old LWP exited?
-#endif
-       jeq     .Lcpu_switch_noctxsave  | Yup. Don't bother saving context
-
        /*
         * Save state of previous process in its pcb.
         */
@@ -140,7 +132,6 @@
 #endif /* FPCOPROC */
 #endif /* !_M68K_CUSTOM_FPU_CTX */
 
-.Lcpu_switch_noctxsave:
        movl    8(%sp),%a0              | get newlwp
        movl    %a0,_C_LABEL(curlwp)
        movl    L_PCB(%a0),%a1          | get its pcb
diff -r 7c456520eed2 -r c6f9b3fb25af sys/arch/mips/mips/locore.S
--- a/sys/arch/mips/mips/locore.S       Wed Jan 08 20:49:22 2020 +0000
+++ b/sys/arch/mips/mips/locore.S       Wed Jan 08 20:59:18 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: locore.S,v 1.221 2020/01/08 17:38:42 ad Exp $  */
+/*     $NetBSD: locore.S,v 1.222 2020/01/08 20:59:19 skrll Exp $       */
 
 /*
  * Copyright (c) 1992, 1993
@@ -63,7 +63,7 @@
 #include <mips/trap.h>
 #include <mips/locore.h>
 
-RCSID("$NetBSD: locore.S,v 1.221 2020/01/08 17:38:42 ad Exp $")
+RCSID("$NetBSD: locore.S,v 1.222 2020/01/08 20:59:19 skrll Exp $")
 
 #include "assym.h"
 
@@ -244,10 +244,8 @@
 #endif
 #endif /* PARANOIA */
        /*
-        * Save old context, unless the LWP is exiting.
+        * Save old context
         */
-       beq     a0, zero, 1f
-        nop
        PTR_L   a2, L_PCB(a0)                   # a2 = pcb of old lwp
        mfc0    t0, MIPS_COP_0_STATUS
        REG_PROLOGUE
@@ -268,7 +266,7 @@
        REG_S   gp, PCB_CONTEXT+SF_REG_GP(a2)
 #endif
        REG_EPILOGUE
-1:
+
 #if defined(PARANOID_SPL)
        /*
         * Verify interrupt configuration matches IPL_SCHED
diff -r 7c456520eed2 -r c6f9b3fb25af sys/arch/powerpc/powerpc/locore_subr.S
--- a/sys/arch/powerpc/powerpc/locore_subr.S    Wed Jan 08 20:49:22 2020 +0000
+++ b/sys/arch/powerpc/powerpc/locore_subr.S    Wed Jan 08 20:59:18 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: locore_subr.S,v 1.58 2020/01/08 17:38:42 ad Exp $      */
+/*     $NetBSD: locore_subr.S,v 1.59 2020/01/08 20:59:19 skrll Exp $   */
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -156,7 +156,7 @@
  * struct lwp *
  * cpu_switchto(struct lwp *current, struct lwp *new)
  * switch to the indicated new LWP.
- *     r3 - current LWP (maybe NULL, if so don't save state)
+ *     r3 - current LWP
  *     r4 - LWP to switch to
  *     scheduler lock held
  *     SPL is IPL_SCHED.
@@ -179,12 +179,6 @@
        tweqi   %r0,0   
 #endif
 
-       /* 
-        * If the oldlwp was null, don't bother saving the switch state.
-        */
-       cmpwi   %r30,0
-       beq     switchto_restore
-
 #if defined (PPC_OEA) || defined (PPC_OEA64_BRIDGE)
        mfsr    %r10,USER_SR            /* save USER_SR for copyin/copyout */
 #else
@@ -202,7 +196,6 @@
        streg   %r9,PCB_USPRG0(%r4)     /* save in PCB, not switchframe. */
 #endif
 
-switchto_restore:
 /* Lock the scheduler. */
 #if defined(PPC_IBM4XX) || defined(PPC_BOOKE)
        wrteei  0                       /* disable interrupts while
diff -r 7c456520eed2 -r c6f9b3fb25af sys/arch/riscv/riscv/locore.S
--- a/sys/arch/riscv/riscv/locore.S     Wed Jan 08 20:49:22 2020 +0000
+++ b/sys/arch/riscv/riscv/locore.S     Wed Jan 08 20:59:18 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: locore.S,v 1.10 2020/01/08 17:38:42 ad Exp $ */
+/* $NetBSD: locore.S,v 1.11 2020/01/08 20:59:19 skrll Exp $ */
 /*-



Home | Main Index | Thread Index | Old Index