aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/locking
diff options
context:
space:
mode:
authorPeter Zijlstra <peterz@infradead.org>2016-07-14 08:26:11 -0400
committerIngo Molnar <mingo@kernel.org>2016-08-10 08:16:02 -0400
commit64a5e3cb308028dba0676daae0a7821d770036fa (patch)
treec50fac7c350895f3ec81662f53cbee6c4e64d9e2 /kernel/locking
parentc2ace36b884de9330c4149064ae8d212d2e0d9ee (diff)
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>
Diffstat (limited to 'kernel/locking')
-rw-r--r--kernel/locking/qspinlock_paravirt.h12
1 files changed, 7 insertions, 5 deletions
diff --git a/kernel/locking/qspinlock_paravirt.h b/kernel/locking/qspinlock_paravirt.h
index 8a99abf58080..429c3dc2a5f3 100644
--- a/kernel/locking/qspinlock_paravirt.h
+++ b/kernel/locking/qspinlock_paravirt.h
@@ -70,11 +70,14 @@ struct pv_node {
70static inline bool pv_queued_spin_steal_lock(struct qspinlock *lock) 70static inline bool pv_queued_spin_steal_lock(struct qspinlock *lock)
71{ 71{
72 struct __qspinlock *l = (void *)lock; 72 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);
75 73
76 qstat_inc(qstat_pv_lock_stealing, ret); 74 if (!(atomic_read(&lock->val) & _Q_LOCKED_PENDING_MASK) &&
77 return ret; 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;
78} 81}
79 82
80/* 83/*
@@ -257,7 +260,6 @@ static struct pv_node *pv_unhash(struct qspinlock *lock)
257static inline bool 260static inline bool
258pv_wait_early(struct pv_node *prev, int loop) 261pv_wait_early(struct pv_node *prev, int loop)
259{ 262{
260
261 if ((loop & PV_PREV_CHECK_MASK) != 0) 263 if ((loop & PV_PREV_CHECK_MASK) != 0)
262 return false; 264 return false;
263 265