Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2059557ybb; Thu, 26 Mar 2020 20:52:11 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsm4n5KG2D/oPHylZMA5eL6iWX0lKI4kg8fM1SrvAW6C0LtlXskXnOVzE57NdRU+k7KEFtN X-Received: by 2002:a9d:27a7:: with SMTP id c36mr8991147otb.68.1585281131389; Thu, 26 Mar 2020 20:52:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585281131; cv=none; d=google.com; s=arc-20160816; b=ugSGIEKHwQvpIa1FZT9IC+OnJwI3JQFg0ofNkpWazeP+4ijxGRWJSMgxKZRYdN8ATD kx4tVQuCwhmkt4hTxkSu2UcJk9+JKLUoaYPN1/FGJEaqXcyI1II2o74kZ0TT4qTC+3ru iasWTRPBFK5ew09SXYlIQX2mXSRKekygOLje2bW6QsOOKOvyon8mDfAIJfEWPhWCAWTy WjgzYElw4eheTz6lg6hX54lsPwbEfVSiUs8SyRc6t6Nd7JzIs83A0YlgzT2b6U5Sghxh xu5E0cICOiA4juruwSDQRlgALMwdi6jTYrJ72nOJLm9dkbd6ABKnDOKSiqM/eiDDZdZ8 WvoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=5qzZ56keCZkfvVMHV/2TRT02Lt997NI4Vy7Q6F/Bzso=; b=JlRMaReYz/A84pQucgd4hVKGyO1c/bH8wE96nXYvdhmhfBUWZqjWiCyEfS+kdwGzBx nhmBI0oNFA8et95IyeyDVN0A/45Kve1mDd6a38n/8njDIGyB+7+dWdWvc2RcQNm3NDMO GFzAPTBDawXQPKX83YEAyJLvjla5fyRtN6NNQp5EcAuvU4442jxZZ+fkvrz176/eOisB U57QnZX9aq6L+jhksdk0ya0oX1gHo8rWGdYkDQMR06lR6fGYly4NAMfLPqu3tLWJ2PgE rSXPvjjaL1cbigMlPqT6uP7Wtsy0uRu9waxrn092NwmIWI+nXDmykA2o4oJoo/WF6ldZ DLSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ellerman.id.au header.s=201909 header.b=AKeE3rtC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d185si1907225oif.234.2020.03.26.20.51.59; Thu, 26 Mar 2020 20:52:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ellerman.id.au header.s=201909 header.b=AKeE3rtC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727740AbgC0DuO (ORCPT + 99 others); Thu, 26 Mar 2020 23:50:14 -0400 Received: from bilbo.ozlabs.org ([203.11.71.1]:45507 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727607AbgC0DuN (ORCPT ); Thu, 26 Mar 2020 23:50:13 -0400 Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 48pSYG15kMz9sRR; Fri, 27 Mar 2020 14:50:10 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ellerman.id.au; s=201909; t=1585281010; bh=4Qqg2r8oM4zPrJhzVQO07i32dlNDD+eFmBtDY+IJlB0=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=AKeE3rtC/tHmgbrDN+BCRn0kRIXQhECLUqtFW9Yv6a/cJApH/zdfgOFjn/WYU7Buh 9ZmJqGOLvqNKaV2W2oAjBO8NHnQIqHpMFxsoI13sRFoBV183mxazsQLrPApSmkJrlH IN/ND6SstTbfalEQE+GOh13LwSwp8LMQmvm68zzqUHZ8LN+vUrcapZevjeh2vdQ6SY 7ABlVGzAl+sJznQmXo/JukKf2j44nx35QMwZ1qRgOCBeaQ3TtCpk33AD8/U+PMRZlr EYZ75f3mkiwv3B+z4cVpg641xeIep6hQIP7vKZCpeSCXVF1elVrB8d02Jdui/slXo4 XTioOijx4aiww== From: Michael Ellerman To: Leonardo Bras , Peter Zijlstra , Ingo Molnar , Will Deacon , Benjamin Herrenschmidt , Paul Mackerras , Greg Kroah-Hartman , Thomas Gleixner , Alexios Zavras , Christophe Leroy , Leonardo Bras Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Subject: Re: [PATCH v2 1/1] ppc/crash: Skip spinlocks during crash In-Reply-To: <20200326232542.503157-1-leonardo@linux.ibm.com> References: <20200326232542.503157-1-leonardo@linux.ibm.com> Date: Fri, 27 Mar 2020 14:50:14 +1100 Message-ID: <87d08ywj61.fsf@mpe.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Leonardo, Leonardo Bras writes: > During a crash, there is chance that the cpus that handle the NMI IPI > are holding a spin_lock. If this spin_lock is needed by crashing_cpu it > will cause a deadlock. (rtas_lock and printk logbuf_log as of today) Please give us more detail on how those locks are causing you trouble, a stack trace would be good if you have it. > This is a problem if the system has kdump set up, given if it crashes > for any reason kdump may not be saved for crash analysis. > > Skip spinlocks after NMI IPI is sent to all other cpus. We don't want to add overhead to all spinlocks for the life of the system, just to handle this one case. There's already a flag that is set when the system is crashing, "oops_in_progress", maybe we need to use that somewhere to skip a lock or do an early return. cheers > diff --git a/arch/powerpc/include/asm/spinlock.h b/arch/powerpc/include/asm/spinlock.h > index 860228e917dc..a6381d110795 100644 > --- a/arch/powerpc/include/asm/spinlock.h > +++ b/arch/powerpc/include/asm/spinlock.h > @@ -111,6 +111,8 @@ static inline void splpar_spin_yield(arch_spinlock_t *lock) {}; > static inline void splpar_rw_yield(arch_rwlock_t *lock) {}; > #endif > > +extern bool crash_skip_spinlock __read_mostly; > + > static inline bool is_shared_processor(void) > { > #ifdef CONFIG_PPC_SPLPAR > @@ -142,6 +144,8 @@ static inline void arch_spin_lock(arch_spinlock_t *lock) > if (likely(__arch_spin_trylock(lock) == 0)) > break; > do { > + if (unlikely(crash_skip_spinlock)) > + return; > HMT_low(); > if (is_shared_processor()) > splpar_spin_yield(lock); > @@ -161,6 +165,8 @@ void arch_spin_lock_flags(arch_spinlock_t *lock, unsigned long flags) > local_save_flags(flags_dis); > local_irq_restore(flags); > do { > + if (unlikely(crash_skip_spinlock)) > + return; > HMT_low(); > if (is_shared_processor()) > splpar_spin_yield(lock); > diff --git a/arch/powerpc/kexec/crash.c b/arch/powerpc/kexec/crash.c > index d488311efab1..ae081f0f2472 100644 > --- a/arch/powerpc/kexec/crash.c > +++ b/arch/powerpc/kexec/crash.c > @@ -66,6 +66,9 @@ static int handle_fault(struct pt_regs *regs) > > #ifdef CONFIG_SMP > > +bool crash_skip_spinlock; > +EXPORT_SYMBOL(crash_skip_spinlock); > + > static atomic_t cpus_in_crash; > void crash_ipi_callback(struct pt_regs *regs) > { > @@ -129,6 +132,7 @@ static void crash_kexec_prepare_cpus(int cpu) > /* Would it be better to replace the trap vector here? */ > > if (atomic_read(&cpus_in_crash) >= ncpus) { > + crash_skip_spinlock = true; > printk(KERN_EMERG "IPI complete\n"); > return; > } > -- > 2.24.1