From patchwork Thu Aug 24 15:30:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13364378 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 7D826C88CB9 for ; Thu, 24 Aug 2023 15:33:39 +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:MIME-Version:Message-ID:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=XvTUVUTpKiDFoYZXMrnS0McFb1jwvMJWadvbXWebKJk=; b=Pz2pbv1QjqcL6s cnFE7dBDUASBPCxx1623HLE1deed9uza4A3Eu/AT6lSIGQ7GxwFGBPb7y+dXX75vrwKMVe8V7AIwp GHyWxQEcwq0i5WmYBjyiZbMsJejxmXnJYWNYnv+eq+8ShPx+mwKDAMcPcEaszV5ltVyJazb092yB3 t29Pipj9UWlBjHXyhOMsex8/jpdV5K6eMDRjm62t3WpXwBIWsr+0JOcF4J60Hq5jsTbuoGbFkhlwE tnjlCv9d92zjsRQw0lqCcYL2ERfy+i4oYmAhWRUQ5gTuHBfu9hnRfqr00WQ2a0I3Y6bn4WKrJAdzi qo/wun9Ro0PEU0daad+w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qZCKW-003NGq-2I; Thu, 24 Aug 2023 15:33:04 +0000 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qZCKS-003NFU-2o for linux-arm-kernel@lists.infradead.org; Thu, 24 Aug 2023 15:33:02 +0000 Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-68becf931d0so848185b3a.3 for ; Thu, 24 Aug 2023 08:32:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1692891178; x=1693495978; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=fe1DJPH/M9r5VhhLRCsDEvJsRV5UtbuD3TZfculFFlc=; b=JrNmfASeswtd34QkKOVwTriiUUI4JOwFzNytoRoUlCQqM8yPEcRW9fcBEJlM37/haz O9aazri8fbmj2r2WyubLkN9ZW0BCSv6W3UAnmd+5yAm8/yydJe0aKvbTQoAgq86Z8V/F NSi0cT77eIeI8rKYeBQ4j3MSMwuUYJ79TVpmk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692891178; x=1693495978; 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=fe1DJPH/M9r5VhhLRCsDEvJsRV5UtbuD3TZfculFFlc=; b=PAqhhFp81NsmkbXBqNu2Hj02ZeKkjpj2eOVdcyY9qM1vjZjgmTk5DC4JOvZH/utlrs B6EN2vQ9pHm2gCuggbw2LgMlu/WBtD+e3Hs87i8GsaFOzgOgJQA+VWVnVwG5CrMbsixS HzY9WCSkyWeGkvukXWUU/szY45dluiAj3L5JKdXb6mlJzW9iEUFyECfz6ikIY8KUy2CA 45E2y6bIUYHf0Pzl210QofAoONUXVdNxkKKOl/v6JCI6LmvEhlWSHUxG6rMOy4vYHN0L nsZ1GI7ANOH2nUQ+fJf927m60wAJKasWvZjd8lu0g9SfwUS8l/qRKj7BeNU8WRfbtjX+ HvXQ== X-Gm-Message-State: AOJu0YwC0U39GMiq+KyUSJ75TBctpp+Z8KJbgH7S8hVbAKgmgvwH/OIz er+MoBGdTod7zSiRUFRpfKc+gg== X-Google-Smtp-Source: AGHT+IEk4YDqkzw8ckutsuR/oJbE8V5t0g1D42ZcOjrtquCJPdSaeWKfRcMjpjDe+Z46t5ZMTIqEGw== X-Received: by 2002:a05:6a00:174c:b0:68a:45a1:c0f2 with SMTP id j12-20020a056a00174c00b0068a45a1c0f2mr12814638pfc.34.1692891178370; Thu, 24 Aug 2023 08:32:58 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:afa3:fcf5:1b7f:f7e2]) by smtp.gmail.com with ESMTPSA id m30-20020a63711e000000b0056365ee8603sm11631337pgc.67.2023.08.24.08.32.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Aug 2023 08:32:57 -0700 (PDT) From: Douglas Anderson To: Mark Rutland , Catalin Marinas , Will Deacon , Sumit Garg , Daniel Thompson , Marc Zyngier Cc: "Rafael J . Wysocki" , Ard Biesheuvel , Thomas Gleixner , kgdb-bugreport@lists.sourceforge.net, Lecopzer Chen , linux-perf-users@vger.kernel.org, Masayoshi Mizuma , Chen-Yu Tsai , linux-arm-kernel@lists.infradead.org, ito-yuichi@fujitsu.com, Stephen Boyd , Peter Zijlstra , Douglas Anderson , D Scott Phillips , Frederic Weisbecker , Guo Ren , Ingo Molnar , Josh Poimboeuf , Kees Cook , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Sami Tolvanen , Valentin Schneider , linux-kernel@vger.kernel.org Subject: [PATCH v11 0/6] arm64: Add IPI for backtraces / kgdb; try to use NMI for some IPIs Date: Thu, 24 Aug 2023 08:30:26 -0700 Message-ID: <20230824153233.1006420-1-dianders@chromium.org> X-Mailer: git-send-email 2.42.0.rc1.204.g551eb34607-goog MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230824_083300_929125_115C8560 X-CRM114-Status: GOOD ( 29.02 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 started my series at v8. I haven't copied all of his old changelongs here, but you can find them from the link. This patch series targets v6.6. Specifically it can't land in v6.5 since it depends on commit 36759e343ff9 ("nmi_backtrace: allow excluding an arbitrary CPU"). It should be noted that Mark still feels there might be some corner cases where pseudo-NMI is not production ready [2] [3], but as far as I'm aware there are no concrete/documented issues. Regardless of whether this should be enabled for production, though, this series will be invaluable to anyone trying to debug crashes on arm64 machines. v11 of this series addresss Stephen Boyd's feedback on v10 and adds a missing "static" that the patches robot found. v10 of this series attempted to address all of Mark's feedback on v9. As a quick summary: - It includes his patch to remove IPI_WAKEUP, freeing up an extra IPI. - It no longer combines the "kgdb" and "backtrace" IPIs. If we need another IPI these could always be recombined later. - It promotes IPI_CPU_STOP and IPI_CPU_CRASH_STOP to NMI. - It puts nearly all the code directly in smp.c. - Several of the patches are squashed together. - Patch #6 ("kgdb: Provide a stub kgdb_nmicallback() if !CONFIG_KGDB") was dropped from the series since it landed. Between v8 and v9, I had cleaned up this patch series by integrating the 10th patch from v8 [4] into the whole series. As part of this, I renamed the "NMI IPI" to the "debug IPI" since it could now be backed by a regular IPI in the case that pseudo NMIs weren't available. With the fallback, this allowed me to drop some extra patches from the series. This feels (to me) to be pretty clean and hopefully others agree. Any patch I touched significantly I removed Masayoshi and Chen-Yu's tags from. ...also in v8, I reorderd the patches a bit in a way that seemed a little cleaner to me. 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. It can be noted that this patch series works very well with the recent "hardlockup" patches that have landed through Andrew Morton's tree and are currently in mainline. It works especially well with the "buddy" lockup detector. [1] https://lore.kernel.org/linux-arm-kernel/1604317487-14543-1-git-send-email-sumit.garg@linaro.org/ [2] https://lore.kernel.org/lkml/ZFvGqD%2F%2Fpm%2FlZb+p@FVFF77S0Q05N.cambridge.arm.com/ [3] https://lore.kernel.org/lkml/ZNDKVP2m-iiZCz3v@FVFF77S0Q05N.cambridge.arm.com [4] https://lore.kernel.org/r/20230419155341.v8.10.Ic3659997d6243139d0522fc3afcdfd88d7a5f030@changeid/ Changes in v11: - Adjust comment about NR_IPI/MAX_IPI. - Don't use confusing "backed by" idiom in comment. - Made arm64_backtrace_ipi() static. - Updated commit message as per Stephen. - arch_send_wakeup_ipi() now takes an unsigned int. Changes in v10: - ("IPI_CPU_STOP and IPI_CPU_CRASH_STOP should try for NMI") new for v10. - ("arm64: smp: Remove dedicated wakeup IPI") new for v10. - Backtrace now directly supported in smp.c - Don't allocate the cpumask on the stack; just iterate. - Moved kgdb calls to smp.c to avoid needing to export IPI info. - Rewrite as needed for 5.11+ as per Mark Rutland and Sumit. - Squash backtrace into patch adding support for pseudo-NMI IPIs. - kgdb now has its own IPI. Changes in v9: - Added comments that we might not be using NMI always. - Added to commit message that this doesn't catch all cases. - Fold in v8 patch #10 ("Fallback to a regular IPI if NMI isn't enabled") - Moved header file out of "include" since it didn't need to be there. - Remove arm64_supports_nmi() - Remove fallback for when debug IPI isn't available. - Renamed "NMI IPI" to "debug IPI" since it might not be backed by NMI. - arch_trigger_cpumask_backtrace() no longer returns bool Changes in v8: - "Tag the arm64 idle functions as __cpuidle" new for v8 - Removed "#ifdef CONFIG_SMP" since arm64 is always SMP - debug_ipi_setup() and debug_ipi_teardown() no longer take cpu param Douglas Anderson (5): irqchip/gic-v3: Enable support for SGIs to act as NMIs arm64: idle: Tag the arm64 idle functions as __cpuidle arm64: smp: Add arch support for backtrace using pseudo-NMI arm64: smp: IPI_CPU_STOP and IPI_CPU_CRASH_STOP should try for NMI arm64: kgdb: Implement kgdb_roundup_cpus() to enable pseudo-NMI roundup Mark Rutland (1): arm64: smp: Remove dedicated wakeup IPI arch/arm64/include/asm/irq.h | 3 + arch/arm64/include/asm/smp.h | 4 +- arch/arm64/kernel/acpi_parking_protocol.c | 2 +- arch/arm64/kernel/idle.c | 4 +- arch/arm64/kernel/smp.c | 135 +++++++++++++++++----- drivers/irqchip/irq-gic-v3.c | 54 ++++++--- 6 files changed, 153 insertions(+), 49 deletions(-)