login
Header Space

 
 

[PATCH 4/8] increase time_offset resolution

Previous thread: [PATCH 6/8] Rename TICK_LENGTH_SHIFT to NTP_SCALE_SHIFT by zippel on Friday, March 14, 2008 - 2:40 pm. (1 message)

Next thread: [PATCH 1/8] cleanup ntp.c by zippel on Friday, March 14, 2008 - 2:40 pm. (3 messages)
To: <linux-kernel@...>
Cc: <akpm@...>, <johnstul@...>
Date: Friday, March 14, 2008 - 2:40 pm

time_offset is already a 64bit value but its resolution barely used, so
this makes better use of it by replacing SHIFT_UPDATE with
TICK_LENGTH_SHIFT.
Side note: the SHIFT_HZ in SHIFT_UPDATE was incorrect for CONFIG_NO_HZ
and the primary reason for changing time_offset to 64bit to avoid the
overflow.

Signed-off-by: Roman Zippel &lt;zippel@linux-m68k.org&gt;

---
 include/linux/timex.h |    9 ++-------
 kernel/time/ntp.c     |   23 +++++++++++------------
 2 files changed, 13 insertions(+), 19 deletions(-)

Index: linux-2.6-mm/include/linux/timex.h
===================================================================
--- linux-2.6-mm.orig/include/linux/timex.h
+++ linux-2.6-mm/include/linux/timex.h
@@ -74,27 +74,22 @@
 #define MAXTC		10	/* maximum time constant (shift) */
 
 /*
- * The SHIFT_UPDATE define establishes the decimal point of the
- * time_offset variable which represents the current offset with
- * respect to standard time.
- *
  * SHIFT_USEC defines the scaling (shift) of the time_freq and
  * time_tolerance variables, which represent the current frequency
  * offset and maximum frequency tolerance.
  */
-#define SHIFT_UPDATE (SHIFT_HZ + 1) /* time offset scale (shift) */
 #define SHIFT_USEC 16		/* frequency offset scale (shift) */
 #define PPM_SCALE (NSEC_PER_USEC &lt;&lt; (TICK_LENGTH_SHIFT - SHIFT_USEC))
 #define PPM_SCALE_INV_SHIFT 20
 #define PPM_SCALE_INV ((1ll &lt;&lt; (PPM_SCALE_INV_SHIFT + TICK_LENGTH_SHIFT)) / \
 		       PPM_SCALE + 1)
 
-#define MAXPHASE 512000L        /* max phase error (us) */
+#define MAXPHASE 500000000l	/* max phase error (ns) */
 #define MAXFREQ 500000		/* max frequency error (ns/s) */
 #define MAXFREQ_SCALED ((s64)MAXFREQ &lt;&lt; TICK_LENGTH_SHIFT)
 #define MINSEC 256		/* min interval between updates (s) */
 #define MAXSEC 2048		/* max interval between updates (s) */
-#define	NTP_PHASE_LIMIT	(MAXPHASE &lt;&lt; 5)	/* beyond max. dispersion */
+#define NTP_PHASE_LIMIT ((MAXPHASE / NSEC_PER_USEC) &lt;&lt; 5) /* beyond max. disp...
Previous thread: [PATCH 6/8] Rename TICK_LENGTH_SHIFT to NTP_SCALE_SHIFT by zippel on Friday, March 14, 2008 - 2:40 pm. (1 message)

Next thread: [PATCH 1/8] cleanup ntp.c by zippel on Friday, March 14, 2008 - 2:40 pm. (3 messages)
speck-geostationary