Source-Changes-HG archive

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

[src/trunk]: src/sys mi_userret(): take care of calling preempt(), set spc_cu...



details:   https://anonhg.NetBSD.org/src/rev/0c27a9605f9f
branches:  trunk
changeset: 461283:0c27a9605f9f
user:      ad <ad%NetBSD.org@localhost>
date:      Thu Nov 21 19:23:58 2019 +0000

description:
mi_userret(): take care of calling preempt(), set spc_curpriority directly,
and remove MD code that does the same.

diffstat:

 sys/arch/aarch64/aarch64/trap.c   |   8 +----
 sys/arch/aarch64/include/cpu.h    |   3 +-
 sys/arch/alpha/alpha/trap.c       |  11 +------
 sys/arch/amd64/amd64/cpufunc.S    |   7 +----
 sys/arch/amd64/amd64/trap.c       |   8 +----
 sys/arch/amd64/include/cpu.h      |  14 +---------
 sys/arch/amiga/amiga/trap.c       |   7 +---
 sys/arch/arm/arm/ast.c            |   8 +----
 sys/arch/arm/include/cpu.h        |   5 +--
 sys/arch/atari/atari/trap.c       |   6 +--
 sys/arch/cesfic/cesfic/trap.c     |   6 +--
 sys/arch/hp300/hp300/trap.c       |   6 +--
 sys/arch/hppa/hppa/trap.c         |  13 ++------
 sys/arch/i386/i386/cpufunc.S      |  10 +-----
 sys/arch/i386/i386/trap.c         |   8 +----
 sys/arch/i386/include/cpu.h       |  13 +--------
 sys/arch/luna68k/luna68k/trap.c   |   6 +--
 sys/arch/mac68k/mac68k/trap.c     |   6 +--
 sys/arch/mips/include/cpu.h       |   8 +-----
 sys/arch/mvme68k/mvme68k/trap.c   |   6 +--
 sys/arch/news68k/news68k/trap.c   |   6 +--
 sys/arch/next68k/next68k/trap.c   |   6 +--
 sys/arch/or1k/include/cpu.h       |   3 +-
 sys/arch/riscv/include/cpu.h      |   3 +-
 sys/arch/riscv/riscv/trap.c       |   6 +---
 sys/arch/sh3/sh3/exception.c      |   9 +-----
 sys/arch/sparc/include/userret.h  |  10 +------
 sys/arch/sparc64/sparc64/trap.c   |   6 +--
 sys/arch/sun2/sun2/trap.c         |   7 +---
 sys/arch/sun3/sun3/trap.c         |   6 +--
 sys/arch/usermode/usermode/trap.c |  10 +-----
 sys/arch/vax/vax/trap.c           |   6 +--
 sys/arch/x68k/x68k/trap.c         |   6 +--
 sys/sys/userret.h                 |  53 ++++++++++++++++----------------------
 34 files changed, 80 insertions(+), 216 deletions(-)

diffs (truncated from 989 to 300 lines):

diff -r 20fb41957875 -r 0c27a9605f9f sys/arch/aarch64/aarch64/trap.c
--- a/sys/arch/aarch64/aarch64/trap.c   Thu Nov 21 19:23:16 2019 +0000
+++ b/sys/arch/aarch64/aarch64/trap.c   Thu Nov 21 19:23:58 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: trap.c,v 1.19 2019/09/28 07:06:50 skrll Exp $ */
+/* $NetBSD: trap.c,v 1.20 2019/11/21 19:23:58 ad Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.19 2019/09/28 07:06:50 skrll Exp $");
+__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.20 2019/11/21 19:23:58 ad Exp $");
 
 #include "opt_arm_intr_impl.h"
 #include "opt_compat_netbsd32.h"
@@ -158,7 +158,6 @@
        ci->ci_data.cpu_ntrap++;
 
        KDASSERT(ci->ci_cpl == IPL_NONE);
-       const int want_resched = ci->ci_want_resched;
 #ifdef __HAVE_PREEMPTION
        kpreempt_enable();
 #endif
@@ -168,9 +167,6 @@
                ADDUPROF(l);
        }
 
-       /* Allow a forced task switch. */
-       if (want_resched)
-               preempt();
        userret(l);
 }
 
