Re: [PATCH] correct inconsistent ntp interval/tick_length usage

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Roman Zippel
Date: Wednesday, January 30, 2008 - 10:02 pm

Hi,

On Wed, 30 Jan 2008, john stultz wrote:


CLOCK_TICK_ADJUST is based on LATCH and HZ, if the update frequency isn't 
based on HZ, there is no point in using it!

Let's look at what actually needs to be done:

1. initializing clock interval:

	clock_cycle_interval = timer_cycle_interval * clock_frequency / timer_frequency

It's simply about converting timer cycles into clock cycles, so they're 
about the same time interval.
We already make it a bit more complicated than necessary as we go via 
nsec:

	ntp_interval = timer_cycle_interval * 10^9nsec / timer_frequency

and in clocksource_calculate_interval() basically:

	clock_cycle_interval = ntp_interval * clock_frequency / 10^9nsec

Without a fixed timer tick it's actually even easier, then we use the same 
frequency for clock and timer and the cycle interval is simply:

	clock_cycle_interval = timer_cycle_interval = clock_frequency / NTP_INTERVAL_FREQ

There is no need to use the adjustment here, you'll only cause a mismatch 
between the clock and timer cycle interval, which had to be corrected by 
NTP.

2. initializing clock adjustment:

	clock_adjust = timer_cycle_interval * NTP_INTERVAL_FREQ / timer_frequency - 1sec

This adjustment is used make up for the difference that the timer 
frequency isn't evenly divisible by HZ, so that the clock is advanced by 
1sec after timer_frequency cycles.

Like above the clock frequency is used for the timer frequency for this 
calculation for CONFIG_NO_HZ, so it would be incorrect to use 
CLOCK_TICK_RATE/LATCH/HZ here and since NTP_INTERVAL_FREQ is quite small 
the resulting adjustment would be rather small, it's easier not to bother 
in this case.

What you're basically trying is to add an error to the clock 
initialization, so that we can later compensate for it. The correct 
solution is really to not add the error in first place, so that there is 
no need to compensate for it.

bye. Roman
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: [PATCH] correct inconsistent ntp interval/tick_length ..., Valdis.Kletnieks, (Thu Jan 24, 2:14 am)
Re: [PATCH] correct inconsistent ntp interval/tick_length ..., Roman Zippel, (Wed Jan 30, 10:02 pm)
[PATCH] Remove obsolete CLOCK_TICK_ADJUST, Roman Zippel, (Thu Feb 28, 9:49 pm)
Re: [PATCH] Remove obsolete CLOCK_TICK_ADJUST, Ray Lee, (Thu Feb 28, 11:25 pm)
Re: [PATCH] Remove obsolete CLOCK_TICK_ADJUST, Roman Zippel, (Fri Feb 29, 6:31 am)
Re: [PATCH] correct inconsistent ntp interval/tick_length ..., Jörg-Volker Peetz, (Fri Feb 29, 11:54 am)
Re: [PATCH] Remove obsolete CLOCK_TICK_ADJUST, Andrew Morton, (Fri Feb 29, 3:08 pm)
Re: [PATCH] Remove obsolete CLOCK_TICK_ADJUST, Roman Zippel, (Fri Feb 29, 3:27 pm)
Re: [PATCH] Remove obsolete CLOCK_TICK_ADJUST, Andrew Morton, (Fri Feb 29, 3:38 pm)
Re: [PATCH] Remove obsolete CLOCK_TICK_ADJUST, john stultz, (Fri Feb 29, 4:11 pm)
Re: [PATCH] Remove obsolete CLOCK_TICK_ADJUST, john stultz, (Fri Feb 29, 4:11 pm)
Re: [PATCH] Remove obsolete CLOCK_TICK_ADJUST, Roman Zippel, (Sat Mar 1, 9:03 pm)