Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 376278
b: refs/heads/master
c: 10b3a32
h: refs/heads/master
v: v3
  • Loading branch information
Jiri Kosina authored and Linus Torvalds committed May 24, 2013
1 parent 3277ec2 commit b4a50b9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 1e7e2e05c179a68aaf8830fe91547a87f4589e53
refs/heads/master: 10b3a32d292c21ea5b3ad5ca5975e88bb20b8d68
24 changes: 16 additions & 8 deletions trunk/drivers/char/random.c
Original file line number Diff line number Diff line change
Expand Up @@ -865,16 +865,24 @@ static size_t account(struct entropy_store *r, size_t nbytes, int min,
if (r->entropy_count / 8 < min + reserved) {
nbytes = 0;
} else {
int entropy_count, orig;
retry:
entropy_count = orig = ACCESS_ONCE(r->entropy_count);
/* If limited, never pull more than available */
if (r->limit && nbytes + reserved >= r->entropy_count / 8)
nbytes = r->entropy_count/8 - reserved;

if (r->entropy_count / 8 >= nbytes + reserved)
r->entropy_count -= nbytes*8;
else
r->entropy_count = reserved;
if (r->limit && nbytes + reserved >= entropy_count / 8)
nbytes = entropy_count/8 - reserved;

if (entropy_count / 8 >= nbytes + reserved) {
entropy_count -= nbytes*8;
if (cmpxchg(&r->entropy_count, orig, entropy_count) != orig)
goto retry;
} else {
entropy_count = reserved;
if (cmpxchg(&r->entropy_count, orig, entropy_count) != orig)
goto retry;
}

if (r->entropy_count < random_write_wakeup_thresh)
if (entropy_count < random_write_wakeup_thresh)
wakeup_write = 1;
}

Expand Down

0 comments on commit b4a50b9

Please sign in to comment.