]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
Add corrtimeratio directive
authorMiroslav Lichvar <mlichvar@redhat.com>
Tue, 15 Nov 2011 11:24:50 +0000 (12:24 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Tue, 15 Nov 2011 17:25:49 +0000 (18:25 +0100)
The corrtimeratio directive controls the ratio between the
duration in which the clock is slewed for an average correction
according to the source history and the interval in which the
corrections are done (usually the NTP polling interval).  Corrections
larger than the average take less time and smaller corrections take
more time, the amount of the correction and the correction time are
inversely proportional.

Increasing corrtimeratio makes the overall frequency error of
the system clock smaller, but increases the overall time error as
the corrections will take longer.

By default, the ratio is 1, which means the duration of an average
correction will be close to the update interval.

chrony.texi
conf.c
conf.h
reference.c

index 3704df6ec03c5f21bbd1c369f841a7d0d95f007a..5984f7bd8162a152dcb2e0e7ff2f36c2146ef048 100644 (file)
@@ -1173,6 +1173,7 @@ directives can occur in any order in the file.
 * cmdallow directive::          Give control access to chronyc on other computers
 * cmddeny directive::           Deny control access to chronyc on other computers
 * commandkey directive::        Set runtime command key
+* corrtimeratio directive::     Set correction time ratio
 * cmdport directive::           Set port to use for runtime commanding
 * deny directive::              Deny access to NTP clients
 * driftfile directive::         Specify location of file containing drift data
@@ -1493,6 +1494,35 @@ cmdport 257
 This would make @code{chronyd} use 257/udp as its command port.
 (@code{chronyc} would need to be run with the @code{-p 257} switch to
 inter-operate correctly).
+@c }}}
+@c {{{ corrtimeratio
+@node corrtimeratio directive
+@subsection corrtimeratio
+When @code{chronyd} makes a time correction, it controls how quickly
+the system clock is slewed (so far only on Linux).  This rate
+temporarily affects the frequency error of the system clock.
+
+The @code{corrtimeratio} directive controls the ratio between the
+duration in which the clock is slewed for an average correction
+according to the source history and the interval in which the
+corrections are done (usually the NTP polling interval).  Corrections
+larger than the average take less time and smaller corrections take
+more time, the amount of the correction and the correction time are
+inversely proportional.
+
+Increasing @code{corrtimeratio} makes the overall frequency error of
+the system clock smaller, but increases the overall time error as
+the corrections will take longer.
+
+By default, the ratio is 1, which means the duration of an average
+correction will be close to the update interval.
+
+The syntax is
+
+@example
+corrtimeratio 10
+@end example
+
 @c }}}
 @c {{{ deny
 @node deny directive
diff --git a/conf.c b/conf.c
index ced1bb740cb3173cc0f6f3134dabeaab704d0722..c8df69e85a239c95fa4f281fa1292711023152e9 100644 (file)
--- a/conf.c
+++ b/conf.c
@@ -76,6 +76,7 @@ static void parse_logbanner(const char *);
 static void parse_logdir(const char *);
 static void parse_maxupdateskew(const char *);
 static void parse_maxclockerror(const char *);
+static void parse_corrtimeratio(const char *);
 static void parse_reselectdist(const char *);
 static void parse_stratumweight(const char *);
 static void parse_peer(const char *);
@@ -122,6 +123,7 @@ static char *drift_file = NULL;
 static char *rtc_file = NULL;
 static unsigned long command_key_id;
 static double max_update_skew = 1000.0;
+static double correction_time_ratio = 1.0;
 static double max_clock_error = 1.0; /* in ppm */
 
 static double reselect_distance = 1e-4;
@@ -239,6 +241,7 @@ static const Command commands[] = {
   {"dumpdir", 7, parse_dumpdir},
   {"maxupdateskew", 13, parse_maxupdateskew},
   {"maxclockerror", 13, parse_maxclockerror},
+  {"corrtimeratio", 13, parse_corrtimeratio},
   {"commandkey", 10, parse_commandkey},
   {"initstepslew", 12, parse_initstepslew},
   {"local", 5, parse_local},
@@ -632,6 +635,16 @@ parse_maxclockerror(const char *line)
 
 /* ================================================== */
 
+static void
+parse_corrtimeratio(const char *line)
+{
+  if (sscanf(line, "%lf", &correction_time_ratio) != 1) {
+    LOG(LOGS_WARN, LOGF_Configure, "Could not read correction time ratio at line %d", line_number);
+  }
+}
+
+/* ================================================== */
+
 static void
 parse_reselectdist(const char *line)
 {
@@ -1477,6 +1490,14 @@ CNF_GetMaxClockError(void)
 
 /* ================================================== */
 
+double
+CNF_GetCorrectionTimeRatio(void)
+{
+  return correction_time_ratio;
+}
+
+/* ================================================== */
+
 double
 CNF_GetReselectDistance(void)
 {
diff --git a/conf.h b/conf.h
index b95ab78f020c1ff731b51b1c05309d9a45a1ea62..4c208c75c93a74e4342098056adf76ef55613a45 100644 (file)
--- a/conf.h
+++ b/conf.h
@@ -74,6 +74,7 @@ extern void CNF_GetLinuxFreqScale(int *set, double *freq_scale);
 /* Value returned in ppm, as read from file */
 extern double CNF_GetMaxUpdateSkew(void);
 extern double CNF_GetMaxClockError(void);
+extern double CNF_GetCorrectionTimeRatio(void);
 
 extern double CNF_GetReselectDistance(void);
 extern double CNF_GetStratumWeight(void);
index c2c316e017154338bb22806dc52f80cfb21b2a23..27837ad0a769a76bc6e42ffd9f8589501642235c 100644 (file)
@@ -56,6 +56,8 @@ static double our_root_dispersion;
 
 static double max_update_skew;
 
+static double correction_time_ratio;
+
 /* Flag indicating that we are initialised */
 static int initialised = 0;
 
@@ -181,6 +183,8 @@ REF_Initialise(void)
 
   max_update_skew = fabs(CNF_GetMaxUpdateSkew()) * 1.0e-6;
 
+  correction_time_ratio = CNF_GetCorrectionTimeRatio();
+
   enable_local_stratum = CNF_AllowLocalReference(&local_stratum);
 
   CNF_GetMakeStep(&make_step_limit, &make_step_threshold);
@@ -619,13 +623,14 @@ REF_SetReference(int stratum,
      Define correction rate as the area of the region bounded by the graph of
      offset corrected in time. Set the rate so that the time needed to correct
      an offset equal to the current sourcestats stddev will be equal to the
-     update interval (assuming linear adjustment). The offset and the
-     time needed to make the correction are inversely proportional.
+     update interval multiplied by the correction time ratio (assuming linear
+     adjustment). The offset and the time needed to make the correction are
+     inversely proportional.
 
      This is only a suggestion and it's up to the system driver how the
      adjustment will be executed. */
 
-  correction_rate = 0.5 * offset_sd * update_interval;
+  correction_rate = correction_time_ratio * 0.5 * offset_sd * update_interval;
 
   /* Eliminate updates that are based on totally unreliable frequency
      information */