Received: by 2002:a17:90a:1609:0:0:0:0 with SMTP id n9csp2491270pja; Thu, 26 Mar 2020 16:28:02 -0700 (PDT) X-Google-Smtp-Source: ADFU+vt4ywAJ7wL1Cnf5oi0aOt5tS5A2sib47+G39MjVliKHYVVghOvNot7LZb5HbXDysfjWjj5f X-Received: by 2002:a9d:7698:: with SMTP id j24mr8594934otl.370.1585265282568; Thu, 26 Mar 2020 16:28:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585265282; cv=none; d=google.com; s=arc-20160816; b=T1Fy6PsDwFuhG6ty76Rp6vG064dCtUFWfLUM0w6ainJjX3kcX9crygbCFqwg3M/AV7 OgXh8IbmLetvCd0OorEIQpQj/G8kPr3/eF1nwvn9stqcc1jFDflkkKG16b46mDyzyer1 oPMSOYUDHfmUwo2RXfM//bf3lpEIvB7epia5LiSg3URD/R2DsTC3b0fNAlLC9ZNemBF0 W1I180SnZtbVUcqoWF5cRLHoZdWgEtdD2pM7a5rEhIZ1tr4JU3mWk6GJWWg/L9m08hK5 dgVLywVEgfvQ1D2WfaiB9/zA8SzWqtVI9arTxMf4z3zH74prvzdI039oTs665arJ3nSt SBfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=Vc5JqdrDpmZYMQEJNE/6+Mc9C8scfy6mCKSVEMkjh30=; b=wPcW9D8EzVZumz+36Wd8LZ97Y8Fh8bg5PMGE6B7OT4Tl3ODGHqFIZSfj6ovi5x2fo3 89/z6MXYoxy3GDe4WM6cVOn9eXjygYpVF+rrFw4okEpO0fbS277DF6ChiYMGgk7kieXB 3hrCCTksyMNN+fhL8losEkdSylCon2dN17SJhjEQ0EsNxqAcJ3Cn2nL42bFSspGwb5kp A/ESA7Vn1v7RsUKqvXlXQAuY57lieaJx+WpCLNkP4j1n3qL4pEYhU0Yho14t3zodeKNA ZG374ZtQCJwO3k8rnKRXsZa1pU5EXI6zPnBCvqNqXK7xQNnPwXvPaVPH/4aE34LvFc2U SV9g== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e13si1631495oom.86.2020.03.26.16.27.49; Thu, 26 Mar 2020 16:28:02 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728513AbgCZX05 (ORCPT + 99 others); Thu, 26 Mar 2020 19:26:57 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:18438 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727661AbgCZX0x (ORCPT ); Thu, 26 Mar 2020 19:26:53 -0400 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 02QN4Fog114235; Thu, 26 Mar 2020 19:26:22 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 2ywf3j7n28-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 26 Mar 2020 19:26:22 -0400 Received: from m0098399.ppops.net (m0098399.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 02QN5VvJ144345; Thu, 26 Mar 2020 19:26:22 -0400 Received: from ppma02dal.us.ibm.com (a.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.10]) by mx0a-001b2d01.pphosted.com with ESMTP id 2ywf3j7n1n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 26 Mar 2020 19:26:21 -0400 Received: from pps.filterd (ppma02dal.us.ibm.com [127.0.0.1]) by ppma02dal.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id 02QNOhOu007631; Thu, 26 Mar 2020 23:26:21 GMT Received: from b01cxnp22035.gho.pok.ibm.com (b01cxnp22035.gho.pok.ibm.com [9.57.198.25]) by ppma02dal.us.ibm.com with ESMTP id 2ywaw2rv3q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 26 Mar 2020 23:26:20 +0000 Received: from b01ledav005.gho.pok.ibm.com (b01ledav005.gho.pok.ibm.com [9.57.199.110]) by b01cxnp22035.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 02QNQKC351315188 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 26 Mar 2020 23:26:20 GMT Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 36780AE062; Thu, 26 Mar 2020 23:26:20 +0000 (GMT) Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 49007AE063; Thu, 26 Mar 2020 23:26:06 +0000 (GMT) Received: from LeoBras.aus.stglabs.ibm.com (unknown [9.85.162.45]) by b01ledav005.gho.pok.ibm.com (Postfix) with ESMTP; Thu, 26 Mar 2020 23:26:05 +0000 (GMT) From: Leonardo Bras To: Peter Zijlstra , Ingo Molnar , Will Deacon , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Greg Kroah-Hartman , Thomas Gleixner , Alexios Zavras , Christophe Leroy , Leonardo Bras Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Subject: [PATCH v2 1/1] ppc/crash: Skip spinlocks during crash Date: Thu, 26 Mar 2020 20:25:43 -0300 Message-Id: <20200326232542.503157-1-leonardo@linux.ibm.com> X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.645 definitions=2020-03-26_13:2020-03-26,2020-03-26 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1011 phishscore=0 priorityscore=1501 adultscore=0 mlxscore=0 mlxlogscore=999 impostorscore=0 bulkscore=0 lowpriorityscore=0 malwarescore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2003260164 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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) 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. Signed-off-by: Leonardo Bras --- arch/powerpc/include/asm/spinlock.h | 6 ++++++ arch/powerpc/kexec/crash.c | 4 ++++ 2 files changed, 10 insertions(+) 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