Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752318AbbGKKWk (ORCPT ); Sat, 11 Jul 2015 06:22:40 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:45073 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750711AbbGKKWj (ORCPT ); Sat, 11 Jul 2015 06:22:39 -0400 Date: Sat, 11 Jul 2015 12:22:19 +0200 From: Peter Zijlstra To: Waiman Long Cc: Masami Hiramatsu , Ingo Molnar , Ingo Molnar , linux-kernel Subject: Re: [BUG][tip/master] kernel panic while locking selftest at qspinlock_paravirt.h:137! Message-ID: <20150711102219.GP19282@twins.programming.kicks-ass.net> References: <559FAD5E.3080309@hitachi.com> <20150710130028.GI19282@twins.programming.kicks-ass.net> <20150710135746.GA13461@gmail.com> <20150710142824.GK19282@twins.programming.kicks-ass.net> <55A06439.90002@hitachi.com> <55A07111.6030900@hp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <55A07111.6030900@hp.com> User-Agent: Mutt/1.5.21 (2012-12-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1635 Lines: 43 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/