[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230519101840.v5.17.Ia9d02578e89c3f44d3cb12eec8b0176603c8ab2f@changeid>
Date: Fri, 19 May 2023 10:18:41 -0700
From: Douglas Anderson <dianders@...omium.org>
To: Petr Mladek <pmladek@...e.com>,
Andrew Morton <akpm@...ux-foundation.org>
Cc: 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>,
Mark Rutland <mark.rutland@....com>,
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>,
Douglas Anderson <dianders@...omium.org>
Subject: [PATCH v5 17/18] arm64: add hw_nmi_get_sample_period for preparation of lockup detector
From: Lecopzer Chen <lecopzer.chen@...iatek.com>
Set safe maximum CPU frequency to 5 GHz in case a particular platform
doesn't implement cpufreq driver.
Although, architecture doesn't put any restrictions on
maximum frequency but 5 GHz seems to be safe maximum given the available
Arm CPUs in the market which are clocked much less than 5 GHz.
On the other hand, we can't make it much higher as it would lead to
a large hard-lockup detection timeout on parts which are running
slower (eg. 1GHz on Developerbox) and doesn't possess a cpufreq driver.
Co-developed-by: Sumit Garg <sumit.garg@...aro.org>
Signed-off-by: Sumit Garg <sumit.garg@...aro.org>
Co-developed-by: Pingfan Liu <kernelfans@...il.com>
Signed-off-by: Pingfan Liu <kernelfans@...il.com>
Signed-off-by: Lecopzer Chen <lecopzer.chen@...iatek.com>
Signed-off-by: Douglas Anderson <dianders@...omium.org>
---
I yanked this patch from the mailing lists [1] into my series just to
make it easier to avoid conflicts between my series and the one adding
the arm64 perf hardlockup detector, in case someone wanted to test
them both together.
The only change I made here was to remove an extra blank line that
checkpatch complained about.
As mentioned in the cover letter, I'm not really expecting this patch
to land together with the patches for the buddy detector. I included
it with my series simply for convenience of testing both series
together.
NOTE: the previous patch posted by Lecopzer pointed to Sumit's
patch [2] in the commit text but provided no context. I moved it to
this "after the cut" note.
[1] https://lore.kernel.org/r/20220903093415.15850-6-lecopzer.chen@mediatek.com/
[2] http://lore.kernel.org/linux-arm-kernel/1610712101-14929-1-git-send-email-sumit.garg@linaro.org
(no changes since v4)
Changes in v4:
- Pulled ("add hw_nmi_get_sample_period for ...") into my series for v4.
arch/arm64/kernel/Makefile | 1 +
arch/arm64/kernel/watchdog_hld.c | 24 ++++++++++++++++++++++++
2 files changed, 25 insertions(+)
create mode 100644 arch/arm64/kernel/watchdog_hld.c
diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile
index 7c2bb4e72476..cc22011ab66a 100644
--- a/arch/arm64/kernel/Makefile
+++ b/arch/arm64/kernel/Makefile
@@ -45,6 +45,7 @@ obj-$(CONFIG_FUNCTION_TRACER) += ftrace.o entry-ftrace.o
obj-$(CONFIG_MODULES) += module.o
obj-$(CONFIG_ARM64_MODULE_PLTS) += module-plts.o
obj-$(CONFIG_PERF_EVENTS) += perf_regs.o perf_callchain.o
+obj-$(CONFIG_HARDLOCKUP_DETECTOR_PERF) += watchdog_hld.o
obj-$(CONFIG_HAVE_HW_BREAKPOINT) += hw_breakpoint.o
obj-$(CONFIG_CPU_PM) += sleep.o suspend.o
obj-$(CONFIG_CPU_IDLE) += cpuidle.o
diff --git a/arch/arm64/kernel/watchdog_hld.c b/arch/arm64/kernel/watchdog_hld.c
new file mode 100644
index 000000000000..2401eb1b7e55
--- /dev/null
+++ b/arch/arm64/kernel/watchdog_hld.c
@@ -0,0 +1,24 @@
+// SPDX-License-Identifier: GPL-2.0
+#include <linux/cpufreq.h>
+
+/*
+ * Safe maximum CPU frequency in case a particular platform doesn't implement
+ * cpufreq driver. Although, architecture doesn't put any restrictions on
+ * maximum frequency but 5 GHz seems to be safe maximum given the available
+ * Arm CPUs in the market which are clocked much less than 5 GHz. On the other
+ * hand, we can't make it much higher as it would lead to a large hard-lockup
+ * detection timeout on parts which are running slower (eg. 1GHz on
+ * Developerbox) and doesn't possess a cpufreq driver.
+ */
+#define SAFE_MAX_CPU_FREQ 5000000000UL // 5 GHz
+u64 hw_nmi_get_sample_period(int watchdog_thresh)
+{
+ unsigned int cpu = smp_processor_id();
+ unsigned long max_cpu_freq;
+
+ max_cpu_freq = cpufreq_get_hw_max_freq(cpu) * 1000UL;
+ if (!max_cpu_freq)
+ max_cpu_freq = SAFE_MAX_CPU_FREQ;
+
+ return (u64)max_cpu_freq * watchdog_thresh;
+}
--
2.40.1.698.g37aff9b760-goog
Powered by blists - more mailing lists