Module Name:    src
Committed By:   riastradh
Date:           Wed Feb 17 19:44:40 UTC 2016

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

Log Message:
Don't schedule a softint if we have nothing to do.

Some systems seem to have gotten stuck in a softint processing loop
doing nothing and then trying to do it again.  Might fix gson's
frozen qemu/anita sparc autobuilds -- tested on macallan's real sparc
hardware and confirmed to fix at least some freeze at boot.


To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 src/sys/kern/kern_rndq.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_rndq.c
diff -u src/sys/kern/kern_rndq.c:1.80 src/sys/kern/kern_rndq.c:1.81
--- src/sys/kern/kern_rndq.c:1.80	Wed Feb 17 01:23:32 2016
+++ src/sys/kern/kern_rndq.c	Wed Feb 17 19:44:40 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_rndq.c,v 1.80 2016/02/17 01:23:32 riastradh Exp $	*/
+/*	$NetBSD: kern_rndq.c,v 1.81 2016/02/17 19:44:40 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1997-2013 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_rndq.c,v 1.80 2016/02/17 01:23:32 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_rndq.c,v 1.81 2016/02/17 19:44:40 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/atomic.h>
@@ -297,15 +297,15 @@ rnd_getmore(size_t byteswanted)
 	mutex_spin_exit(&rnd_global.lock);
 
 	/*
-	 * Assume some callback is likely to have entered entropy
-	 * synchronously.  In that case, we may need to distribute
-	 * entropy to waiters.  Do that, if we can do it
-	 * asynchronously.  (Otherwise we may end up trying to
-	 * distribute to the very rndsink that is trying to get more
-	 * entropy in the first place, leading to lock recursion in
-	 * that rndsink's callback.)
+	 * Check whether we got entropy samples to process.  In that
+	 * case, we may need to distribute entropy to waiters.  Do
+	 * that, if we can do it asynchronously.
+	 *
+	 * - Conditionally because we don't want a softint loop.
+	 * - Asynchronously because if we did it synchronously, we may
+	 *   end up with lock recursion on rndsinks_lock.
 	 */
-	if (__predict_true(rnd_process))
+	if (!SIMPLEQ_EMPTY(&rnd_samples.q) && rnd_process != NULL)
 		rnd_schedule_process();
 }
 

Reply via email to