Source-Changes-HG archive

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

[src/trunk]: src/sys Switch XC_HIGHPRI to run at IPL_SOFTSERIAL i.e. the high...



details:   https://anonhg.NetBSD.org/src/rev/3d01cfaf0ec0
branches:  trunk
changeset: 791631:3d01cfaf0ec0
user:      rmind <rmind%NetBSD.org@localhost>
date:      Tue Nov 26 20:29:40 2013 +0000

description:
Switch XC_HIGHPRI to run at IPL_SOFTSERIAL i.e. the highest software level.
Adjust pcu(9) to this xcall(9) change.  This may fix the problems after
x86 FPU was converted to use PCU, since it avoids heavy contention at the
lower levels (particularly, IPL_SOFTNET).  This is a good illustration why
software interrupts should generally avoid any blocking on locks.

diffstat:

 sys/arch/x86/x86/nmi.c |   6 +++---
 sys/kern/subr_pcu.c    |  20 ++++++++++----------
 sys/kern/subr_xcall.c  |  14 +++++++-------
 3 files changed, 20 insertions(+), 20 deletions(-)

diffs (148 lines):

diff -r ccef7021bb2e -r 3d01cfaf0ec0 sys/arch/x86/x86/nmi.c
--- a/sys/arch/x86/x86/nmi.c    Tue Nov 26 19:12:46 2013 +0000
+++ b/sys/arch/x86/x86/nmi.c    Tue Nov 26 20:29:40 2013 +0000
@@ -1,4 +1,4 @@
-/*     $Id: nmi.c,v 1.3 2011/10/12 00:07:29 yamt Exp $ */
+/*     $Id: nmi.c,v 1.4 2013/11/26 20:29:40 rmind Exp $        */
 
 /*-
  * Copyright (c)2009,2011 YAMAMOTO Takashi,
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nmi.c,v 1.3 2011/10/12 00:07:29 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nmi.c,v 1.4 2013/11/26 20:29:40 rmind Exp $");
 
 /*
  * nmi dispatcher.
@@ -153,7 +153,7 @@
         *
         * we don't bother to call pserialize_read_enter/pserialize_read_exit
         * because they are not necessary here as we are sure our IPL is
-        * higher than IPL_SOFTCLOCK.  better to avoid unnecessary calls as
+        * higher than IPL_SOFTSERIAL.  better to avoid unnecessary calls as
         * we are in a dangerous context. (NMI)
         */
 
diff -r ccef7021bb2e -r 3d01cfaf0ec0 sys/kern/subr_pcu.c
--- a/sys/kern/subr_pcu.c       Tue Nov 26 19:12:46 2013 +0000
+++ b/sys/kern/subr_pcu.c       Tue Nov 26 20:29:40 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: subr_pcu.c,v 1.15 2013/08/22 19:50:55 drochner Exp $   */
+/*     $NetBSD: subr_pcu.c,v 1.16 2013/11/26 20:29:40 rmind Exp $      */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -57,7 +57,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_pcu.c,v 1.15 2013/08/22 19:50:55 drochner Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_pcu.c,v 1.16 2013/11/26 20:29:40 rmind Exp $");
 
 #include <sys/param.h>
 #include <sys/cpu.h>
@@ -121,7 +121,7 @@
                return;
        }
        /* commented out as we know we are already at IPL_SCHED */
-       /* s = splsoftclock(); */
+       /* s = splsoftserial(); */
        for (u_int id = 0; id < PCU_UNIT_COUNT; id++) {
                if ((pcu_user_inuse & (1 << id)) == 0) {
                        continue;
@@ -154,7 +154,7 @@
                /* PCUs are not in use. */
                return;
        }
-       const int s = splsoftclock();
+       const int s = splsoftserial();
        for (u_int id = 0; id < PCU_UNIT_COUNT; id++) {
                if ((pcu_inuse & (1 << id)) == 0) {
                        continue;
@@ -203,7 +203,7 @@
                /* PCUs are not in use. */
                return;
        }
-       const int s = splsoftclock();
+       const int s = splsoftserial();
        for (u_int id = 0; id < PCU_UNIT_COUNT; id++) {
                if ((pcu_inuse & (1 << id)) == 0) {
                        continue;
@@ -220,7 +220,7 @@
 /*
  * pcu_do_op: save/release PCU state on the current CPU.
  *
- * => Must be called at IPL_SOFTCLOCK or from the soft-interrupt.
+ * => Must be called at IPL_SOFTSERIAL or from the soft-interrupt.
  */
 static inline void
 pcu_do_op(const pcu_ops_t *pcu, lwp_t * const l, const int flags)
@@ -294,7 +294,7 @@
         * Block the interrupts and inspect again, since cross-call sent
         * by remote CPU could have changed the state.
         */
-       s = splsoftclock();
+       s = splsoftserial();
        ci = l->l_pcu_cpu[id];
        if (ci == curcpu()) {
                /*
@@ -345,7 +345,7 @@
 
        KASSERT(!cpu_intr_p() && !cpu_softintr_p());
 
-       s = splsoftclock();
+       s = splsoftserial();
        curci = curcpu();
        ci = l->l_pcu_cpu[id];
 
@@ -365,8 +365,8 @@
                    __UNCONST(pcu), (void *)(PCU_SAVE | PCU_RELEASE), ci);
                xc_wait(where);
 
-               /* Enter IPL_SOFTCLOCK and re-fetch the current CPU. */
-               s = splsoftclock();
+               /* Enter IPL_SOFTSERIAL and re-fetch the current CPU. */
+               s = splsoftserial();
                curci = curcpu();
        }
        KASSERT(l->l_pcu_cpu[id] == NULL);
diff -r ccef7021bb2e -r 3d01cfaf0ec0 sys/kern/subr_xcall.c
--- a/sys/kern/subr_xcall.c     Tue Nov 26 19:12:46 2013 +0000
+++ b/sys/kern/subr_xcall.c     Tue Nov 26 20:29:40 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: subr_xcall.c,v 1.16 2013/10/25 16:18:36 martin Exp $   */
+/*     $NetBSD: subr_xcall.c,v 1.17 2013/11/26 20:29:40 rmind Exp $    */
 
 /*-
  * Copyright (c) 2007-2010 The NetBSD Foundation, Inc.
@@ -69,12 +69,12 @@
  *
  *     A low-overhead mechanism for high priority calls (XC_HIGHPRI) is
  *     also provided.  The function to be executed runs on a software
- *     interrupt context, at SOFTINT_CLOCK level, and is expected to be
- *     very lightweight, e.g. avoid blocking.
+ *     interrupt context, at IPL_SOFTSERIAL level, and is expected to
+ *     be very lightweight, e.g. avoid blocking.
  */
- 
+
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_xcall.c,v 1.16 2013/10/25 16:18:36 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_xcall.c,v 1.17 2013/11/26 20:29:40 rmind Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -137,9 +137,9 @@
        xc_tailp = 0;
 
        memset(xchi, 0, sizeof(xc_state_t));
-       mutex_init(&xchi->xc_lock, MUTEX_DEFAULT, IPL_SOFTCLOCK);
+       mutex_init(&xchi->xc_lock, MUTEX_DEFAULT, IPL_SOFTSERIAL);
        cv_init(&xchi->xc_busy, "xchicv");
-       xc_sih = softint_establish(SOFTINT_CLOCK | SOFTINT_MPSAFE,
+       xc_sih = softint_establish(IPL_SOFTSERIAL | SOFTINT_MPSAFE,
            xc__highpri_intr, NULL);
        KASSERT(xc_sih != NULL);
 



Home | Main Index | Thread Index | Old Index