[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZIb0hd8djM+jJviF@FVFF77S0Q05N>
Date: Mon, 12 Jun 2023 11:33:41 +0100
From: Mark Rutland <mark.rutland@....com>
To: Douglas Anderson <dianders@...omium.org>
Cc: Petr Mladek <pmladek@...e.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Matthias Kaehlcke <mka@...omium.org>,
kgdb-bugreport@...ts.sourceforge.net,
Stephane Eranian <eranian@...gle.com>, mpe@...erman.id.au,
Tzung-Bi Shih <tzungbi@...omium.org>,
Daniel Thompson <daniel.thompson@...aro.org>,
linuxppc-dev@...ts.ozlabs.org, Sumit Garg <sumit.garg@...aro.org>,
npiggin@...il.com, davem@...emloft.net,
Marc Zyngier <maz@...nel.org>,
Stephen Boyd <swboyd@...omium.org>, sparclinux@...r.kernel.org,
christophe.leroy@...roup.eu,
Catalin Marinas <catalin.marinas@....com>,
ravi.v.shankar@...el.com, Randy Dunlap <rdunlap@...radead.org>,
Pingfan Liu <kernelfans@...il.com>,
Guenter Roeck <groeck@...omium.org>,
Lecopzer Chen <lecopzer.chen@...iatek.com>,
Ian Rogers <irogers@...gle.com>, ito-yuichi@...itsu.com,
ricardo.neri@...el.com, linux-arm-kernel@...ts.infradead.org,
linux-perf-users@...r.kernel.org, Will Deacon <will@...nel.org>,
Chen-Yu Tsai <wens@...e.org>, linux-kernel@...r.kernel.org,
Masayoshi Mizuma <msys.mizuma@...il.com>,
Andi Kleen <ak@...ux.intel.com>
Subject: Re: [PATCH v5 15/18] watchdog/perf: Add a weak function for an arch
to detect if perf can use NMIs
On Fri, May 19, 2023 at 10:18:39AM -0700, Douglas Anderson wrote:
> On arm64, NMI support needs to be detected at runtime. Add a weak
> function to the perf hardlockup detector so that an architecture can
> implement it to detect whether NMIs are available.
>
> Signed-off-by: Douglas Anderson <dianders@...omium.org>
> ---
> While I won't object to this patch landing, I consider it part of the
> arm64 perf hardlockup effort. I would be OK with the earlier patches
> in the series landing and then not landing ${SUBJECT} patch nor
> anything else later.
FWIW, everything prior to this looks fine to me, so I reckon it'd be worth
splitting the series here and getting the buddy lockup detector in first, to
avoid a log-jam on all the subsequent NMI bits.
Thanks,
Mark.
> I'll also note that, as an alternative to this, it would be nice if we
> could figure out how to make perf_event_create_kernel_counter() fail
> on arm64 if NMIs aren't available. Maybe we could add a "must_use_nmi"
> element to "struct perf_event_attr"?
>
> (no changes since v4)
>
> Changes in v4:
> - ("Add a weak function for an arch to detect ...") new for v4.
>
> include/linux/nmi.h | 1 +
> kernel/watchdog_perf.c | 12 +++++++++++-
> 2 files changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/include/linux/nmi.h b/include/linux/nmi.h
> index 47db14e7da52..eb616fc07c85 100644
> --- a/include/linux/nmi.h
> +++ b/include/linux/nmi.h
> @@ -210,6 +210,7 @@ static inline bool trigger_single_cpu_backtrace(int cpu)
>
> #ifdef CONFIG_HARDLOCKUP_DETECTOR_PERF
> u64 hw_nmi_get_sample_period(int watchdog_thresh);
> +bool arch_perf_nmi_is_available(void);
> #endif
>
> #if defined(CONFIG_HARDLOCKUP_CHECK_TIMESTAMP) && \
> diff --git a/kernel/watchdog_perf.c b/kernel/watchdog_perf.c
> index 349fcd4d2abc..8ea00c4a24b2 100644
> --- a/kernel/watchdog_perf.c
> +++ b/kernel/watchdog_perf.c
> @@ -234,12 +234,22 @@ void __init hardlockup_detector_perf_restart(void)
> }
> }
>
> +bool __weak __init arch_perf_nmi_is_available(void)
> +{
> + return true;
> +}
> +
> /**
> * watchdog_hardlockup_probe - Probe whether NMI event is available at all
> */
> int __init watchdog_hardlockup_probe(void)
> {
> - int ret = hardlockup_detector_event_create();
> + int ret;
> +
> + if (!arch_perf_nmi_is_available())
> + return -ENODEV;
> +
> + ret = hardlockup_detector_event_create();
>
> if (ret) {
> pr_info("Perf NMI watchdog permanently disabled\n");
> --
> 2.40.1.698.g37aff9b760-goog
>
Powered by blists - more mailing lists