diff -r 20fb41957875 -r 0c27a9605f9f sys/arch/aarch64/include/cpu.h
--- a/sys/arch/aarch64/include/cpu.h    Thu Nov 21 19:23:16 2019 +0000
+++ b/sys/arch/aarch64/include/cpu.h    Thu Nov 21 19:23:58 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.h,v 1.14 2019/10/19 18:04:26 jmcneill Exp $ */
+/* $NetBSD: cpu.h,v 1.15 2019/11/21 19:23:58 ad Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -118,7 +118,6 @@
 #define setsoftast(ci)         atomic_or_uint(&(ci)->ci_astpending, __BIT(0))
 #define cpu_signotify(l)       setsoftast((l)->l_cpu)
 
-void cpu_set_curpri(int);
 void cpu_proc_fork(struct proc *, struct proc *);
 void cpu_need_proftick(struct lwp *l);
 void cpu_boot_secondary_processors(void);
diff -r 20fb41957875 -r 0c27a9605f9f sys/arch/alpha/alpha/trap.c
--- a/sys/arch/alpha/alpha/trap.c       Thu Nov 21 19:23:16 2019 +0000
+++ b/sys/arch/alpha/alpha/trap.c       Thu Nov 21 19:23:58 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: trap.c,v 1.134 2019/04/06 03:06:24 thorpej Exp $ */
+/* $NetBSD: trap.c,v 1.135 2019/11/21 19:23:58 ad Exp $ */
 
 /*-
  * Copyright (c) 2000, 2001 The NetBSD Foundation, Inc.
@@ -93,7 +93,7 @@
 
 #include <sys/cdefs.h>                 /* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.134 2019/04/06 03:06:24 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.135 2019/11/21 19:23:58 ad Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -603,13 +603,6 @@
                ADDUPROF(l);
        }
 
-       if (curcpu()->ci_want_resched) {
-               /*
-                * We are being preempted.
-                */
-               preempt();
-       }
-
        userret(l);
 }
 
diff -r 20fb41957875 -r 0c27a9605f9f sys/arch/amd64/amd64/cpufunc.S
--- a/sys/arch/amd64/amd64/cpufunc.S    Thu Nov 21 19:23:16 2019 +0000
+++ b/sys/arch/amd64/amd64/cpufunc.S    Thu Nov 21 19:23:58 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpufunc.S,v 1.48 2019/11/15 09:03:26 maxv Exp $        */
+/*     $NetBSD: cpufunc.S,v 1.49 2019/11/21 19:23:58 ad Exp $  */
 
 /*
  * Copyright (c) 1998, 2007, 2008 The NetBSD Foundation, Inc.
@@ -251,11 +251,6 @@
        ret
 END(x86_curlwp)
 
-ENTRY(cpu_set_curpri)
-       movl    %edi, %gs:(CPU_INFO_CURPRIORITY)
-       ret
-END(cpu_set_curpri)
-
 ENTRY(__byte_swap_u32_variable)
        movl    %edi, %eax
        bswapl  %eax
diff -r 20fb41957875 -r 0c27a9605f9f sys/arch/amd64/amd64/trap.c
--- a/sys/arch/amd64/amd64/trap.c       Thu Nov 21 19:23:16 2019 +0000
+++ b/sys/arch/amd64/amd64/trap.c       Thu Nov 21 19:23:58 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: trap.c,v 1.124 2019/09/18 20:18:27 kamil Exp $ */
+/*     $NetBSD: trap.c,v 1.125 2019/11/21 19:23:58 ad Exp $    */
 
 /*
  * Copyright (c) 1998, 2000, 2017 The NetBSD Foundation, Inc.
@@ -64,7 +64,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.124 2019/09/18 20:18:27 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.125 2019/11/21 19:23:58 ad Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -426,10 +426,6 @@
                        l->l_pflag &= ~LP_OWEUPC;
                        ADDUPROF(l);
                }
-               /* Allow a forced task switch. */
-               if (curcpu()->ci_want_resched) {
-                       preempt();
-               }
                goto out;
 
        case T_BOUND|T_USER:
diff -r 20fb41957875 -r 0c27a9605f9f sys/arch/amd64/include/cpu.h
--- a/sys/arch/amd64/include/cpu.h      Thu Nov 21 19:23:16 2019 +0000
+++ b/sys/arch/amd64/include/cpu.h      Thu Nov 21 19:23:58 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpu.h,v 1.65 2019/11/14 16:23:52 maxv Exp $    */
+/*     $NetBSD: cpu.h,v 1.66 2019/11/21 19:23:58 ad Exp $      */
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -82,21 +82,9 @@
            (*(struct cpu_info * const *)offsetof(struct cpu_info, ci_curlwp)));
        return l;
 }
-
-__inline static void __unused
-cpu_set_curpri(int pri)
-{
-
-       __asm volatile(
-           "movl %1, %%gs:%0" :
-           "=m" (*(struct cpu_info *)offsetof(struct cpu_info, ci_schedstate.spc_curpriority)) :
-           "r" (pri)
-       );
-}
 #else
 struct cpu_info *x86_curcpu(void);
 lwp_t *x86_curlwp(void);
-void cpu_set_curpri(int);
 #endif
 
 #endif /* __GNUC__ && !_MODULE */
