mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Jörn Engel" <joern@purestorage.com>
To: "Theodore Ts'o" <tytso@mit.edu>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] random: initialize pools faster
Date: Mon, 13 Jul 2015 13:25:04 -0700	[thread overview]
Message-ID: <20150713202504.GF32078@Sligo.logfs.org> (raw)

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


                 reply	other threads:[~2015-07-13 20:25 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150713202504.GF32078@Sligo.logfs.org \
    --to=joern@purestorage.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®