Module Name:    src
Committed By:   knakahara
Date:           Thu Dec 24 02:27:14 UTC 2015

Modified Files:
        src/sys/kern: kern_softint.c

Log Message:
fix the following softint parallel operation problem.

(0) softint handler "handler A" is established
(1) CPU#X does softint_schedule() for "handler A"
    - the softhand_t is set SOFTINT_PENDING flag
    - the softhand_t is NOT set SOFTINT_ACTIVE flag yet
(2) CPU#X begins other H/W interrupt processing
(3) CPU#Y does softint_disestablish() for "handler A"
    - waits until softhand_t's SOFTINT_ACTIVE of all CPUs is clear
    - the softhand_t is set not SOFTINT_ACTIVE but SOFTINT_PENDING,
      so CPU#Y does not wait
    - unset the function of "handler A"
(4) CPU#X does softint_execute()
    - the function of "handler A" is already clear, so panic


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 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.41 src/sys/kern/kern_softint.c:1.42
--- src/sys/kern/kern_softint.c:1.41	Sun May 25 15:42:01 2014
+++ src/sys/kern/kern_softint.c	Thu Dec 24 02:27:14 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_softint.c,v 1.41 2014/05/25 15:42:01 rmind Exp $	*/
+/*	$NetBSD: kern_softint.c,v 1.42 2015/12/24 02:27:14 knakahara Exp $	*/
 
 /*-
  * Copyright (c) 2007, 2008 The NetBSD Foundation, Inc.
@@ -170,7 +170,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_softint.c,v 1.41 2014/05/25 15:42:01 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_softint.c,v 1.42 2015/12/24 02:27:14 knakahara Exp $");
 
 #include <sys/param.h>
 #include <sys/proc.h>
@@ -442,8 +442,8 @@ softint_disestablish(void *arg)
 			KASSERT(sh->sh_func != NULL);
 			flags |= sh->sh_flags;
 		}
-		/* Inactive on all CPUs? */
-		if ((flags & SOFTINT_ACTIVE) == 0) {
+		/* Neither pending nor active on all CPUs? */
+		if ((flags & (SOFTINT_PENDING | SOFTINT_ACTIVE)) == 0) {
 			break;
 		}
 		/* Oops, still active.  Wait for it to clear. */

Reply via email to