Module Name:    src
Committed By:   jmcneill
Date:           Mon Feb 22 21:16:25 UTC 2021

Modified Files:
        src/sys/arch/arm/pic: pic_splfuncs.c

Log Message:
Make the splx fast path smaller.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/arm/pic/pic_splfuncs.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/arm/pic/pic_splfuncs.c
diff -u src/sys/arch/arm/pic/pic_splfuncs.c:1.17 src/sys/arch/arm/pic/pic_splfuncs.c:1.18
--- src/sys/arch/arm/pic/pic_splfuncs.c:1.17	Sun Feb 21 17:07:45 2021
+++ src/sys/arch/arm/pic/pic_splfuncs.c	Mon Feb 22 21:16:25 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic_splfuncs.c,v 1.17 2021/02/21 17:07:45 jmcneill Exp $	*/
+/*	$NetBSD: pic_splfuncs.c,v 1.18 2021/02/22 21:16:25 jmcneill Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -28,7 +28,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pic_splfuncs.c,v 1.17 2021/02/21 17:07:45 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic_splfuncs.c,v 1.18 2021/02/22 21:16:25 jmcneill Exp $");
 
 #define _INTR_PRIVATE
 #include <sys/param.h>
@@ -46,23 +46,34 @@ __KERNEL_RCSID(0, "$NetBSD: pic_splfuncs
 
 #include <arm/pic/picvar.h>
 
+#if defined(__HAVE_CPU_DOSOFTINTS_CI)
+#define	CPU_DOSOFTINTS(ci)	cpu_dosoftints_ci((ci))
+#else
+#define	CPU_DOSOFTINTS(ci)	cpu_dosoftints()
+#endif
+
+#if defined(__HAVE_PIC_PENDING_INTRS)
+static void	splx_dopendingints(struct cpu_info *, const int);
+#endif
+
 int
 _splraise(int newipl)
 {
 	struct cpu_info * const ci = curcpu();
 	const int oldipl = ci->ci_cpl;
-	KASSERT(newipl < NIPL);
+	KDASSERT(newipl < NIPL);
 	if (newipl > ci->ci_cpl) {
 		pic_set_priority(ci, newipl);
 	}
 	return oldipl;
 }
+
 int
 _spllower(int newipl)
 {
 	struct cpu_info * const ci = curcpu();
 	const int oldipl = ci->ci_cpl;
-	KASSERT(panicstr || newipl <= ci->ci_cpl);
+	KDASSERT(panicstr || newipl <= ci->ci_cpl);
 	if (newipl < ci->ci_cpl) {
 		register_t psw = cpsid(I32_bit);
 		ci->ci_intr_depth++;
@@ -79,17 +90,29 @@ void
 splx(int savedipl)
 {
 	struct cpu_info * const ci = curcpu();
-	KASSERT(savedipl < NIPL);
+	KDASSERT(savedipl < NIPL);
 
 	if (__predict_false(savedipl == ci->ci_cpl)) {
 		return;
 	}
 
 #if defined(__HAVE_PIC_PENDING_INTRS)
-	if (__predict_true(ci->ci_pending_ipls == 0)) {
-		goto skip_pending;
+	if (__predict_false(ci->ci_pending_ipls != 0)) {
+		splx_dopendingints(ci, savedipl);
 	}
+#endif
+
+	pic_set_priority(ci, savedipl);
+	CPU_DOSOFTINTS(ci);
 
+	KDASSERTMSG(ci->ci_cpl == savedipl, "cpl %d savedipl %d",
+	    ci->ci_cpl, savedipl);
+}
+
+#if defined(__HAVE_PIC_PENDING_INTRS)
+static void __noinline
+splx_dopendingints(struct cpu_info *ci, const int savedipl)
+{
 	const register_t psw = cpsid(I32_bit);
 	ci->ci_intr_depth++;
 	while ((ci->ci_pending_ipls & ~__BIT(savedipl)) > __BIT(savedipl)) {
@@ -110,16 +133,5 @@ splx(int savedipl)
 	if ((psw & I32_bit) == 0) {
 		cpsie(I32_bit);
 	}
-skip_pending:
-#endif
-
-	pic_set_priority(ci, savedipl);
-#if defined(__HAVE_CPU_DOSOFTINTS_CI)
-	cpu_dosoftints_ci(ci);
-#else
-	cpu_dosoftints();
-#endif
-
-	KASSERTMSG(ci->ci_cpl == savedipl, "cpl %d savedipl %d",
-	    ci->ci_cpl, savedipl);
 }
+#endif

Reply via email to