From 75af6f507df6c3570d9914831bd9e5765c150ec2 Mon Sep 17 00:00:00 2001 From: stevesk <> Date: Tue, 10 Feb 2009 16:52:09 +0000 Subject: [PATCH] log tiny frequency adjustments at debug only. ok henning@, 'I think I agree' otto@ --- src/usr.sbin/ntpd/ntpd.c | 19 ++++++++++++++----- src/usr.sbin/ntpd/ntpd.h | 3 ++- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/usr.sbin/ntpd/ntpd.c b/src/usr.sbin/ntpd/ntpd.c index 5459777d..cc9befaa 100644 --- a/src/usr.sbin/ntpd/ntpd.c +++ b/src/usr.sbin/ntpd/ntpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ntpd.c,v 1.63 2009/02/06 21:48:00 stevesk Exp $ */ +/* $OpenBSD: ntpd.c,v 1.64 2009/02/10 16:52:09 stevesk Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -380,6 +380,7 @@ void ntpd_adjfreq(double relfreq, int wrlog) { int64_t curfreq; + double ppmfreq; int r; if (adjfreq(NULL, &curfreq) == -1) { @@ -393,10 +394,18 @@ ntpd_adjfreq(double relfreq, int wrlog) */ curfreq += relfreq * 1e9 * (1LL << 32); r = writefreq(curfreq / 1e9 / (1LL << 32)); - if (wrlog) - log_info("adjusting clock frequency by %f to %fppm%s", - relfreq * 1e6, curfreq / 1e3 / (1LL << 32), - r ? "" : " (no drift file)"); + ppmfreq = relfreq * 1e6; + if (wrlog) { + if (ppmfreq >= LOG_NEGLIGIBLE_ADJFREQ || + ppmfreq <= -LOG_NEGLIGIBLE_ADJFREQ) + log_info("adjusting clock frequency by %f to %fppm%s", + ppmfreq, curfreq / 1e3 / (1LL << 32), + r ? "" : " (no drift file)"); + else + log_debug("adjusting clock frequency by %f to %fppm%s", + ppmfreq, curfreq / 1e3 / (1LL << 32), + r ? "" : " (no drift file)"); + } if (adjfreq(&curfreq, NULL) == -1) log_warn("adjfreq failed"); diff --git a/src/usr.sbin/ntpd/ntpd.h b/src/usr.sbin/ntpd/ntpd.h index cd182569..4c037ab4 100644 --- a/src/usr.sbin/ntpd/ntpd.h +++ b/src/usr.sbin/ntpd/ntpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ntpd.h,v 1.97 2009/02/06 21:48:00 stevesk Exp $ */ +/* $OpenBSD: ntpd.h,v 1.98 2009/02/10 16:52:09 stevesk Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -56,6 +56,7 @@ #define SENSOR_OFFSETS 7 #define SETTIME_TIMEOUT 15 /* max seconds to wait with -s */ #define LOG_NEGLIGIBLE_ADJTIME 32 /* negligible drift to not log (ms) */ +#define LOG_NEGLIGIBLE_ADJFREQ 0.05 /* negligible rate to not log (ppm) */ #define FREQUENCY_SAMPLES 8 /* samples for est. of permanent drift */ #define MAX_FREQUENCY_ADJUST 128e-5 /* max correction per iteration */ #define REPORT_INTERVAL (24*60*60) /* interval between status reports */