[patch] sched: fix latency in random driver

Ingo Molnar
2004-09-14T09:56:32Z

[-- Attachment #1: Type: text/plain, Size: 255 bytes --]

the attached patch fixes possibly long scheduling latencies in the
/dev/random driver's rekey_seq_generator() function, by moving the
expensive get_random_bytes() function out from under ip_lock.

has been in the -VP patchset for quite some time.

Ingo

[-- Attachment #2: fix-latency-random.patch --]
[-- Type: text/plain, Size: 955 bytes --]

the attached patch fixes possibly long scheduling latencies in the
/dev/random driver's rekey_seq_generator() function, by moving the
expensive get_random_bytes() function out from under ip_lock.

has been in the -VP patchset for quite some time.

Signed-off-by: Ingo Molnar <mingo@elte.hu>

--- linux/drivers/char/random.c.orig
+++ linux/drivers/char/random.c
@@ -2220,17 +2220,18 @@ static unsigned int ip_cnt;

static void rekey_seq_generator(void *private_)
{
- struct keydata *keyptr;
+ struct keydata *keyptr, tmp;
struct timeval tv;

do_gettimeofday(&tv);
+ get_random_bytes(tmp.secret, sizeof(tmp.secret));

spin_lock_bh(&ip_lock);
keyptr = &ip_keydata[ip_cnt&1];

keyptr = &ip_keydata[1^(ip_cnt&1)];
keyptr->rekey_time = tv.tv_sec;
- get_random_bytes(keyptr->secret, sizeof(keyptr->secret));
+ memcpy(keyptr->secret, tmp.secret, sizeof(keyptr->secret));
keyptr->count = (ip_cnt&COUNT_MASK)<<HASH_BITS;
mb();
ip_cnt++;