lkml.org 
[lkml]   [2014]   [Mar]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[PATCH] random: give up adding randomness to the entropy pool when block devices are busy
From
Date
Hi,

This gives up adding randomness to the entropy pool when block devices
are busy, to avoid lock contention in I/O intensive situation.

Currently randomness is added to the entropy pool for each 4096 I/O
completion, and holds a global spinlock during its process.
Contention for the spinlock occurs In I/O intensive situation that
many cores process I/O completions, even each core processes
completion for different block device.

This just replaces spin_lock_irqsave() in mix_pool_bytes()
with spin_trylock_irqsave(), and gives up adding randomness
when trylock is failed.
And, it moves trace_mix_pool_bytes() after lock, to trace
events only where addition of randomness is executed.

Thank you,


Signed-off-by: Kazuya Hisaki <kazuya.hisaki.bx@hitachi.com>
Cc: "Theodore Ts'o" <tytso@mit.edu>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.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 429b75b..d2603f8 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -545,8 +545,9 @@ static void mix_pool_bytes(struct entropy_store *r, const void *in,
{
unsigned long flags;

+ if (!spin_trylock_irqsave(&r->lock, flags))
+ return;
trace_mix_pool_bytes(r->name, nbytes, _RET_IP_);
- spin_lock_irqsave(&r->lock, flags);
_mix_pool_bytes(r, in, nbytes, out);
spin_unlock_irqrestore(&r->lock, flags);
}


\
 
 \ /
  Last update: 2014-03-27 13:21    [W:0.018 / U:0.740 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site