Skip to content

Commit

Permalink
random: forget lock in lockless accounting
Browse files Browse the repository at this point in the history
The only mutable data accessed here is ->entropy_count, but since
10b3a32 ("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>
  • Loading branch information
Greg Price authored and Theodore Ts'o committed Mar 20, 2014
1 parent ee1de40 commit a58aa4e
Showing 1 changed file with 0 additions and 4 deletions.
4 changes: 0 additions & 4 deletions drivers/char/random.c
Original file line number Diff line number Diff line change
Expand Up @@ -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? */
Expand All @@ -995,7 +992,6 @@ static size_t account(struct entropy_store *r, size_t nbytes, int min,
< random_write_wakeup_thresh)
wakeup_write = 1;
}
spin_unlock_irqrestore(&r->lock, flags);

trace_debit_entropy(r->name, 8 * ibytes);
if (wakeup_write) {
Expand Down

0 comments on commit a58aa4e

Please sign in to comment.