Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp943635rwr; Wed, 19 Apr 2023 15:57:39 -0700 (PDT) X-Google-Smtp-Source: AKy350b6WFMzWPUvnh/o0xYBGcyi75rZea5xZqxp7rGptkZMT8qlxVIdv6Z+k7BitAWd6r8qVZfq X-Received: by 2002:a05:6a20:9148:b0:ef:dce0:4955 with SMTP id x8-20020a056a20914800b000efdce04955mr285619pzc.2.1681945058756; Wed, 19 Apr 2023 15:57:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681945058; cv=none; d=google.com; s=arc-20160816; b=Ic66KuQpKQEFdmwl5WzY+OAzk11M/ViwoQumd4mm4AFWjA+Rp20H5BdyjOhzaHnORq 12lEkkh+fRXiJbB6kstcDFQFNWdOcJH98n8T5oyI6nxTr1aYruxuuchJZU9ScS5b8bR3 DSnDXjdpBotxn5VWksjfaKFrpVMFOlbMAZe3uvLA0EYuPQO5sbZZ7kg97pac35gaDuVA gVEEaeeu+i3uC6mP/F9PfBAkQC4U2BoVq1PBfwxFB0ztnBBMOetkYOY270grwjCWIlL8 +eIX0+xgW+aHUgEE9W46AvG5C4QcqGC6ZOSGaIjI4p5YnQPpgIDW3AzhEVejBUNtLT1T VR3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=EfHs6iQcu6f/xzGNIRNs/Y6zNI7wkCv1JLv9sFf5g1M=; b=glD/hrIQ1/1T68WjkuY8mH21d9q1X/dkdANxnP0aTqG4cSrrjELBGBKzkkLabZdlg4 TdAX4Fqn+15IBmG+NFV1jboTB0IpP2X+XfOakpSRsjzH1NNftkgupmiMmy1c8igojOYS gOD3NdkUxwu5b+65Y6frUAbtep3KXULhNNIDj+X+nCiTUpVOR/EJwZaPc1g9Hw4zbdU7 ZVOAoe6QOsx0ni5jycL6aqcxyrtKOXn85cWPe4+dfVxH02Uy/Y8vLWtI6BTTC3O2GNY3 dSLaosN0V5Ktu/OvzcHblBauoVIuTwoZcuNHVi4UaHdA+6XOk3A81uOjjq/BXN5XEu53 Drhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Hf8STPeT; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 5-20020a630f45000000b0051f9ef9f57dsi3902174pgp.364.2023.04.19.15.57.14; Wed, 19 Apr 2023 15:57:38 -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; dkim=pass header.i=@chromium.org header.s=google header.b=Hf8STPeT; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232746AbjDSW5E (ORCPT + 99 others); Wed, 19 Apr 2023 18:57:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232734AbjDSW5C (ORCPT ); Wed, 19 Apr 2023 18:57:02 -0400 Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5FC721738 for ; Wed, 19 Apr 2023 15:56:59 -0700 (PDT) Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-63b62d2f729so373642b3a.1 for ; Wed, 19 Apr 2023 15:56:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1681945019; x=1684537019; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=EfHs6iQcu6f/xzGNIRNs/Y6zNI7wkCv1JLv9sFf5g1M=; b=Hf8STPeTqcCEMBqR/MDrmp1HtnPk6GIH5PFNOTsUN7tPgWqWR1ZyBP8GwDsJkkLKG8 AYhZdFrgwCV8MqXtRmCQi31cmL6jiSjz3Nhdqbn+Ydb7KtggmVC0mWLgTkV8h5LrocTx JMSiKPmPNqI9PaMzeCfkSLedwLBMwC/49yavs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681945019; x=1684537019; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=EfHs6iQcu6f/xzGNIRNs/Y6zNI7wkCv1JLv9sFf5g1M=; b=ZEufqGZrxPsmNJR4PiTB6Kq8E5LFeEYErWbh/GIDRkXC+icjMmU+Q0QR/8D5/TGj6z q0HCjaMyqiZ3XosA0Ujgz511zgaP/HegOQ6i+0d59FmwVrqyWJVioUwuC0yaTF6D9+86 NZT3CKGnTgFVhMAwB/kLZJi5f913bSBlrJ9GDcRPy9f2SgjdzyPcDKd7DOAtZFvHiDIA /99lSy7MF3rBsXqStJRXqR2dJt6IrbQwlfalF/c//SWSkbiJMhvQR0Wo2ala8+Q6OA2A unop+P2OsBRbceeNUWoG5vIJWBfDSNuSd2KA1QwZP/L/vu6RWiku84oTnyufXUmhK6ga AK/g== X-Gm-Message-State: AAQBX9eTg9RaiWaB5APIVe2tzorKqzl4QL1mMcqNKm/MCUeWXFmc+J9f VeWiA6zBqKI0NY27CPKXNJO3eA== X-Received: by 2002:a17:902:e74a:b0:1a6:46d7:77dc with SMTP id p10-20020a170902e74a00b001a646d777dcmr7987289plf.43.1681945018669; Wed, 19 Apr 2023 15:56:58 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:8b1:fa03:670e:b784]) by smtp.gmail.com with ESMTPSA id h15-20020a17090aea8f00b00246ea338c96sm1847101pjz.53.2023.04.19.15.56.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 15:56:57 -0700 (PDT) From: Douglas Anderson To: Catalin Marinas , Will Deacon , Sumit Garg , Daniel Thompson , Marc Zyngier , Mark Rutland Cc: ito-yuichi@fujitsu.com, kgdb-bugreport@lists.sourceforge.net, Chen-Yu Tsai , Masayoshi Mizuma , Peter Zijlstra , Ard Biesheuvel , "Rafael J . Wysocki" , linux-arm-kernel@lists.infradead.org, Stephen Boyd , Lecopzer Chen , Thomas Gleixner , linux-perf-users@vger.kernel.org, Douglas Anderson , Alexandru Elisei , Andrey Konovalov , Ben Dooks , Borislav Petkov , Christophe Leroy , "Darrick J. Wong" , Dave Hansen , "David S. Miller" , "Eric W. Biederman" , Frederic Weisbecker , Gaosheng Cui , "Gautham R. Shenoy" , Greg Kroah-Hartman , "Guilherme G. Piccoli" , Guo Ren , "H. Peter Anvin" , Huacai Chen , Ingo Molnar , Ingo Molnar , "Jason A. Donenfeld" , Jason Wessel , Jianmin Lv , Jiaxun Yang , Jinyang He , Joey Gouly , Kees Cook , Laurent Dufour , Masahiro Yamada , Masayoshi Mizuma , Michael Ellerman , Nicholas Piggin , "Paul E. McKenney" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Pierre Gondois , Qing Zhang , "Russell King (Oracle)" , Russell King , Thomas Bogendoerfer , Ulf Hansson , WANG Xuerui , linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, loongarch@lists.linux.dev, sparclinux@vger.kernel.org, x86@kernel.org Subject: [PATCH v8 00/10] arm64: Add framework to turn an IPI as NMI Date: Wed, 19 Apr 2023 15:55:54 -0700 Message-ID: <20230419225604.21204-1-dianders@chromium.org> X-Mailer: git-send-email 2.40.0.634.g4ca3ef3211-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable 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 This is an attempt to resurrect Sumit's old patch series [1] that allowed us to use the arm64 pseudo-NMI to get backtraces of CPUs and also to round up CPUs in kdb/kgdb. The last post from Sumit that I could find was v7, so I called this series v8. I haven't copied all of his old changelongs here, but you can find them from the link. Since v7, I have: * Addressed the small amount of feedback that was there for v7. * Rebased. * Added a new patch that prevents us from spamming the logs with idle tasks. * Added an extra patch to gracefully fall back to regular IPIs if pseudo-NMIs aren't there. Since there appear to be a few different patches series related to being able to use NMIs to get stack traces of crashed systems, let me try to organize them to the best of my understanding: a) This series. On its own, a) will (among other things) enable stack traces of all running processes with the soft lockup detector if you've enabled the sysctl "kernel.softlockup_all_cpu_backtrace". On its own, a) doesn't give a hard lockup detector. b) A different recently-posted series [2] that adds a hard lockup detector based on perf. On its own, b) gives a stack crawl of the locked up CPU but no stack crawls of other CPUs (even if they're locked too). Together with a) + b) we get everything (full lockup detect, full ability to get stack crawls). c) The old Android "buddy" hard lockup detector [3] that I'm considering trying to upstream. If b) lands then I believe c) would be redundant (at least for arm64). c) on its own is really only useful on arm64 for platforms that can print CPU_DBGPCSR somehow (see [4]). a) + c) is roughly as good as a) + b). [1] https://lore.kernel.org/linux-arm-kernel/1604317487-14543-1-git-send-email-sumit.garg@linaro.org/ [2] https://lore.kernel.org/linux-arm-kernel/20220903093415.15850-1-lecopzer.chen@mediatek.com/ [3] https://issuetracker.google.com/172213097 [4] https://issuetracker.google.com/172213129 Changes in v8: - dynamic_ipi_setup() and dynamic_ipi_teardown() no longer take cpu param - dynamic_ipi_setup() and dynamic_ipi_teardown() no longer take cpu param - Add loongarch support, too - Removed "#ifdef CONFIG_SMP" since arm64 is always SMP - "Tag the arm64 idle functions as __cpuidle" new for v8 - "Provide a stub kgdb_nmicallback() if !CONFIG_KGDB" new for v8 - "Fallback to a regular IPI if NMI isn't enabled" new for v8 Douglas Anderson (3): arm64: idle: Tag the arm64 idle functions as __cpuidle kgdb: Provide a stub kgdb_nmicallback() if !CONFIG_KGDB arm64: ipi_nmi: Fallback to a regular IPI if NMI isn't enabled Sumit Garg (7): arm64: Add framework to turn IPI as NMI irqchip/gic-v3: Enable support for SGIs to act as NMIs arm64: smp: Assign and setup an IPI as NMI nmi: backtrace: Allow runtime arch specific override arm64: ipi_nmi: Add support for NMI backtrace kgdb: Expose default CPUs roundup fallback mechanism arm64: kgdb: Roundup cpus using IPI as NMI arch/arm/include/asm/irq.h | 2 +- arch/arm/kernel/smp.c | 3 +- arch/arm64/include/asm/irq.h | 4 ++ arch/arm64/include/asm/nmi.h | 17 +++++ arch/arm64/kernel/Makefile | 2 +- arch/arm64/kernel/idle.c | 4 +- arch/arm64/kernel/ipi_nmi.c | 103 +++++++++++++++++++++++++++++++ arch/arm64/kernel/kgdb.c | 18 ++++++ arch/arm64/kernel/smp.c | 8 +++ arch/loongarch/include/asm/irq.h | 2 +- arch/loongarch/kernel/process.c | 3 +- arch/mips/include/asm/irq.h | 2 +- arch/mips/kernel/process.c | 3 +- arch/powerpc/include/asm/nmi.h | 2 +- arch/powerpc/kernel/stacktrace.c | 3 +- arch/sparc/include/asm/irq_64.h | 2 +- arch/sparc/kernel/process_64.c | 4 +- arch/x86/include/asm/irq.h | 2 +- arch/x86/kernel/apic/hw_nmi.c | 3 +- drivers/irqchip/irq-gic-v3.c | 29 ++++++--- include/linux/kgdb.h | 13 ++++ include/linux/nmi.h | 12 ++-- kernel/debug/debug_core.c | 8 ++- 23 files changed, 217 insertions(+), 32 deletions(-) create mode 100644 arch/arm64/include/asm/nmi.h create mode 100644 arch/arm64/kernel/ipi_nmi.c -- 2.40.0.634.g4ca3ef3211-goog