Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752492AbbGLDNM (ORCPT ); Sat, 11 Jul 2015 23:13:12 -0400 Received: from mail9.hitachi.co.jp ([133.145.228.44]:40089 "EHLO mail9.hitachi.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752092AbbGLDNL (ORCPT ); Sat, 11 Jul 2015 23:13:11 -0400 Message-ID: <55A1DB41.7050108@hitachi.com> Date: Sun, 12 Jul 2015 12:13:05 +0900 From: Masami Hiramatsu Organization: Hitachi, Ltd., Japan User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: Waiman Long , Peter Zijlstra , Ingo Molnar CC: linux-kernel@vger.kernel.org Subject: Re: [PATCH] locking/pvqspinlock: Fix kernel panic in locking-selftest References: <1436663959-53092-1-git-send-email-Waiman.Long@hp.com> In-Reply-To: <1436663959-53092-1-git-send-email-Waiman.Long@hp.com> Content-Type: text/plain; charset=iso-2022-jp Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2793 Lines: 82 On 2015/07/12 10:19, Waiman Long wrote: > Enabling locking-selftest in a VM guest may cause the following > kernel panic: > > kernel BUG at .../kernel/locking/qspinlock_paravirt.h:137! > > This is due to the fact that the pvqspinlock unlock function is > expecting either a _Q_LOCKED_VAL or _Q_SLOW_VAL in the lock byte. This > patch prevents that bug report by ignoring it when debug_locks_silent > is set. Otherwise, a warning will be printed if it contains an > unexpected value. > > With this patch applied, the kernel locking-selftest completed without > any noise. > OK, I've tested this with make allmodconfig && make localmodconfig kernel. (I've hit another issue to boot, but it seems not related to this issue) Tested-by: Masami Hiramatsu Thank you! > Signed-off-by: Waiman Long > --- > kernel/locking/qspinlock_paravirt.h | 12 +++++++++++- > 1 files changed, 11 insertions(+), 1 deletions(-) > > diff --git a/kernel/locking/qspinlock_paravirt.h b/kernel/locking/qspinlock_paravirt.h > index 04ab181..15d3733 100644 > --- a/kernel/locking/qspinlock_paravirt.h > +++ b/kernel/locking/qspinlock_paravirt.h > @@ -4,6 +4,7 @@ > > #include > #include > +#include > > /* > * Implement paravirt qspinlocks; the general idea is to halt the vcpus instead > @@ -286,15 +287,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)) { > + if (debug_locks_silent) > + return; > + WARN(1, "pvqspinlock: lock 0x%lx has corrupted value 0x%x!\n", > + (unsigned long)lock, atomic_read(&lock->val)); > + return; > + } > + > /* > * Since the above failed to release, this must be the SLOW path. > * Therefore start by looking up the blocked node and unhashing it. > -- Masami HIRAMATSU Linux Technology Research Center, System Productivity Research Dept. Center for Technology Innovation - Systems Engineering Hitachi, Ltd., Research & Development Group E-mail: masami.hiramatsu.pt@hitachi.com -- 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/