History

arm64: add hw_nmi_get_sample_period for preparation of lockup detector

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.

Lecopzer Chen committed 3 years ago

Commit 94946f91 parent 930d8f82 files · +25 −0Browse files

Unified · Split

2 files
  1. arch/arm64/kernel/Makefile +1 −0
  2. arch/arm64/kernel/watchdog_hld.c +24 −0
arch/arm64/kernel/Makefile+1−0
@@ -45,6 +45,7 @@ obj-$(CONFIG_FUNCTION_TRACER) += ftrace.o entry-ftrace.o · 44 unmodified lines
45obj-$(CONFIG_MODULES) += module.o45obj-$(CONFIG_MODULES) += module.o
46obj-$(CONFIG_ARM64_MODULE_PLTS) += module-plts.o46obj-$(CONFIG_ARM64_MODULE_PLTS) += module-plts.o
47obj-$(CONFIG_PERF_EVENTS) += perf_regs.o perf_callchain.o47obj-$(CONFIG_PERF_EVENTS) += perf_regs.o perf_callchain.o
48obj-$(CONFIG_HARDLOCKUP_DETECTOR_PERF) += watchdog_hld.o
48obj-$(CONFIG_HAVE_HW_BREAKPOINT) += hw_breakpoint.o49obj-$(CONFIG_HAVE_HW_BREAKPOINT) += hw_breakpoint.o
49obj-$(CONFIG_CPU_PM) += sleep.o suspend.o50obj-$(CONFIG_CPU_PM) += sleep.o suspend.o
50obj-$(CONFIG_CPU_IDLE) += cpuidle.o51obj-$(CONFIG_CPU_IDLE) += cpuidle.o
arch/arm64/kernel/watchdog_hld.c+24−0
@@ -0,0 +1,24 @@
1// SPDX-License-Identifier: GPL-2.0
2#include <linux/cpufreq.h>
3
4/*
5 * Safe maximum CPU frequency in case a particular platform doesn't implement
6 * cpufreq driver. Although, architecture doesn't put any restrictions on
7 * maximum frequency but 5 GHz seems to be safe maximum given the available
8 * Arm CPUs in the market which are clocked much less than 5 GHz. On the other
9 * hand, we can't make it much higher as it would lead to a large hard-lockup
10 * detection timeout on parts which are running slower (eg. 1GHz on
11 * Developerbox) and doesn't possess a cpufreq driver.
12 */
13#define SAFE_MAX_CPU_FREQ 5000000000UL // 5 GHz
14u64 hw_nmi_get_sample_period(int watchdog_thresh)
15{
16 unsigned int cpu = smp_processor_id();
17 unsigned long max_cpu_freq;
18
19 max_cpu_freq = cpufreq_get_hw_max_freq(cpu) * 1000UL;
20 if (!max_cpu_freq)
21 max_cpu_freq = SAFE_MAX_CPU_FREQ;
22
23 return (u64)max_cpu_freq * watchdog_thresh;
24}