Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp412112ybb; Wed, 1 Apr 2020 02:27:53 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvEcuUjLekxAYp+xTnI3zAJ7zykP8ciSe+Ka9tiAtaN5OZphdFFPHRRlR/ZByk3fi3tanHG X-Received: by 2002:a05:6830:6:: with SMTP id c6mr6147128otp.84.1585733272914; Wed, 01 Apr 2020 02:27:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585733272; cv=none; d=google.com; s=arc-20160816; b=UcvDaitLFr1B8P9iUdeRrV2Fk8eJ2+iUcXVtU1nlcnSxk6f/pCnRVXd+xWOxZv6PN0 B0hw/4283H2SA+6tbV+79/gC8t2PpSX8tOPizAOmvhc0VpCSqXxLXlBMKvaG1eWFFW/3 wSw3ACz+l4ktl2UHWDdiZ+GPA8Uny+JPP5CxKELCM60m7/DIZMn/nqkzH2lHHYcrZOWw bklgrW5sllugIvJ/F3z8v7wtt6xkX5vly+tfIrKK0UHpOLjdVlFHCqQX/Vafc9PuW0M1 l39xYMKNlYvFgJHKOR1IzHnLJjj/0AFmGRJDuOs5n+lnRpXWNmyWw77h7GwR4fwMdC5j M90Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=YYo5EKAQ9jeZ5u7WqOrUteHoNVI7yscIqPfvElnPohU=; b=d+ppYwYW1bLnRJZW0XLPBE3dqS7/xLKvBtWWSXXsLptrWS9hGuionIRb8JpAy7poKM 9K5gXWZ5fkO18Jy7UvNh7YdwZolGJSxLuNsfqB2eLoVLlEu12ma2sTZWr/fOevI5yMrs xBqkoW243P1tzPQnuKs22Nyww0NGSgw8nLGaHCCwxhXHo2MvxTH4c7CnTitT3LmgcP+4 vq4IWHhNO577qz7zWYuOjt/d8FpBaoY5t5ne3IfE+GgJqT3xswgfbTsJAvSMwFhVssxS hVIRC2roKx8B5XN0qVxCvhnwqeoiPCFRiOsrpbcAOZMWOuhiumtc4jDgEL/mSQGn/xgV gpYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=temperror (dns failure for signature) header.i=@infradead.org header.s=merlin.20170209 header.b=HqlQzdOT; 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 t125si663328oib.103.2020.04.01.02.27.39; Wed, 01 Apr 2020 02:27:52 -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=temperror (dns failure for signature) header.i=@infradead.org header.s=merlin.20170209 header.b=HqlQzdOT; 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 S1727627AbgDAJ0u (ORCPT + 99 others); Wed, 1 Apr 2020 05:26:50 -0400 Received: from merlin.infradead.org ([205.233.59.134]:36498 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726205AbgDAJ0t (ORCPT ); Wed, 1 Apr 2020 05:26:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=YYo5EKAQ9jeZ5u7WqOrUteHoNVI7yscIqPfvElnPohU=; b=HqlQzdOTso81BOo6+3TntCLG5T +mklMvBXZ3e9he4xGmkeNbi5t4ugfq8TrkzZhGPidhsp4gu1JaVtXXetqw7yhu4LHwDN7l1kw8AK4 SbaSKoUfEejrcmc9QD+nxze0g+FJwnwAJRiPl9XWJBVSuBhQNqbxn1tGUyUaRW1kFRn8P/xQMLP/W 8wGd/lYGxfnlq0wolb36aIUKGWJ2gNtigsU9cCfadQ6lGbFzAyM+q71bYpiNpgG5y7CBoMsQ//11X uvFMcEOTovRgxSdVXgk1LtROyqmNO7W36ElgiDHK6bcqJvUrG+7vId3gUCIH0kInt/u5Eggov+BtQ FyrGhJJw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jJZdg-000832-JJ; Wed, 01 Apr 2020 09:26:24 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id E7008301631; Wed, 1 Apr 2020 11:26:18 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id D34ED29E1FE81; Wed, 1 Apr 2020 11:26:18 +0200 (CEST) Date: Wed, 1 Apr 2020 11:26:18 +0200 From: Peter Zijlstra To: Leonardo Bras Cc: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Enrico Weigelt , Alexios Zavras , Thomas Gleixner , Greg Kroah-Hartman , Christophe Leroy , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 1/1] ppc/crash: Reset spinlocks during crash Message-ID: <20200401092618.GW20713@hirez.programming.kicks-ass.net> References: <20200401000020.590447-1-leonardo@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200401000020.590447-1-leonardo@linux.ibm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 31, 2020 at 09:00:21PM -0300, Leonardo Bras wrote: > 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 > @@ -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; > } You might want to add a note to your asm/spinlock.h that you rely on spin_unlock() unconditionally clearing a lock. This isn't naturally true for all lock implementations. Consider ticket locks, doing a surplus unlock will wreck your lock state in that case. So anybody poking at the powerpc spinlock implementation had better know you rely on this.