]> git.karo-electronics.de Git - linux-beck.git/commitdiff
random: forget lock in lockless accounting
authorGreg Price <price@MIT.EDU>
Sat, 30 Nov 2013 01:09:37 +0000 (20:09 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Thu, 20 Mar 2014 02:18:51 +0000 (22:18 -0400)
The only mutable data accessed here is ->entropy_count, but since
10b3a32d2 ("random: fix accounting race condition") we use cmpxchg to
protect our accesses to ->entropy_count here.  Drop the use of the
lock.

Cc: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Greg Price <price@mit.edu>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
drivers/char/random.c

index 9675821b4b5af05b7c057e90603b329d5232392b..694510af4fcd0e9073fba46527ac26d34b19f238 100644 (file)
@@ -970,9 +970,6 @@ static size_t account(struct entropy_store *r, size_t nbytes, int min,
        int entropy_count, orig;
        size_t ibytes;
 
-       /* Hold lock while accounting */
-       spin_lock_irqsave(&r->lock, flags);
-
        BUG_ON(r->entropy_count > r->poolinfo->poolfracbits);
 
        /* Can we pull enough? */
@@ -995,7 +992,6 @@ retry:
                    < random_write_wakeup_thresh)
                        wakeup_write = 1;
        }
-       spin_unlock_irqrestore(&r->lock, flags);
 
        trace_debit_entropy(r->name, 8 * ibytes);
        if (wakeup_write) {