diff -r 20fb41957875 -r 0c27a9605f9f sys/arch/amiga/amiga/trap.c
--- a/sys/arch/amiga/amiga/trap.c       Thu Nov 21 19:23:16 2019 +0000
+++ b/sys/arch/amiga/amiga/trap.c       Thu Nov 21 19:23:58 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: trap.c,v 1.137 2019/04/06 03:06:24 thorpej Exp $       */
+/*     $NetBSD: trap.c,v 1.138 2019/11/21 19:23:58 ad Exp $    */
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -45,7 +45,7 @@
 #include "opt_m68k_arch.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.137 2019/04/06 03:06:24 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.138 2019/11/21 19:23:58 ad Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -691,9 +691,6 @@
                        l->l_pflag &= ~LP_OWEUPC;
                        ADDUPROF(l);
                }
-               if (curcpu()->ci_want_resched)
-                       preempt();
-
                userret(l, fp->f_pc, sticks);
                return;
        /*
diff -r 20fb41957875 -r 0c27a9605f9f sys/arch/arm/arm/ast.c
--- a/sys/arch/arm/arm/ast.c    Thu Nov 21 19:23:16 2019 +0000
+++ b/sys/arch/arm/arm/ast.c    Thu Nov 21 19:23:58 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ast.c,v 1.30 2018/01/24 09:04:44 skrll Exp $   */
+/*     $NetBSD: ast.c,v 1.31 2019/11/21 19:23:59 ad Exp $      */
 
 /*
  * Copyright (c) 1994,1995 Mark Brinicombe
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ast.c,v 1.30 2018/01/24 09:04:44 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ast.c,v 1.31 2019/11/21 19:23:59 ad Exp $");
 
 #include "opt_ddb.h"
 
@@ -119,7 +119,6 @@
        ci->ci_data.cpu_ntrap++;
 
        KDASSERT(ci->ci_cpl == IPL_NONE);
-       const int want_resched = ci->ci_want_resched;
 #ifdef __HAVE_PREEMPTION
        kpreempt_enable();
 #endif
@@ -129,8 +128,5 @@
                ADDUPROF(l);
        }
 
-       /* Allow a forced task switch. */
-       if (want_resched)
-               preempt();
        userret(l);
 }
diff -r 20fb41957875 -r 0c27a9605f9f sys/arch/arm/include/cpu.h
--- a/sys/arch/arm/include/cpu.h        Thu Nov 21 19:23:16 2019 +0000
+++ b/sys/arch/arm/include/cpu.h        Thu Nov 21 19:23:58 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpu.h,v 1.101 2019/10/19 18:04:26 jmcneill Exp $       */
+/*     $NetBSD: cpu.h,v 1.102 2019/11/21 19:23:59 ad Exp $     */
 
 /*
  * Copyright (c) 1994-1996 Mark Brinicombe.
@@ -315,9 +315,6 @@
 #define        cpu_need_proftick(l)    ((l)->l_pflag |= LP_OWEUPC, \
                                 setsoftast((l)->l_cpu))
 
-/* for preeemption. */
-void   cpu_set_curpri(int);
-
 /*
  * We've already preallocated the stack for the idlelwps for additional CPUs.
  * This hook allows to return them.
diff -r 20fb41957875 -r 0c27a9605f9f sys/arch/atari/atari/trap.c
--- a/sys/arch/atari/atari/trap.c       Thu Nov 21 19:23:16 2019 +0000
+++ b/sys/arch/atari/atari/trap.c       Thu Nov 21 19:23:58 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: trap.c,v 1.115 2019/04/06 03:06:25 thorpej Exp $       */
+/*     $NetBSD: trap.c,v 1.116 2019/11/21 19:23:59 ad Exp $    */
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.115 2019/04/06 03:06:25 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.116 2019/11/21 19:23:59 ad Exp $");
 
 #include "opt_ddb.h"
 #include "opt_execfmt.h"
@@ -545,8 +545,6 @@
                        l->l_pflag &= ~LP_OWEUPC;
                        ADDUPROF(l);
                }
-               if (curcpu()->ci_want_resched)
-                       preempt();
                goto out;
        /*
         * Kernel/User page fault
diff -r 20fb41957875 -r 0c27a9605f9f sys/arch/cesfic/cesfic/trap.c
--- a/sys/arch/cesfic/cesfic/trap.c     Thu Nov 21 19:23:16 2019 +0000
+++ b/sys/arch/cesfic/cesfic/trap.c     Thu Nov 21 19:23:58 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: trap.c,v 1.59 2019/04/06 03:06:25 thorpej Exp $        */
+/*     $NetBSD: trap.c,v 1.60 2019/11/21 19:23:59 ad Exp $     */
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.59 2019/04/06 03:06:25 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.60 2019/11/21 19:23:59 ad Exp $");
 
 #include "opt_ddb.h"
 #include "opt_execfmt.h"
@@ -503,8 +503,6 @@
                        l->l_pflag &= ~LP_OWEUPC;
                        ADDUPROF(l);
                }
-               if (curcpu()->ci_want_resched)
-                       preempt();
                goto out;



Home | Main Index | Thread Index | Old Index