Skip to content

Commit 64a5e3c

Browse files
Peter ZijlstraIngo Molnar
authored andcommitted
locking/qspinlock: Improve readability
Restructure pv_queued_spin_steal_lock() as I found it hard to read. Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Waiman Long <waiman.long@hpe.com Cc: linux-kernel@vger.kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent c2ace36 commit 64a5e3c

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

kernel/locking/qspinlock_paravirt.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,14 @@ struct pv_node {
7070
static inline bool pv_queued_spin_steal_lock(struct qspinlock *lock)
7171
{
7272
struct __qspinlock *l = (void *)lock;
73-
int ret = !(atomic_read(&lock->val) & _Q_LOCKED_PENDING_MASK) &&
74-
(cmpxchg(&l->locked, 0, _Q_LOCKED_VAL) == 0);
7573

76-
qstat_inc(qstat_pv_lock_stealing, ret);
77-
return ret;
74+
if (!(atomic_read(&lock->val) & _Q_LOCKED_PENDING_MASK) &&
75+
(cmpxchg(&l->locked, 0, _Q_LOCKED_VAL) == 0)) {
76+
qstat_inc(qstat_pv_lock_stealing, true);
77+
return true;
78+
}
79+
80+
return false;
7881
}
7982

8083
/*
@@ -257,7 +260,6 @@ static struct pv_node *pv_unhash(struct qspinlock *lock)
257260
static inline bool
258261
pv_wait_early(struct pv_node *prev, int loop)
259262
{
260-
261263
if ((loop & PV_PREV_CHECK_MASK) != 0)
262264
return false;
263265

0 commit comments

Comments
 (0)