lkml.org 
[lkml]   [2015]   [Jul]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] random: initialize pools faster
add_interrupt_randomness() can cause significant cpu overhead on
interrupt-heavy workloads. We try to limit that overhead by bailing out
quickly once we have sampled a few bits of entropy this second. If
there is enough entropy around it doesn't hurt to waste the excess.

However, we also waste entropy early in boot when we haven't even
initialized the pools yet. With this patch we initialize the pools in
1-2s while it takes 10-20s without this patch. Actual numbers depend on
hardware and fluctuate from boot to boot, but in all cases I have tested
there is a clear improvement.

Signed-off-by: Joern Engel <joern@logfs.org>
---
drivers/char/random.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/char/random.c b/drivers/char/random.c
index 9cd6968e2f92..514f67a98b88 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -898,7 +898,8 @@ void add_interrupt_randomness(int irq, int irq_flags)
add_interrupt_bench(cycles);

if ((fast_pool->count < 64) &&
- !time_after(now, fast_pool->last + HZ))
+ !time_after(now, fast_pool->last + HZ) &&
+ nonblocking_pool.initialized)
return;

r = nonblocking_pool.initialized ? &input_pool : &nonblocking_pool;
--
2.1.4


\
 
 \ /
  Last update: 2015-07-13 23:01    [W:0.037 / U:0.092 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site