lkml.org 
[lkml]   [2004]   [Sep]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    Subject[patch] sched: fix latency in random driver

    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

    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++;
    \
     
     \ /
      Last update: 2005-03-22 14:06    [W:3.448 / U:0.020 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site