Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp3164999rwb; Mon, 7 Aug 2023 09:08:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFjv1YEj/eoWcpioEOdBZ5685eslxyAhXTEw9/Rvwl3bP46GKeaXdcRvVxaj8HLSp0pEfr5 X-Received: by 2002:a05:6a21:272f:b0:133:8720:ac4 with SMTP id rm47-20020a056a21272f00b0013387200ac4mr8533023pzb.24.1691424504540; Mon, 07 Aug 2023 09:08:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691424504; cv=none; d=google.com; s=arc-20160816; b=G8YsYbTixkdl9/kSqoFxjuMAVSNrXz3yiuJ3R5I0c1JtXFjMV4c5fH9E2IEECySX9Y +MVRhJSXdCU2/5YtO8u3AY011xiuCtuxOx53aZNxXttqFBu9aJAKdfPZxWoy4jlbCCl9 kK8f8nnp1CCoimtztooChoAhfM8aUrJUeK9HHPlJaDScH7BZSfec2dwFnBbuYOW21iDd BQ8VWadgwbl2SI5/47MKE2AuYMfBGad14zO7tCZxwqdArezocQ7KNDB5JSY8jEKLwCFK E19U4KnLaQPnrNE/JiQ7+0A0rVgh/iRfhZca88TI/nXzf2AnPzTAXbuYlZJIcNkVhGSi FFig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=5O8vR/1i2pTaOS1dFRpBW/IxDy7VOIWd34DMjXV3TwY=; fh=SaZEgtUYVUtjDM/j7C8CW8BcBb0DP/MYzc3l4G5Okeg=; b=HsdKKFdrkyAJGXIPNYyCUxHS9D3LVKz6Gktm6n4pVpV8sLaLfUAnBuN6Ivg1AP8/KC GhvKrp7SkC9Hgpwu6SqHuwvJf1TjfqBcWbjJG2/8wBAl7YSPODC+th/3ODQmTcdF7Bry 2leTaIYv9d/KgpYxcCS42Adk78/Z08h3HowpkeaejqJMBucIB9ROoAU+YizptZpgA4Tv TTn2olSMa4FGymwdf6BsSUJo9c3/OKlgF5nJUJSCK8PjSqqcLAEM0tH+LNi0jTUlWGyJ Vtn4gYej+qSG+A7vvn7CHEqy/84iLfxeVaETlnZPKi6eRSGyGb2+u/EHyXfSP2z6DL6M xw2A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cq8-20020a056a00330800b00687346d94c4si5753179pfb.334.2023.08.07.09.08.10; Mon, 07 Aug 2023 09:08:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234746AbjHGOn6 (ORCPT + 99 others); Mon, 7 Aug 2023 10:43:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233922AbjHGOn5 (ORCPT ); Mon, 7 Aug 2023 10:43:57 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id F404E10DC; Mon, 7 Aug 2023 07:43:55 -0700 (PDT) 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 5C37B1FB; Mon, 7 Aug 2023 07:44:38 -0700 (PDT) Received: from FVFF77S0Q05N.cambridge.arm.com (FVFF77S0Q05N.cambridge.arm.com [10.1.32.139]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 74E703F64C; Mon, 7 Aug 2023 07:43:51 -0700 (PDT) Date: Mon, 7 Aug 2023 15:43:46 +0100 From: Mark Rutland To: Sumit Garg Cc: Doug Anderson , Catalin Marinas , Will Deacon , Daniel Thompson , Marc Zyngier , linux-perf-users@vger.kernel.org, ito-yuichi@fujitsu.com, Chen-Yu Tsai , Ard Biesheuvel , Stephen Boyd , Peter Zijlstra , Thomas Gleixner , linux-arm-kernel@lists.infradead.org, kgdb-bugreport@lists.sourceforge.net, Masayoshi Mizuma , "Rafael J . Wysocki" , Lecopzer Chen , Andrey Konovalov , Ben Dooks , Frederic Weisbecker , "Gautham R. Shenoy" , Ingo Molnar , Jason Wessel , Josh Poimboeuf , Masahiro Yamada , Valentin Schneider , Wei Li , linux-kernel@vger.kernel.org Subject: Re: [PATCH v9 0/7] arm64: Add debug IPI for backtraces / kgdb; try to use NMI for it Message-ID: References: <20230601213440.2488667-1-dianders@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Aug 07, 2023 at 06:16:24PM +0530, Sumit Garg wrote: > On Mon, 7 Aug 2023 at 16:11, Mark Rutland wrote: > > On Mon, Jul 24, 2023 at 08:55:44AM -0700, Doug Anderson wrote: > > > On Thu, Jun 1, 2023 at 2:37 PM Douglas Anderson wrote: > > I'd also strongly prefer if we > > could have separate IPI_CPU_BACKTRACE and IPI_CPU_KGDB IPIs, > > With current logic of single debug IPI, it is not required for a user > to enable KGDB in order to use that IPI for backtrace. The original > motivation for this logic was that the IPIs are a scarce resource on > arm64 as per comments from Marc. So I am fine either way to keep them > separate or unified. > > > and I think we can > > do that either by unifying IPI_CPU_STOP && IPI_CPU_CRASH_STOP or by reclaiming > > IPI_WAKEUP by reusing a different IPI for the parking protocol (e.g. > > IPI_RESCHEDULE). > > That sounds like a good cleanup. I took a quick stab at removing IPI_WAKEUP, and it seems simple enough; patch below. Mark. ----<8---- From 267401824576c1dd3bb6d380142c92f710098b67 Mon Sep 17 00:00:00 2001 From: Mark Rutland Date: Mon, 7 Aug 2023 15:05:47 +0100 Subject: [PATCH] arm64: smp: Remove dedicated wakeup IPI To enable NMI backtrace and KGDB's NMI cpu roundup, we need to free up at least one dedicated IPI. On arm64 the IPI_WAKEUP IPI is only used for the ACPI parking protocol, which itself is only used on some very early ARMv8 systems which couldn't implement PSCI. Remove the IPI_WAKEUP IPI, and rely on the IPI_RESCHEDULE IPI to wake CPUs from the parked state. This will cause a tiny amonut of redundant work to check the thread flags, but this is miniscule in relation to the cost of taking and handling the IPI in the first place. We can safely handle redundant IPI_RESCHEDULE IPIs, so there should be no functional impact as a result of this change. Signed-off-by: Mark Rutland Cc: Catalin Marinas Cc: Douglas Anderson Cc: Marc Zyngier Cc: Sumit Garg Cc: Will Deacon --- arch/arm64/include/asm/smp.h | 4 ++-- arch/arm64/kernel/acpi_parking_protocol.c | 2 +- arch/arm64/kernel/smp.c | 28 +++++++++-------------- 3 files changed, 14 insertions(+), 20 deletions(-) diff --git a/arch/arm64/include/asm/smp.h b/arch/arm64/include/asm/smp.h index 9b31e6d0da174..798fd76a883a0 100644 --- a/arch/arm64/include/asm/smp.h +++ b/arch/arm64/include/asm/smp.h @@ -89,9 +89,9 @@ extern void arch_send_call_function_single_ipi(int cpu); extern void arch_send_call_function_ipi_mask(const struct cpumask *mask); #ifdef CONFIG_ARM64_ACPI_PARKING_PROTOCOL -extern void arch_send_wakeup_ipi_mask(const struct cpumask *mask); +extern void arch_send_wakeup_ipi(int cpu); #else -static inline void arch_send_wakeup_ipi_mask(const struct cpumask *mask) +static inline void arch_send_wakeup_ipi(int cpu) { BUILD_BUG(); } diff --git a/arch/arm64/kernel/acpi_parking_protocol.c b/arch/arm64/kernel/acpi_parking_protocol.c index b1990e38aed0a..e1be29e608b71 100644 --- a/arch/arm64/kernel/acpi_parking_protocol.c +++ b/arch/arm64/kernel/acpi_parking_protocol.c @@ -103,7 +103,7 @@ static int acpi_parking_protocol_cpu_boot(unsigned int cpu) &mailbox->entry_point); writel_relaxed(cpu_entry->gic_cpu_id, &mailbox->cpu_id); - arch_send_wakeup_ipi_mask(cpumask_of(cpu)); + arch_send_wakeup_ipi(cpu); return 0; } diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index edd63894d61e8..be00c8c5c1711 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -72,7 +72,6 @@ enum ipi_msg_type { IPI_CPU_CRASH_STOP, IPI_TIMER, IPI_IRQ_WORK, - IPI_WAKEUP, NR_IPI }; @@ -764,7 +763,6 @@ static const char *ipi_types[NR_IPI] __tracepoint_string = { [IPI_CPU_CRASH_STOP] = "CPU stop (for crash dump) interrupts", [IPI_TIMER] = "Timer broadcast interrupts", [IPI_IRQ_WORK] = "IRQ work interrupts", - [IPI_WAKEUP] = "CPU wake-up interrupts", }; static void smp_cross_call(const struct cpumask *target, unsigned int ipinr); @@ -797,13 +795,6 @@ void arch_send_call_function_single_ipi(int cpu) smp_cross_call(cpumask_of(cpu), IPI_CALL_FUNC); } -#ifdef CONFIG_ARM64_ACPI_PARKING_PROTOCOL -void arch_send_wakeup_ipi_mask(const struct cpumask *mask) -{ - smp_cross_call(mask, IPI_WAKEUP); -} -#endif - #ifdef CONFIG_IRQ_WORK void arch_irq_work_raise(void) { @@ -897,14 +888,6 @@ static void do_handle_IPI(int ipinr) break; #endif -#ifdef CONFIG_ARM64_ACPI_PARKING_PROTOCOL - case IPI_WAKEUP: - WARN_ONCE(!acpi_parking_protocol_valid(cpu), - "CPU%u: Wake-up IPI outside the ACPI parking protocol\n", - cpu); - break; -#endif - default: pr_crit("CPU%u: Unknown IPI message 0x%x\n", cpu, ipinr); break; @@ -979,6 +962,17 @@ void arch_smp_send_reschedule(int cpu) smp_cross_call(cpumask_of(cpu), IPI_RESCHEDULE); } +#ifdef CONFIG_ARM64_ACPI_PARKING_PROTOCOL +void arch_send_wakeup_ipi(int cpu) +{ + /* + * We use a scheduler IPI to wake the CPU as this avoids the need for a + * dedicated IPI and we can safely handle spurious scheduler IPIs. + */ + arch_smp_send_reschedule(cpu); +} +#endif + #ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST void tick_broadcast(const struct cpumask *mask) { -- 2.30.2