mirror of
https://github.com/torvalds/linux.git
synced 2026-09-23 13:14:02 +02:00
Add a new "dump" pretimeout governor that triggers a backtrace of all CPUs (via trigger_all_cpu_backtrace()) to the kernel log buffer. This provides diagnostic information right before the hardware watchdog fires. In addition, update the WATCHDOG_PRETIMEOUT_GOV_SEL Kconfig logic to fall back to the "panic" governor only when both "noop" and "dump" governors are disabled. Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org> Link: https://lore.kernel.org/r/20260707102105.3600275-1-tzungbi@kernel.org Signed-off-by: Guenter Roeck <linux@roeck-us.net>
46 lines
1.1 KiB
C
46 lines
1.1 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* Copyright 2026 Google LLC
|
|
*/
|
|
|
|
#include <linux/kernel.h>
|
|
#include <linux/module.h>
|
|
#include <linux/nmi.h>
|
|
#include <linux/watchdog.h>
|
|
|
|
#include "watchdog_pretimeout.h"
|
|
|
|
/**
|
|
* pretimeout_dump - Dump on watchdog pretimeout event
|
|
* @wdd: watchdog_device
|
|
*
|
|
* Dump all cpu backtrace on pretimeout event.
|
|
*/
|
|
static void pretimeout_dump(struct watchdog_device *wdd)
|
|
{
|
|
pr_alert("watchdog%d: pretimeout event\n", wdd->id);
|
|
if (!trigger_all_cpu_backtrace())
|
|
pr_alert("trigger_all_cpu_backtrace() isn't available\n");
|
|
}
|
|
|
|
static struct watchdog_governor watchdog_gov_dump = {
|
|
.name = "dump",
|
|
.pretimeout = pretimeout_dump,
|
|
};
|
|
|
|
static int __init watchdog_gov_dump_register(void)
|
|
{
|
|
return watchdog_register_governor(&watchdog_gov_dump);
|
|
}
|
|
|
|
static void __exit watchdog_gov_dump_unregister(void)
|
|
{
|
|
watchdog_unregister_governor(&watchdog_gov_dump);
|
|
}
|
|
module_init(watchdog_gov_dump_register);
|
|
module_exit(watchdog_gov_dump_unregister);
|
|
|
|
MODULE_AUTHOR("Tzung-Bi Shih <tzungbi@kernel.org>");
|
|
MODULE_DESCRIPTION("Dump watchdog pretimeout governor");
|
|
MODULE_LICENSE("GPL");
|