lkml.org 
[lkml]   [2014]   [Aug]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH v2 3/7] locking/rwsem: rwsem_can_spin_on_owner can be called with preemption enabled
    Date
    The rwsem_can_spin_on_owner() function can be called with preemption
    enabled. This patch moves it before preempt_disable() so that it won't
    do unnecessary preemption operations when spinning is not possible.

    Signed-off-by: Waiman Long <Waiman.Long@hp.com>
    ---
    kernel/locking/rwsem-xadd.c | 6 +++---
    1 files changed, 3 insertions(+), 3 deletions(-)

    diff --git a/kernel/locking/rwsem-xadd.c b/kernel/locking/rwsem-xadd.c
    index ddd56d2..c8887ba 100644
    --- a/kernel/locking/rwsem-xadd.c
    +++ b/kernel/locking/rwsem-xadd.c
    @@ -404,11 +404,11 @@ static bool rwsem_optimistic_spin(struct rw_semaphore *sem)
    bool taken = false;
    int spincnt = 0;

    - preempt_disable();
    -
    /* sem->wait_lock should not be held when doing optimistic spinning */
    if (!rwsem_can_spin_on_owner(sem))
    - goto done;
    + return false;
    +
    + preempt_disable();

    if (!osq_lock(&sem->osq))
    goto done;
    --
    1.7.1


    \
     
     \ /
      Last update: 2014-08-08 00:41    [W:6.425 / U:0.452 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site