sdei_watchdog: set secure timer period base on 'watchdog_thresh'

commit 13ddc12768ca98d36ec03bfa21a30b3ebc91673d openeuler.

The period of the secure timer is set to 3s by BIOS. That means the
secure timer interrupt will trigger every 3 seconds. To further decrease
the NMI watchdog's effect on performance, this patch set the period of
the secure timer base on 'watchdog_thresh'. This variable is initiallized
to 10s. We can also set the period at runtime by modifying
'/proc/sys/kernel/watchdog_thresh'

Signed-off-by: huwentao <huwentao19@h-partners.com>
This commit is contained in:
Xiongfeng Wang 2021-02-20 11:01:01 +08:00 committed by lcy
parent 3d3ce61def
commit 4108f89bf6
5 changed files with 23 additions and 1 deletions

View File

@ -30,7 +30,11 @@ int watchdog_nmi_enable(unsigned int cpu)
if (!sdei_watchdog_registered)
return -EINVAL;
#ifdef CONFIG_HARDLOCKUP_CHECK_TIMESTAMP
refresh_hld_last_timestamp();
#endif
sdei_api_set_secure_timer_period(watchdog_thresh);
ret = sdei_api_event_enable(sdei_watchdog_event_num);
if (ret) {
@ -104,6 +108,17 @@ int __init watchdog_nmi_probe(void)
return sdei_watchdog_event_num;
}
/*
* After we introduced 'sdei_api_set_secure_timer_period', we disselect
* 'CONFIG_HARDLOCKUP_CHECK_TIMESTAMP'. So we need to make sure that
* firmware can set the period of the secure timer and the timer
* interrupt doesn't trigger too soon.
*/
if (sdei_api_set_secure_timer_period(watchdog_thresh)) {
pr_err("Firmware doesn't support setting the secure timer period, please update your BIOS !\n");
return -EINVAL;
}
on_each_cpu(sdei_nmi_watchdog_bind, NULL, true);
ret = sdei_event_register(sdei_watchdog_event_num,

View File

@ -208,6 +208,12 @@ int sdei_api_clear_eoi(int hwirq)
NULL);
}
int sdei_api_set_secure_timer_period(int sec)
{
return invoke_sdei_fn(SDEI_1_0_FN_SET_SECURE_TIMER_PERIOD, sec, 0, 0, 0,
0, NULL);
}
static int sdei_api_event_get_info(u32 event, u32 info, u64 *result)
{
return invoke_sdei_fn(SDEI_1_0_FN_SDEI_EVENT_GET_INFO, event, info, 0,

View File

@ -46,6 +46,7 @@ int sdei_api_event_interrupt_bind(int hwirq);
int sdei_api_event_disable(u32 event_num);
int sdei_api_event_enable(u32 event_num);
int sdei_api_clear_eoi(int hwirq);
int sdei_api_set_secure_timer_period(int sec);
/* GHES register/unregister helpers */
int sdei_register_ghes(struct ghes *ghes, sdei_event_callback *normal_cb,

View File

@ -25,6 +25,7 @@
#define SDEI_1_0_FN_SDEI_PRIVATE_RESET SDEI_1_0_FN(0x11)
#define SDEI_1_0_FN_SDEI_SHARED_RESET SDEI_1_0_FN(0x12)
#define SDEI_1_0_FN_SDEI_CLEAR_EOI SDEI_1_0_FN(0x18)
#define SDEI_1_0_FN_SET_SECURE_TIMER_PERIOD SDEI_1_0_FN(0x19)
#define SDEI_VERSION_MAJOR_SHIFT 48
#define SDEI_VERSION_MAJOR_MASK 0x7fff

View File

@ -857,7 +857,6 @@ config SDEI_WATCHDOG
bool "SDEI NMI Watchdog support"
depends on ARM_SDE_INTERFACE
select HAVE_HARDLOCKUP_DETECTOR_ARCH
select HARDLOCKUP_CHECK_TIMESTAMP
select HARDLOCKUP_DETECTOR
#