Module Name: src
Committed By: ad
Date: Sat Jan 25 15:12:47 UTC 2020
Modified Files:
src/sys/kern: kern_softint.c
Log Message:
softint_execute(): don't hang onto the kernel_lock hold longer than
needed.
To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 src/sys/kern/kern_softint.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/kern/kern_softint.c
diff -u src/sys/kern/kern_softint.c:1.57 src/sys/kern/kern_softint.c:1.58
--- src/sys/kern/kern_softint.c:1.57 Wed Jan 8 17:38:42 2020
+++ src/sys/kern/kern_softint.c Sat Jan 25 15:12:47 2020
@@ -1,7 +1,7 @@
-/* $NetBSD: kern_softint.c,v 1.57 2020/01/08 17:38:42 ad Exp $ */
+/* $NetBSD: kern_softint.c,v 1.58 2020/01/25 15:12:47 ad Exp $ */
/*-
- * Copyright (c) 2007, 2008, 2019 The NetBSD Foundation, Inc.
+ * Copyright (c) 2007, 2008, 2019, 2020 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@@ -170,7 +170,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_softint.c,v 1.57 2020/01/08 17:38:42 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_softint.c,v 1.58 2020/01/25 15:12:47 ad Exp $");
#include <sys/param.h>
#include <sys/proc.h>
@@ -544,7 +544,6 @@ static inline void
softint_execute(softint_t *si, lwp_t *l, int s)
{
softhand_t *sh;
- bool havelock;
#ifdef __HAVE_FAST_SOFTINTS
KASSERT(si->si_lwp == curlwp);
@@ -555,8 +554,6 @@ softint_execute(softint_t *si, lwp_t *l,
KASSERT(si->si_lwp->l_wchan == NULL);
KASSERT(si->si_active);
- havelock = false;
-
/*
* Note: due to priority inheritance we may have interrupted a
* higher priority LWP. Since the soft interrupt must be quick
@@ -577,17 +574,14 @@ softint_execute(softint_t *si, lwp_t *l,
splx(s);
/* Run the handler. */
- if (sh->sh_flags & SOFTINT_MPSAFE) {
- if (havelock) {
- KERNEL_UNLOCK_ONE(l);
- havelock = false;
- }
- } else if (!havelock) {
+ if (__predict_true((sh->sh_flags & SOFTINT_MPSAFE) != 0)) {
+ (*sh->sh_func)(sh->sh_arg);
+ } else {
KERNEL_LOCK(1, l);
- havelock = true;
+ (*sh->sh_func)(sh->sh_arg);
+ KERNEL_UNLOCK_ONE(l);
}
- (*sh->sh_func)(sh->sh_arg);
-
+
/* Diagnostic: check that spin-locks have not leaked. */
KASSERTMSG(curcpu()->ci_mtx_count == 0,
"%s: ci_mtx_count (%d) != 0, sh_func %p\n",
@@ -603,10 +597,6 @@ softint_execute(softint_t *si, lwp_t *l,
PSREF_DEBUG_BARRIER();
- if (havelock) {
- KERNEL_UNLOCK_ONE(l);
- }
-
CPU_COUNT(CPU_COUNT_NSOFT, 1);
KASSERT(si->si_cpu == curcpu());