Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932195AbbGJNAo (ORCPT ); Fri, 10 Jul 2015 09:00:44 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:50532 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932228AbbGJNAi (ORCPT ); Fri, 10 Jul 2015 09:00:38 -0400 Date: Fri, 10 Jul 2015 15:00:28 +0200 From: Peter Zijlstra To: Masami Hiramatsu Cc: Ingo Molnar , linux-kernel , Waiman Long Subject: Re: [BUG][tip/master] kernel panic while locking selftest at qspinlock_paravirt.h:137! Message-ID: <20150710130028.GI19282@twins.programming.kicks-ass.net> References: <559FAD5E.3080309@hitachi.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <559FAD5E.3080309@hitachi.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: 1960 Lines: 54 On Fri, Jul 10, 2015 at 08:32:46PM +0900, Masami Hiramatsu wrote: > double unlock: > ------------[ cut here ]------------ > kernel BUG at /home/mhiramat/ksrc/linux-3/kernel/locking/qspinlock_paravirt.h:137! > Call Trace: > [] __raw_callee_save___pv_queued_spin_unlock+0x11/0x1e > [] ? do_raw_spin_unlock+0xfa/0x10c > [] _raw_spin_unlock+0x44/0x64 > [] double_unlock_spin+0x3d/0x46 Cute, but somewhat expected. A double unlock really is a BUG and the PV spinlock code cannot deal with it. Do we want to make double unlock non-fatal unconditionally? --- kernel/locking/qspinlock_paravirt.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/kernel/locking/qspinlock_paravirt.h b/kernel/locking/qspinlock_paravirt.h index 04ab18151cc8..172deeaf1311 100644 --- a/kernel/locking/qspinlock_paravirt.h +++ b/kernel/locking/qspinlock_paravirt.h @@ -286,15 +286,22 @@ __visible void __pv_queued_spin_unlock(struct qspinlock *lock) { struct __qspinlock *l = (void *)lock; struct pv_node *node; + 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(cmpxchg(&l->locked, _Q_LOCKED_VAL, 0) == _Q_LOCKED_VAL)) + locked = cmpxchg(&l->locked, _Q_LOCKED_VAL, 0); + if (likely(locked == _Q_LOCKED_VAL)) return; +#ifdef CONFIG_DEBUG_LOCKING_API_SELFTESTS + if (unlikely(!locked)) + return; +#endif + /* * Since the above failed to release, this must be the SLOW path. * Therefore start by looking up the blocked node and unhashing it. -- 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/