Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752908AbbGMUZL (ORCPT ); Mon, 13 Jul 2015 16:25:11 -0400 Received: from mail-pd0-f169.google.com ([209.85.192.169]:33428 "EHLO mail-pd0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751866AbbGMUZI (ORCPT ); Mon, 13 Jul 2015 16:25:08 -0400 Date: Mon, 13 Jul 2015 13:25:04 -0700 From: =?iso-8859-1?Q?J=F6rn?= Engel To: "Theodore Ts'o" Cc: linux-kernel@vger.kernel.org Subject: [PATCH] random: initialize pools faster Message-ID: <20150713202504.GF32078@Sligo.logfs.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1482 Lines: 38 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 --- 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/