summaryrefslogtreecommitdiff
path: root/kernel/sysctl.c
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@armlinux.org.uk>2017-09-21 12:11:49 +0100
committerRussell King (Oracle) <rmk+kernel@armlinux.org.uk>2025-09-29 10:27:25 +0100
commit95f4eadf4f769d16f5b54832fc54d68e07e56998 (patch)
treecd16d3dd4a386716d6bdd1ee200a70519e726b4d /kernel/sysctl.c
parent3e025ed07352570f5480cbdab4c75253f2d7c7c7 (diff)
rtc: add procfs sysctl to control RTC updates
Add a procfs sysctl to allow the RTC updates by the NTP code to be disabled. This is necessary if one wishes to adjust the RTC trimming. When performing such an adjustment, one would want to compare the RTC against a good reference. One way to do that is to synchronise the systems own time using NTP, but doing so causes the kernel to set the RTC every 11 minutes. This repeated setting prevents measuring the long-term drift of the RTC, and so prevents any attempt to trim the RTC for better accuracy. This sysctl defaults to enabled, so existing behaviour is preserved. When one wishes to adjust the long-term drift, the RTC update can be disabled via: echo 0 > /proc/sys/kernel/ntp_rtc_sync, the drift measured, and the update subsequently re-enabled. The next update will be triggered by the next successful adjtimex call. Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Diffstat (limited to 'kernel/sysctl.c')
-rw-r--r--kernel/sysctl.c13
1 files changed, 13 insertions, 0 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",