From: Douglas Anderson <dianders@chromium.org> To: Catalin Marinas <catalin.marinas@arm.com>, Will Deacon <will@kernel.org>, Sumit Garg <sumit.garg@linaro.org>, Daniel Thompson <daniel.thompson@linaro.org>, Marc Zyngier <maz@kernel.org>, Mark Rutland <mark.rutland@arm.com> Cc: ito-yuichi@fujitsu.com, kgdb-bugreport@lists.sourceforge.net, Chen-Yu Tsai <wens@csie.org>, Masayoshi Mizuma <msys.mizuma@gmail.com>, Peter Zijlstra <peterz@infradead.org>, Ard Biesheuvel <ardb@kernel.org>, "Rafael J . Wysocki" <rafael.j.wysocki@intel.com>, linux-arm-kernel@lists.infradead.org, Stephen Boyd <swboyd@chromium.org>, Lecopzer Chen <lecopzer.chen@mediatek.com>, Thomas Gleixner <tglx@linutronix.de>, linux-perf-users@vger.kernel.org, Douglas Anderson <dianders@chromium.org>, Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>, linux-kernel@vger.kernel.org Subject: [PATCH v8 10/10] arm64: ipi_nmi: Fallback to a regular IPI if NMI isn't enabled Date: Wed, 19 Apr 2023 15:56:04 -0700 [thread overview] Message-ID: <20230419155341.v8.10.Ic3659997d6243139d0522fc3afcdfd88d7a5f030@changeid> (raw) In-Reply-To: <20230419225604.21204-1-dianders@chromium.org> The current ipi_nmi implementation relies on the arm64 pseudo-NMI support. This needs to be enabled in both the kernel config with CONFIG_ARM64_PSEUDO_NMI and on the kernel command line with "irqchip.gicv3_pseudo_nmi=1". Let's add a fallback of using a regular IPI if the NMI isn't enabled. The fallback mechanism of using a regular IPI matches what arm32 does all the time since there is no NMI there. The reason for doing this is to make the trigger_all_cpu_backtrace() class of functions work. While those functions all return a bool indicating that the caller should try a fallback upon failure, an inspection of the callers shows that nearly nobody implements a fallback. It's better to at least provide something here. Signed-off-by: Douglas Anderson <dianders@chromium.org> --- I dunno what people think of this patch. If it's great, we could actually drop some of the patches out of this series since some of them are to account for the fact that we might not be able to register an "ipi_nmi". If it's awful, it could simply be dropped. Changes in v8: - "Fallback to a regular IPI if NMI isn't enabled" new for v8 arch/arm64/kernel/ipi_nmi.c | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/arch/arm64/kernel/ipi_nmi.c b/arch/arm64/kernel/ipi_nmi.c index 2adaaf1519e5..02868752845c 100644 --- a/arch/arm64/kernel/ipi_nmi.c +++ b/arch/arm64/kernel/ipi_nmi.c @@ -16,6 +16,7 @@ static struct irq_desc *ipi_nmi_desc __read_mostly; static int ipi_nmi_id __read_mostly; +static bool is_nmi; bool arm64_supports_nmi(void) { @@ -62,8 +63,12 @@ void dynamic_ipi_setup(void) if (!ipi_nmi_desc) return; - if (!prepare_percpu_nmi(ipi_nmi_id)) - enable_percpu_nmi(ipi_nmi_id, IRQ_TYPE_NONE); + if (is_nmi) { + if (!prepare_percpu_nmi(ipi_nmi_id)) + enable_percpu_nmi(ipi_nmi_id, IRQ_TYPE_NONE); + } else { + enable_percpu_irq(ipi_nmi_id, IRQ_TYPE_NONE); + } } void dynamic_ipi_teardown(void) @@ -71,14 +76,28 @@ void dynamic_ipi_teardown(void) if (!ipi_nmi_desc) return; - disable_percpu_nmi(ipi_nmi_id); - teardown_percpu_nmi(ipi_nmi_id); + if (is_nmi) { + disable_percpu_nmi(ipi_nmi_id); + teardown_percpu_nmi(ipi_nmi_id); + } else { + disable_percpu_irq(ipi_nmi_id); + } } void __init set_smp_dynamic_ipi(int ipi) { + int err; + if (!request_percpu_nmi(ipi, ipi_nmi_handler, "IPI", &cpu_number)) { - ipi_nmi_desc = irq_to_desc(ipi); - ipi_nmi_id = ipi; + is_nmi = true; + } else { + err = request_percpu_irq(ipi, ipi_nmi_handler, "IPI", &cpu_number); + if (WARN_ON(err)) + return; + + irq_set_status_flags(ipi, IRQ_HIDDEN); } + + ipi_nmi_desc = irq_to_desc(ipi); + ipi_nmi_id = ipi; } -- 2.40.0.634.g4ca3ef3211-goog
WARNING: multiple messages have this Message-ID (diff)
From: Douglas Anderson <dianders@chromium.org> To: Catalin Marinas <catalin.marinas@arm.com>, Will Deacon <will@kernel.org>, Sumit Garg <sumit.garg@linaro.org>, Daniel Thompson <daniel.thompson@linaro.org>, Marc Zyngier <maz@kernel.org>, Mark Rutland <mark.rutland@arm.com> Cc: ito-yuichi@fujitsu.com, kgdb-bugreport@lists.sourceforge.net, Chen-Yu Tsai <wens@csie.org>, Masayoshi Mizuma <msys.mizuma@gmail.com>, Peter Zijlstra <peterz@infradead.org>, Ard Biesheuvel <ardb@kernel.org>, "Rafael J . Wysocki" <rafael.j.wysocki@intel.com>, linux-arm-kernel@lists.infradead.org, Stephen Boyd <swboyd@chromium.org>, Lecopzer Chen <lecopzer.chen@mediatek.com>, Thomas Gleixner <tglx@linutronix.de>, linux-perf-users@vger.kernel.org, Douglas Anderson <dianders@chromium.org>, Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>, linux-kernel@vger.kernel.org Subject: [PATCH v8 10/10] arm64: ipi_nmi: Fallback to a regular IPI if NMI isn't enabled Date: Wed, 19 Apr 2023 15:56:04 -0700 [thread overview] Message-ID: <20230419155341.v8.10.Ic3659997d6243139d0522fc3afcdfd88d7a5f030@changeid> (raw) In-Reply-To: <20230419225604.21204-1-dianders@chromium.org> The current ipi_nmi implementation relies on the arm64 pseudo-NMI support. This needs to be enabled in both the kernel config with CONFIG_ARM64_PSEUDO_NMI and on the kernel command line with "irqchip.gicv3_pseudo_nmi=1". Let's add a fallback of using a regular IPI if the NMI isn't enabled. The fallback mechanism of using a regular IPI matches what arm32 does all the time since there is no NMI there. The reason for doing this is to make the trigger_all_cpu_backtrace() class of functions work. While those functions all return a bool indicating that the caller should try a fallback upon failure, an inspection of the callers shows that nearly nobody implements a fallback. It's better to at least provide something here. Signed-off-by: Douglas Anderson <dianders@chromium.org> --- I dunno what people think of this patch. If it's great, we could actually drop some of the patches out of this series since some of them are to account for the fact that we might not be able to register an "ipi_nmi". If it's awful, it could simply be dropped. Changes in v8: - "Fallback to a regular IPI if NMI isn't enabled" new for v8 arch/arm64/kernel/ipi_nmi.c | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/arch/arm64/kernel/ipi_nmi.c b/arch/arm64/kernel/ipi_nmi.c index 2adaaf1519e5..02868752845c 100644 --- a/arch/arm64/kernel/ipi_nmi.c +++ b/arch/arm64/kernel/ipi_nmi.c @@ -16,6 +16,7 @@ static struct irq_desc *ipi_nmi_desc __read_mostly; static int ipi_nmi_id __read_mostly; +static bool is_nmi; bool arm64_supports_nmi(void) { @@ -62,8 +63,12 @@ void dynamic_ipi_setup(void) if (!ipi_nmi_desc) return; - if (!prepare_percpu_nmi(ipi_nmi_id)) - enable_percpu_nmi(ipi_nmi_id, IRQ_TYPE_NONE); + if (is_nmi) { + if (!prepare_percpu_nmi(ipi_nmi_id)) + enable_percpu_nmi(ipi_nmi_id, IRQ_TYPE_NONE); + } else { + enable_percpu_irq(ipi_nmi_id, IRQ_TYPE_NONE); + } } void dynamic_ipi_teardown(void) @@ -71,14 +76,28 @@ void dynamic_ipi_teardown(void) if (!ipi_nmi_desc) return; - disable_percpu_nmi(ipi_nmi_id); - teardown_percpu_nmi(ipi_nmi_id); + if (is_nmi) { + disable_percpu_nmi(ipi_nmi_id); + teardown_percpu_nmi(ipi_nmi_id); + } else { + disable_percpu_irq(ipi_nmi_id); + } } void __init set_smp_dynamic_ipi(int ipi) { + int err; + if (!request_percpu_nmi(ipi, ipi_nmi_handler, "IPI", &cpu_number)) { - ipi_nmi_desc = irq_to_desc(ipi); - ipi_nmi_id = ipi; + is_nmi = true; + } else { + err = request_percpu_irq(ipi, ipi_nmi_handler, "IPI", &cpu_number); + if (WARN_ON(err)) + return; + + irq_set_status_flags(ipi, IRQ_HIDDEN); } + + ipi_nmi_desc = irq_to_desc(ipi); + ipi_nmi_id = ipi; } -- 2.40.0.634.g4ca3ef3211-goog _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2023-04-19 22:58 UTC|newest] Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-04-19 22:55 [PATCH v8 00/10] arm64: Add framework to turn an IPI as NMI Douglas Anderson 2023-04-19 22:55 ` Douglas Anderson 2023-04-19 22:55 ` [PATCH v8 01/10] arm64: Add framework to turn " Douglas Anderson 2023-04-19 22:55 ` Douglas Anderson 2023-04-19 22:55 ` [PATCH v8 02/10] irqchip/gic-v3: Enable support for SGIs to act as NMIs Douglas Anderson 2023-04-19 22:55 ` Douglas Anderson 2023-04-19 22:55 ` [PATCH v8 03/10] arm64: smp: Assign and setup an IPI as NMI Douglas Anderson 2023-04-19 22:55 ` Douglas Anderson 2023-04-24 17:53 ` Doug Anderson 2023-04-24 17:53 ` Doug Anderson 2023-04-19 22:55 ` [PATCH v8 04/10] nmi: backtrace: Allow runtime arch specific override Douglas Anderson 2023-04-19 22:55 ` Douglas Anderson 2023-04-19 22:55 ` [PATCH v8 05/10] arm64: ipi_nmi: Add support for NMI backtrace Douglas Anderson 2023-04-19 22:55 ` Douglas Anderson 2023-04-19 22:56 ` [PATCH v8 06/10] arm64: idle: Tag the arm64 idle functions as __cpuidle Douglas Anderson 2023-04-19 22:56 ` Douglas Anderson 2023-05-10 16:43 ` Mark Rutland 2023-05-10 21:13 ` Doug Anderson 2023-04-19 22:56 ` [PATCH v8 07/10] kgdb: Expose default CPUs roundup fallback mechanism Douglas Anderson 2023-04-19 22:56 ` Douglas Anderson 2023-05-12 13:48 ` Daniel Thompson 2023-05-15 23:21 ` Doug Anderson 2023-05-15 23:21 ` Doug Anderson 2023-06-01 21:47 ` Doug Anderson 2023-06-01 21:47 ` Doug Anderson 2023-04-19 22:56 ` [PATCH v8 08/10] kgdb: Provide a stub kgdb_nmicallback() if !CONFIG_KGDB Douglas Anderson 2023-04-19 22:56 ` Douglas Anderson 2023-05-11 14:34 ` Doug Anderson 2023-05-12 13:52 ` Daniel Thompson 2023-04-19 22:56 ` [PATCH v8 09/10] arm64: kgdb: Roundup cpus using IPI as NMI Douglas Anderson 2023-04-19 22:56 ` Douglas Anderson 2023-05-12 14:00 ` Daniel Thompson 2023-05-15 23:11 ` Doug Anderson 2023-05-15 23:11 ` Doug Anderson 2023-04-19 22:56 ` Douglas Anderson [this message] 2023-04-19 22:56 ` [PATCH v8 10/10] arm64: ipi_nmi: Fallback to a regular IPI if NMI isn't enabled Douglas Anderson 2023-05-10 15:28 ` [PATCH v8 00/10] arm64: Add framework to turn an IPI as NMI Doug Anderson 2023-05-10 15:28 ` Doug Anderson 2023-05-10 16:30 ` Mark Rutland 2023-05-10 16:30 ` Mark Rutland 2023-05-10 16:42 ` Doug Anderson 2023-05-10 16:42 ` Doug Anderson 2023-05-16 10:09 ` Sumit Garg 2023-05-16 10:09 ` Sumit Garg 2023-06-01 21:46 ` Doug Anderson 2023-06-01 21:46 ` Doug Anderson
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20230419155341.v8.10.Ic3659997d6243139d0522fc3afcdfd88d7a5f030@changeid \ --to=dianders@chromium.org \ --cc=ardb@kernel.org \ --cc=catalin.marinas@arm.com \ --cc=daniel.thompson@linaro.org \ --cc=ito-yuichi@fujitsu.com \ --cc=kgdb-bugreport@lists.sourceforge.net \ --cc=lecopzer.chen@mediatek.com \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-perf-users@vger.kernel.org \ --cc=m.mizuma@jp.fujitsu.com \ --cc=mark.rutland@arm.com \ --cc=maz@kernel.org \ --cc=msys.mizuma@gmail.com \ --cc=peterz@infradead.org \ --cc=rafael.j.wysocki@intel.com \ --cc=sumit.garg@linaro.org \ --cc=swboyd@chromium.org \ --cc=tglx@linutronix.de \ --cc=wens@csie.org \ --cc=will@kernel.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.