From 446ef7b7a79cd6813e1cdf29d996154ef4f68165 Mon Sep 17 00:00:00 2001 From: riastradh Date: Wed, 17 Feb 2016 19:44:40 +0000 Subject: [PATCH] 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. --- sys/kern/kern_rndq.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/sys/kern/kern_rndq.c b/sys/kern/kern_rndq.c index f22b2b5326ab..a1e9d8a46513 100644 --- a/sys/kern/kern_rndq.c +++ b/sys/kern/kern_rndq.c @@ -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 -__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 #include @@ -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(); }