diff options
-rw-r--r-- | kernel/sysctl.c | 13 | ||||
-rw-r--r-- | kernel/time/ntp.c | 7 |
2 files changed, 18 insertions, 2 deletions
diff --git a/kernel/sysctl.c b/kernel/sysctl.c index cb6196e3fa99..75635a02336a 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -32,6 +32,8 @@ EXPORT_SYMBOL_GPL(sysctl_long_vals); #if defined(CONFIG_SYSCTL) +extern unsigned int sysctl_ntp_rtc_sync; + /* Constants used for minimum and maximum */ static const int ngroups_max = NGROUPS_MAX; static const int cap_last_cap = CAP_LAST_CAP; @@ -1455,6 +1457,17 @@ int proc_do_static_key(const struct ctl_table *table, int write, } static const struct ctl_table sysctl_subsys_table[] = { +#if defined(CONFIG_GENERIC_CMOS_UPDATE) || defined(CONFIG_RTC_SYSTOHC) + { + .procname = "ntp_rtc_sync", + .data = &sysctl_ntp_rtc_sync, + .maxlen = sizeof(sysctl_ntp_rtc_sync), + .mode = 0644, + .proc_handler = proc_douintvec_minmax, + .extra1 = SYSCTL_ZERO, + .extra2 = SYSCTL_ONE, + }, +#endif #ifdef CONFIG_PROC_SYSCTL { .procname = "sysctl_writes_strict", diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c index 97fa99b96dd0..215640b3f89d 100644 --- a/kernel/time/ntp.c +++ b/kernel/time/ntp.c @@ -490,6 +490,7 @@ out: return leap; } +unsigned int sysctl_ntp_rtc_sync = true; #if defined(CONFIG_GENERIC_CMOS_UPDATE) || defined(CONFIG_RTC_SYSTOHC) static void sync_hw_clock(struct work_struct *work); static DECLARE_WORK(sync_work, sync_hw_clock); @@ -640,7 +641,8 @@ static void sync_hw_clock(struct work_struct *work) * managed to schedule the work between the timer firing and the * work being able to rearm the timer. Wait for the timer to expire. */ - if (!ntp_synced() || hrtimer_is_queued(&sync_hrtimer)) + if (!ntp_synced() || !sysctl_ntp_rtc_sync || + hrtimer_is_queued(&sync_hrtimer)) return; ktime_get_real_ts64(&now); @@ -680,7 +682,8 @@ void ntp_notify_cmos_timer(bool offset_set) * rearmed this queues the work immediately again. No big issue, * just a pointless work scheduled. */ - if (ntp_synced() && !hrtimer_is_queued(&sync_hrtimer)) + if (ntp_synced() && sysctl_ntp_rtc_sync && + !hrtimer_is_queued(&sync_hrtimer)) queue_work(system_freezable_power_efficient_wq, &sync_work); } |