Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp56080ybb; Tue, 31 Mar 2020 17:04:11 -0700 (PDT) X-Google-Smtp-Source: APiQypKdzxq0mpY1XbX1DONWNLO68yCr4EDsq6XCNpu1tSz7UK6vPg9ZS3WE+9d2SSNbM6CAthna X-Received: by 2002:a05:6808:4e:: with SMTP id v14mr1090773oic.70.1585699451418; Tue, 31 Mar 2020 17:04:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585699451; cv=none; d=google.com; s=arc-20160816; b=QwiztT1jpeKi1grcmvbBNdaymE6S+apGAfsxdUDJws4IqBbq9gBMXA5axcbJ4tvNF0 S+xiBbYXGLzGGBf1vnjKxj8jrYUelctk9bwzSYA1g+QhLGmziEVLDyNnrRrnolaZs/iY qr7l87HuSf0zmK49T6mAhb5aPCUHLmEHNadTyfA67bnK4P+almjk1dz/cYZ84tuq0Hst 9TQTXjXncN0jWEMiuxeC8rd6WayL3FgieEpFwQhaYNvH80+EKCZ4XAivo5Ru5PZ8sjwd HWWeyAZUJzEmmM0bJc4DceL7ZSWFkqQxTPkFhzWiyB3ktyyITdjw9v98NIUJo5yyMtgM mnpw== 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=glp5Ka6amW4OauuaiUS7Sk/qeYSO/3mWm2YPLOXzaOk=; b=w8vNgEAWBkBQjX5GQq4ZwW48citEBmEnpM5UUy/5FvtXTElDZAfPR6q1sRpQ8luHFn uHZjj21QkAzlPXZ+jVGCKQ34NvbFcOg3rAIxvaB8vg2kycbbNUdGBB12ilzohP0+UxaU S7zZDdLDjHv9WF+ueFtx7WCLWBZxXVKmuaRJ5W6WdE3+NIDp/i5bsi86GCgCnfo19Laa zKsy6ctfNkj7XYXjc8k+q40PlkhWT2cPCUmxj4xJHxiJESVEjvF4Q0h0N0KjCEo7WCIc 9FxsQ9RCVaanH8w6kxKrp8Wa4yG09G7gG8n8dunX8lWyA380OwIw/0LC4b86YUjFbxQr 8WOQ== 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 n5si50337oof.46.2020.03.31.17.03.48; Tue, 31 Mar 2020 17:04: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; 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 S1731531AbgDAAC3 (ORCPT + 99 others); Tue, 31 Mar 2020 20:02:29 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:50728 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728840AbgDAAC3 (ORCPT ); Tue, 31 Mar 2020 20:02:29 -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 02VNWqkJ007299; Tue, 31 Mar 2020 20:01:56 -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 3022qypncq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 31 Mar 2020 20:01:56 -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 03101IsE026674; Wed, 1 Apr 2020 00:01:55 GMT Received: from b03cxnp08026.gho.boulder.ibm.com (b03cxnp08026.gho.boulder.ibm.com [9.17.130.18]) by ppma02dal.us.ibm.com with ESMTP id 301x7740x5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 01 Apr 2020 00:01:55 +0000 Received: from b03ledav006.gho.boulder.ibm.com (b03ledav006.gho.boulder.ibm.com [9.17.130.237]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 03101se159572518 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 1 Apr 2020 00:01:54 GMT Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EA5A8C605D; Wed, 1 Apr 2020 00:01:53 +0000 (GMT) Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 00FDEC605A; Wed, 1 Apr 2020 00:01:44 +0000 (GMT) Received: from LeoBras.aus.stglabs.ibm.com (unknown [9.85.169.195]) by b03ledav006.gho.boulder.ibm.com (Postfix) with ESMTP; Wed, 1 Apr 2020 00:01:44 +0000 (GMT) From: Leonardo Bras To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Enrico Weigelt , Leonardo Bras , Alexios Zavras , Thomas Gleixner , Greg Kroah-Hartman , Christophe Leroy , peterz@infradead.org Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 1/1] ppc/crash: Reset spinlocks during crash Date: Tue, 31 Mar 2020 21:00:21 -0300 Message-Id: <20200401000020.590447-1-leonardo@linux.ibm.com> X-Mailer: git-send-email 2.25.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.676 definitions=2020-03-31_07:2020-03-31,2020-03-31 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 phishscore=0 malwarescore=0 spamscore=0 mlxlogscore=999 impostorscore=0 suspectscore=2 adultscore=0 clxscore=1015 bulkscore=0 mlxscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2003310192 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_lock 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. After NMI IPI is sent to all other cpus, force unlock all spinlocks needed for finishing crash routine. Signed-off-by: Leonardo Bras --- Changes from v2: - Instead of skipping spinlocks, unlock the needed ones. Changes from v1: - Exported variable --- arch/powerpc/kexec/crash.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arch/powerpc/kexec/crash.c b/arch/powerpc/kexec/crash.c index d488311efab1..8d63fca3242c 100644 --- a/arch/powerpc/kexec/crash.c +++ b/arch/powerpc/kexec/crash.c @@ -24,6 +24,7 @@ #include #include #include +#include /* * The primary CPU waits a while for all secondary CPUs to enter. This is to @@ -49,6 +50,8 @@ static int time_to_dump; */ int crash_wake_offline; +extern raw_spinlock_t logbuf_lock; + #define CRASH_HANDLER_MAX 3 /* List of shutdown handles */ static crash_shutdown_t crash_shutdown_handles[CRASH_HANDLER_MAX]; @@ -129,6 +132,13 @@ 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) { + /* + * At this point no other CPU is running, and some of them may + * have been interrupted while holding one of the locks needed + * to complete crashing. Free them so there is no deadlock. + */ + arch_spin_unlock(&logbuf_lock.raw_lock); + arch_spin_unlock(&rtas.lock); printk(KERN_EMERG "IPI complete\n"); return; } -- 2.25.1