From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C9CCFC83F17 for ; Thu, 31 Aug 2023 10:14:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=p9M3Ul7NMd0kut2HbSubYGgjLbZlcDBYCOqHHnIgXWE=; b=d4NgX5XaGJQ+I4 N4wL/hP5B1WlddbDay/qz4GEyacVXcDWR60935U06oMHFmTgYcw+vTRJ2BNrPyWxSubCOsMJMark7 /DyiCtkDXmtiXfTdFopZO5ZvkGPvBGBWP6HRcY8wWxJdCOtK21OnRsFi9ZuxZkIiy7BwDbDrKIqNW lHauckbpBxO8R+xNziAoC422aeBj6TMVv1yexXcSW9G2TgTQ7o3nWv1BnXerAMk3r2gDvMKWLKgDw XJRm87pCjREG9XxUHkIuDpl4TvGm2ygbTn9PU8+FQjwuO4H0mKpzrsC8xhg6kUH/ZNZPRgvf7tvpd stlbGt95plGg2Gemxnzg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qbegq-00EzpP-2g; Thu, 31 Aug 2023 10:14:16 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qbegn-00EzoR-1g for linux-arm-kernel@lists.infradead.org; Thu, 31 Aug 2023 10:14:15 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0DFCCC15; Thu, 31 Aug 2023 03:14:50 -0700 (PDT) Received: from FVFF77S0Q05N (unknown [10.57.3.201]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3EF463F64C; Thu, 31 Aug 2023 03:14:07 -0700 (PDT) Date: Thu, 31 Aug 2023 11:14:04 +0100 From: Mark Rutland To: Douglas Anderson Cc: Catalin Marinas , Will Deacon , Sumit Garg , Daniel Thompson , Marc Zyngier , linux-arm-kernel@lists.infradead.org, Masayoshi Mizuma , "Rafael J . Wysocki" , Chen-Yu Tsai , Lecopzer Chen , Tomohiro Misono , Stephane Eranian , kgdb-bugreport@lists.sourceforge.net, Peter Zijlstra , Thomas Gleixner , Stephen Boyd , ito-yuichi@fujitsu.com, linux-perf-users@vger.kernel.org, Ard Biesheuvel , D Scott Phillips , Josh Poimboeuf , Valentin Schneider , linux-kernel@vger.kernel.org Subject: Re: [PATCH v12 6/7] arm64: kgdb: Implement kgdb_roundup_cpus() to enable pseudo-NMI roundup Message-ID: References: <20230830191314.1618136-1-dianders@chromium.org> <20230830121115.v12.6.I2ef26d1b3bfbed2d10a281942b0da7d9854de05e@changeid> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20230830121115.v12.6.I2ef26d1b3bfbed2d10a281942b0da7d9854de05e@changeid> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230831_031413_651670_D28378A5 X-CRM114-Status: GOOD ( 34.44 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Aug 30, 2023 at 12:11:27PM -0700, Douglas Anderson wrote: > Up until now we've been using the generic (weak) implementation for > kgdb_roundup_cpus() when using kgdb on arm64. Let's move to a custom > one. The advantage here is that, when pseudo-NMI is enabled on a > device, we'll be able to round up CPUs using pseudo-NMI. This allows > us to debug CPUs that are stuck with interrupts disabled. If > pseudo-NMIs are not enabled then we'll fallback to just using an IPI, > which is still slightly better than the generic implementation since > it avoids the potential situation described in the generic > kgdb_call_nmi_hook(). > > Co-developed-by: Sumit Garg > Signed-off-by: Sumit Garg > Reviewed-by: Daniel Thompson > Reviewed-by: Stephen Boyd > Signed-off-by: Douglas Anderson > --- > I debated whether this should be in "arch/arm64/kernel/smp.c" or if I > should try to find a way for it to go into "arch/arm64/kernel/kgdb.c". > In the end this is so little code that it didn't seem worth it to find > a way to export the IPI defines or to otherwise come up with some API > between kgdb.c and smp.c. If someone has strong feelings and wants > this to change, please shout and give details of your preferred > solution. Putting this in smp.c seems fine to me. Acked-by: Mark Rutland Mark. > > FWIW, it seems like ~half the other platforms put this in "smp.c" with > an ifdef for KGDB and the other half put it in "kgdb.c" with an ifdef > for SMP. :-P > > (no changes since v10) > > Changes in v10: > - Don't allocate the cpumask on the stack; just iterate. > - Moved kgdb calls to smp.c to avoid needing to export IPI info. > - kgdb now has its own IPI. > > Changes in v9: > - Remove fallback for when debug IPI isn't available. > - Renamed "NMI IPI" to "debug IPI" since it might not be backed by NMI. > > arch/arm64/kernel/smp.c | 23 +++++++++++++++++++++++ > 1 file changed, 23 insertions(+) > > diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c > index 800c59cf9b64..1a53e57c81d0 100644 > --- a/arch/arm64/kernel/smp.c > +++ b/arch/arm64/kernel/smp.c > @@ -32,6 +32,7 @@ > #include > #include > #include > +#include > #include > #include > > @@ -79,6 +80,7 @@ enum ipi_msg_type { > * with trace_ipi_* > */ > IPI_CPU_BACKTRACE = NR_IPI, > + IPI_KGDB_ROUNDUP, > MAX_IPI > }; > > @@ -868,6 +870,22 @@ void arch_trigger_cpumask_backtrace(const cpumask_t *mask, int exclude_cpu) > nmi_trigger_cpumask_backtrace(mask, exclude_cpu, arm64_backtrace_ipi); > } > > +#ifdef CONFIG_KGDB > +void kgdb_roundup_cpus(void) > +{ > + int this_cpu = raw_smp_processor_id(); > + int cpu; > + > + for_each_online_cpu(cpu) { > + /* No need to roundup ourselves */ > + if (cpu == this_cpu) > + continue; > + > + __ipi_send_single(ipi_desc[IPI_KGDB_ROUNDUP], cpu); > + } > +} > +#endif > + > /* > * Main handler for inter-processor interrupts > */ > @@ -919,6 +937,10 @@ static void do_handle_IPI(int ipinr) > nmi_cpu_backtrace(get_irq_regs()); > break; > > + case IPI_KGDB_ROUNDUP: > + kgdb_nmicallback(cpu, get_irq_regs()); > + break; > + > default: > pr_crit("CPU%u: Unknown IPI message 0x%x\n", cpu, ipinr); > break; > @@ -949,6 +971,7 @@ static bool ipi_should_be_nmi(enum ipi_msg_type ipi) > case IPI_CPU_STOP: > case IPI_CPU_CRASH_STOP: > case IPI_CPU_BACKTRACE: > + case IPI_KGDB_ROUNDUP: > return true; > default: > return false; > -- > 2.42.0.283.g2d96d420d3-goog > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel