lkml.org 
[lkml]   [2013]   [Nov]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    Subject[PATCH 09/11] random: forget lock in lockless accounting
    The only mutable data accessed here is ->entropy_count, but since
    902c098a3 ("random: use lockless techniques in the interrupt path")
    that member isn't protected by the lock anyway. 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>
    Cc: "Theodore Ts'o" <tytso@mit.edu>
    Signed-off-by: Greg Price <price@mit.edu>
    ---
    drivers/char/random.c | 5 -----
    1 file changed, 5 deletions(-)

    diff --git a/drivers/char/random.c b/drivers/char/random.c
    index 9e4645e..1bf6bf8 100644
    --- a/drivers/char/random.c
    +++ b/drivers/char/random.c
    @@ -843,9 +843,6 @@ static size_t account(struct entropy_store *r, size_t nbytes, int min,
    unsigned long flags;
    int wakeup_write = 0;

    - /* Hold lock while accounting */
    - spin_lock_irqsave(&r->lock, flags);
    -
    BUG_ON(r->entropy_count > r->poolinfo->POOLBITS);
    DEBUG_ENT("trying to extract %zu bits from %s\n",
    nbytes * 8, r->name);
    @@ -871,8 +868,6 @@ retry:
    DEBUG_ENT("debiting %zu entropy credits from %s%s\n",
    nbytes * 8, r->name, r->limit ? "" : " (unlimited)");

    - spin_unlock_irqrestore(&r->lock, flags);
    -
    if (wakeup_write) {
    wake_up_interruptible(&random_write_wait);
    kill_fasync(&fasync, SIGIO, POLL_OUT);
    --
    1.8.3.2


    \
     
     \ /
      Last update: 2013-11-08 01:21    [W:3.134 / U:0.312 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site