[chrony-dev] [PATCH] MacOS X - Reset the drift removal timer following a spike in offset_sd |
[ Thread Index |
Date Index
| More chrony.tuxfamily.org/chrony-dev Archives
]
- To: chrony-dev@xxxxxxxxxxxxxxxxxxxx
- Subject: [chrony-dev] [PATCH] MacOS X - Reset the drift removal timer following a spike in offset_sd
- From: Bryan Christianson <bryan@xxxxxxxxxxxxx>
- Date: Fri, 28 Aug 2015 23:21:01 +1200
- Cc: Bryan Christianson <bryan@xxxxxxxxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=smtpcorp.com; s=a0-2; h=Feedback-ID:X-Smtpcorp-Track:Message-Id:Date: Subject:To:From; bh=rL42B76Q59a4WH+SqtCdsxh47hbmN0w+zusTYuLjs9w=; b=nWgcyFHc4 cOeOTJmFc1brnJX77B2qXpBqA6xWhc9CeG728Lghk4MtmWotGyF0nitv78O+VciEFm7npJNiZYpM8 tWb9Hx4tQhujV2kA02UaOhUynvB5s+1LDtYsnp9kzD42iU5Uvxzi9+XMIXKclIIxl+EchGdLFDFW4 YYPjVqCyeS9rD/LHsuNT18k0oZomd/pjrkAqGtW1xqOfpnRjawBDnOZqDzo48V0W+zC1KQ+5MgJ0h Cgjyf60DugiAGpdCWh7YJdP9pxLV1lKrE1gs/B/2GH3yUyPXnf0VpaceDBWUKWeM2W+GxsLlu7gWx r86EgXjcqwlZq1bBHsaglx2tg==;
- Feedback-id: 149811m:149811acx33YQ:149811soeFRhqf6g:SMTPCORP
When a large spike occurs in offset_sd the drift removal interval can be
set to an excessively long time, although what ever event caused the
perturbation has passed. At the next set_sync_status() we now compare
the expected drift removal interval with that currently in effect.
If they are significantly different, the current timer is cancelled
and new cycle started using the new drift removal interval.
---
sys_macosx.c | 54 +++++++++++++++++++++++++++++++++---------------------
1 file changed, 33 insertions(+), 21 deletions(-)
diff --git a/sys_macosx.c b/sys_macosx.c
index 503f8f1..343c5a0 100644
--- a/sys_macosx.c
+++ b/sys_macosx.c
@@ -79,6 +79,11 @@ static double adjustment_requested;
#define DRIFT_REMOVAL_INTERVAL (4.0)
#define DRIFT_REMOVAL_INTERVAL_MIN (0.5)
+/* if current_drift_removal_interval / drift_removal_interval exceeds this */
+/* ratio, then restart the drift removal timer */
+
+#define DRIFT_REMOVAL_RESTART_RATIO (DRIFT_REMOVAL_INTERVAL / DRIFT_REMOVAL_INTERVAL_MIN)
+
static double drift_removal_interval;
static double current_drift_removal_interval;
static struct timeval Tdrift;
@@ -223,27 +228,6 @@ accrue_offset(double offset, double corr_rate)
/* ================================================== */
-/* use est_error to calculate the drift_removal_interval */
-
-static void
-set_sync_status(int synchronised, double est_error, double max_error)
-{
- double interval;
-
- if (!synchronised) {
- drift_removal_interval = MAX(drift_removal_interval, DRIFT_REMOVAL_INTERVAL);
- return;
- }
-
- interval = ERROR_WEIGHT * est_error / (fabs(current_freq) + FREQUENCY_RES);
- drift_removal_interval = MAX(interval, DRIFT_REMOVAL_INTERVAL_MIN);
-
- DEBUG_LOG(LOGF_SysMacOSX, "est_error: %.3f current_freq: %.3f est drift_removal_interval: %.3f act drift_removal_interval: %.3f",
- est_error * 1.0e6, current_freq * 1.0e6, interval, drift_removal_interval);
-}
-
-/* ================================================== */
-
/* Positive offset means system clock is fast of true time, therefore
step backwards */
@@ -341,6 +325,34 @@ drift_removal_timeout(SCH_ArbitraryArgument not_used)
}
/* ================================================== */
+
+/* use est_error to calculate the drift_removal_interval */
+
+static void
+set_sync_status(int synchronised, double est_error, double max_error)
+{
+ double interval;
+
+ if (!synchronised) {
+ drift_removal_interval = MAX(drift_removal_interval, DRIFT_REMOVAL_INTERVAL);
+ } else {
+ interval = ERROR_WEIGHT * est_error / (fabs(current_freq) + FREQUENCY_RES);
+ drift_removal_interval = MAX(interval, DRIFT_REMOVAL_INTERVAL_MIN);
+
+ DEBUG_LOG(LOGF_SysMacOSX, "est_error: %.3f current_freq: %.3f est drift_removal_interval: %.3f act drift_removal_interval: %.3f",
+ est_error * 1.0e6, current_freq * 1.0e6, interval, drift_removal_interval);
+ }
+
+ if (current_drift_removal_interval / drift_removal_interval > DRIFT_REMOVAL_RESTART_RATIO) {
+ /* recover from a large est_error by resetting the timer */
+ SCH_ArbitraryArgument unused;
+ SCH_RemoveTimeout(drift_removal_id);
+ unused = NULL;
+ drift_removal_timeout(unused);
+ }
+}
+
+/* ================================================== */
/*
Give chronyd real time priority so that time critical calculations
are not pre-empted by the kernel.
--
2.3.2 (Apple Git-55)
--
To unsubscribe email chrony-dev-request@xxxxxxxxxxxxxxxxxxxx with "unsubscribe" in the subject.
For help email chrony-dev-request@xxxxxxxxxxxxxxxxxxxx with "help" in the subject.
Trouble? Email listmaster@xxxxxxxxxxxxxxxxxxxx.