aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorYicong Yang <yangyicong@hisilicon.com>2025-07-01 19:02:13 +0800
committerWill Deacon <will@kernel.org>2025-07-04 13:17:30 +0100
commit60bc47b5a0b164082d448815d7db3066266aa3ed (patch)
tree49037ceaa09b4317f10ba5a5c5139bd56f07b274 /kernel
parentLinux 6.16-rc1 (diff)
downloadlinux-60bc47b5a0b164082d448815d7db3066266aa3ed.tar.gz
linux-60bc47b5a0b164082d448815d7db3066266aa3ed.zip
watchdog/perf: Provide function for adjusting the event period
Architecture's using perf events for hard lockup detection needs to convert the watchdog_thresh to the event's period, some architecture for example arm64 perform this conversion using the CPU's maximum frequency which will be acquired by cpufreq. However by the time the lockup detector's initialized the cpufreq driver may not be initialized, thus launch a watchdog with inaccurate period. Provide a function hardlockup_detector_perf_adjust_period() to allowing adjust the event period. Then architecture can update with more accurate period if cpufreq is initialized. Reviewed-by: Douglas Anderson <dianders@chromium.org> Signed-off-by: Yicong Yang <yangyicong@hisilicon.com> Link: https://lore.kernel.org/r/20250701110214.27242-2-yangyicong@huawei.com Signed-off-by: Will Deacon <will@kernel.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/watchdog_perf.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/kernel/watchdog_perf.c b/kernel/watchdog_perf.c
index 75af12ff774e..9c58f5b4381d 100644
--- a/kernel/watchdog_perf.c
+++ b/kernel/watchdog_perf.c
@@ -187,6 +187,28 @@ void watchdog_hardlockup_disable(unsigned int cpu)
}
/**
+ * hardlockup_detector_perf_adjust_period - Adjust the event period due
+ * to current cpu frequency change
+ * @period: The target period to be set
+ */
+void hardlockup_detector_perf_adjust_period(u64 period)
+{
+ struct perf_event *event = this_cpu_read(watchdog_ev);
+
+ if (!(watchdog_enabled & WATCHDOG_HARDLOCKUP_ENABLED))
+ return;
+
+ if (!event)
+ return;
+
+ if (event->attr.sample_period == period)
+ return;
+
+ if (perf_event_period(event, period))
+ pr_err("failed to change period to %llu\n", period);
+}
+
+/**
* hardlockup_detector_perf_stop - Globally stop watchdog events
*
* Special interface for x86 to handle the perf HT bug.