Module Name:    src
Committed By:   rmind
Date:           Tue Nov 26 20:29:40 UTC 2013

Modified Files:
        src/sys/arch/x86/x86: nmi.c
        src/sys/kern: subr_pcu.c subr_xcall.c

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/x86/x86/nmi.c
cvs rdiff -u -r1.15 -r1.16 src/sys/kern/subr_pcu.c
cvs rdiff -u -r1.16 -r1.17 src/sys/kern/subr_xcall.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/x86/nmi.c
diff -u src/sys/arch/x86/x86/nmi.c:1.3 src/sys/arch/x86/x86/nmi.c:1.4
--- src/sys/arch/x86/x86/nmi.c:1.3	Wed Oct 12 00:07:29 2011
+++ src/sys/arch/x86/x86/nmi.c	Tue Nov 26 20:29:40 2013
@@ -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 @@ nmi_dispatch(const struct trapframe *tf)
 	 *
 	 * 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)
 	 */
 

Index: src/sys/kern/subr_pcu.c
diff -u src/sys/kern/subr_pcu.c:1.15 src/sys/kern/subr_pcu.c:1.16
--- src/sys/kern/subr_pcu.c:1.15	Thu Aug 22 19:50:55 2013
+++ src/sys/kern/subr_pcu.c	Tue Nov 26 20:29:40 2013
@@ -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 @@ pcu_switchpoint(lwp_t *l)
 		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 @@ pcu_discard_all(lwp_t *l)
 		/* 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 @@ pcu_save_all(lwp_t *l)
 		/* 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_save_all(lwp_t *l)
 /*
  * 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 @@ pcu_lwp_op(const pcu_ops_t *pcu, lwp_t *
 	 * 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 @@ pcu_load(const pcu_ops_t *pcu)
 
 	KASSERT(!cpu_intr_p() && !cpu_softintr_p());
 
-	s = splsoftclock();
+	s = splsoftserial();
 	curci = curcpu();
 	ci = l->l_pcu_cpu[id];
 
@@ -365,8 +365,8 @@ pcu_load(const pcu_ops_t *pcu)
 		    __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);

Index: src/sys/kern/subr_xcall.c
diff -u src/sys/kern/subr_xcall.c:1.16 src/sys/kern/subr_xcall.c:1.17
--- src/sys/kern/subr_xcall.c:1.16	Fri Oct 25 16:18:36 2013
+++ src/sys/kern/subr_xcall.c	Tue Nov 26 20:29:40 2013
@@ -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_init(void)
 	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);
 

Reply via email to