Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1182126

Re: [BUG][tip/master] kernel panic while locking selftest at qspinlock_paravirt.h:137!

From Peter Zijlstra <peterz@infradead.org>
Newsgroups linux.kernel
Subject Re: [BUG][tip/master] kernel panic while locking selftest at qspinlock_paravirt.h:137!
Date 2015-07-11 12:30 +0200
Message-ID <pL0cF-20i-1@gated-at.bofh.it> (permalink)
References (1 earlier) <pKGdX-6qI-1@gated-at.bofh.it> <pKH0m-6JD-5@gated-at.bofh.it> <pKHto-791-23@gated-at.bofh.it> <pKWLL-8gN-11@gated-at.bofh.it> <pKWLL-8gN-13@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Fri, Jul 10, 2015 at 09:27:45PM -0400, Waiman Long wrote:
> Anyway, I have an alternative fix that should better capture the problem:
> 
> -------------------------------
> diff --git a/kernel/locking/qspinlock_paravirt.h
> b/kernel/locking/qspinlock_paravirt.h
> index 04ab181..92fc54f 100644
> --- a/kernel/locking/qspinlock_paravirt.h
> +++ b/kernel/locking/qspinlock_paravirt.h
> @@ -286,15 +286,24 @@ __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);
> 
>      /*
>       * 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(cmpxchg(&l->locked, _Q_LOCKED_VAL, 0) == _Q_LOCKED_VAL))
> +    if (likely(lockval == _Q_LOCKED_VAL))
>          return;
> 
> +    if (unlikely(lockval != _Q_SLOW_VAL)) {
> +        printk(KERN_WARNING
> +               "pvqspinlock: lock 0x%lx has corrupted value 0x%x!\n",
> +               (unsigned long)lock, atomic_read(&lock->val));
> +        WARN_ON_ONCE(1);

	WARN_ONCE(1, "foo");

> +        return;
> +    }

Right, so since this should not ever happen in 'sane' code, its a shame
to have to put in this condition. But yes, this works too.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

Re: [BUG][tip/master] kernel panic while locking selftest at  qspinlock_paravirt.h:137! Peter Zijlstra <peterz@infradead.org> - 2015-07-11 12:30 +0200

csiph-web