lkml.org 
[lkml]   [2021]   [Sep]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    Subject[PATCH 15/20] futex: Simplify double_lock_hb()

    Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    ---
    kernel/futex/futex.h | 14 ++++++--------
    1 file changed, 6 insertions(+), 8 deletions(-)

    --- a/kernel/futex/futex.h
    +++ b/kernel/futex/futex.h
    @@ -316,14 +316,12 @@ extern void futex_q_unlock(struct futex_
    static inline void
    double_lock_hb(struct futex_hash_bucket *hb1, struct futex_hash_bucket *hb2)
    {
    - if (hb1 <= hb2) {
    - spin_lock(&hb1->lock);
    - if (hb1 < hb2)
    - spin_lock_nested(&hb2->lock, SINGLE_DEPTH_NESTING);
    - } else { /* hb1 > hb2 */
    - spin_lock(&hb2->lock);
    - spin_lock_nested(&hb1->lock, SINGLE_DEPTH_NESTING);
    - }
    + if (hb1 > hb2)
    + swap(hb1, hb2);
    +
    + spin_lock(&hb1->lock);
    + if (hb1 != hb2)
    + spin_lock_nested(&hb2->lock, SINGLE_DEPTH_NESTING);
    }

    static inline void

    \
     
     \ /
      Last update: 2021-09-15 16:18    [W:4.101 / U:0.008 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site