Skip to content

Commit

Permalink
locking: Clean up pvqspinlock warning
Browse files Browse the repository at this point in the history
 - Rename the on-stack variable to match the datastructure variable,

 - place the cmpxchg back under the comment that explains it,

 - clean up the WARN() statement to avoid superfluous conditionals
   and line-breaks.

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@hp.com>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
  • Loading branch information
Peter Zijlstra authored and Ingo Molnar committed Aug 3, 2015
1 parent 3a7651e commit 0b792bf
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions kernel/locking/qspinlock_paravirt.h
Original file line number Diff line number Diff line change
Expand Up @@ -287,20 +287,21 @@ __visible void __pv_queued_spin_unlock(struct qspinlock *lock)
{
struct __qspinlock *l = (void *)lock;
struct pv_node *node;
u8 lockval = cmpxchg(&l->locked, _Q_LOCKED_VAL, 0);
u8 locked;

/*
* We must not unlock if SLOW, because in that case we must first
* unhash. Otherwise it would be possible to have multiple @lock
* entries, which would be BAD.
*/
if (likely(lockval == _Q_LOCKED_VAL))
locked = cmpxchg(&l->locked, _Q_LOCKED_VAL, 0);
if (likely(locked == _Q_LOCKED_VAL))
return;

if (unlikely(lockval != _Q_SLOW_VAL)) {
if (debug_locks_silent)
return;
WARN(1, "pvqspinlock: lock %p has corrupted value 0x%x!\n", lock, atomic_read(&lock->val));
if (unlikely(locked != _Q_SLOW_VAL)) {
WARN(!debug_locks_silent,
"pvqspinlock: lock 0x%lx has corrupted value 0x%x!\n",
(unsigned long)lock, atomic_read(&lock->val));
return;
}

Expand Down

0 comments on commit 0b792bf

Please sign in to comment.