From: john stultz <johnstul@us.ibm.com>
To: akpm@osdl.org
Cc: john stultz <johnstul@us.ibm.com>,
linux-kernel@vger.kernel.org, george@wildturkeyranch.net,
Steven Rostedt <rostedt@goodmis.org>,
Thomas Gleixner <tglx@linutronix.de>,
Ulrich Windl <ulrich.windl@rz.uni-regensburg.de>,
Roman Zippel <zippel@linux-m68k.org>, Ingo Molnar <mingo@elte.hu>,
Paul Mackerras <paulus@samba.org>
Subject: [PATCH 3/10] Time: Let user request precision from current_tick_length()
Date: Wed, 22 Mar 2006 20:06:07 -0700 [thread overview]
Message-ID: <20060323030606.19338.46175.sendpatchset@cog.beaverton.ibm.com> (raw)
In-Reply-To: <20060323030547.19338.95102.sendpatchset@cog.beaverton.ibm.com>
Change the current_tick_length() function so it takes an
argument which specifies how much precision to return in shifted
nanoseconds. This provides a simple way to convert between NTPs
internal nanoseconds shifted by (SHIFT_SCALE - 10) to other shifted
nanosecond units that are used by the clocksource abstraction.
Signed-off-by John Stultz <johnstul@us.ibm.com>
arch/powerpc/kernel/time.c | 2 +-
include/linux/timex.h | 2 +-
kernel/timer.c | 21 +++++++++++++++++----
3 files changed, 19 insertions(+), 6 deletions(-)
linux-2.6.16_timeofday-core2_C1.patch
============================================
diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
index 86f7e3d..08a53a4 100644
--- a/arch/powerpc/kernel/time.c
+++ b/arch/powerpc/kernel/time.c
@@ -315,7 +315,7 @@ static __inline__ void timer_recalc_offs
if (__USE_RTC())
return;
- tlen = current_tick_length();
+ tlen = current_tick_length(SHIFT_SCALE - 10);
offset = cur_tb - do_gtod.varp->tb_orig_stamp;
if (tlen == last_tick_len && offset < 0x80000000u)
return;
diff --git a/include/linux/timex.h b/include/linux/timex.h
index b7ca120..e239f2d 100644
--- a/include/linux/timex.h
+++ b/include/linux/timex.h
@@ -346,7 +346,7 @@ time_interpolator_reset(void)
#endif /* !CONFIG_TIME_INTERPOLATION */
/* Returns how long ticks are at present, in ns / 2^(SHIFT_SCALE-10). */
-extern u64 current_tick_length(void);
+extern u64 current_tick_length(long);
#endif /* KERNEL */
diff --git a/kernel/timer.c b/kernel/timer.c
index 78a9d03..dc9b4ec 100644
--- a/kernel/timer.c
+++ b/kernel/timer.c
@@ -791,16 +791,29 @@ static void update_wall_time_one_tick(vo
* Return how long ticks are at the moment, that is, how much time
* update_wall_time_one_tick will add to xtime next time we call it
* (assuming no calls to do_adjtimex in the meantime).
- * The return value is in fixed-point nanoseconds with SHIFT_SCALE-10
- * bits to the right of the binary point.
+ * The return value is in fixed-point nanoseconds shifted by the
+ * specified number of bits to the right of the binary point.
* This function has no side-effects.
*/
-u64 current_tick_length(void)
+u64 current_tick_length(long shift)
{
long delta_nsec;
+ u64 ret;
+ /* calculate the finest interval NTP will allow.
+ * ie: nanosecond value shifted by (SHIFT_SCALE - 10)
+ */
delta_nsec = tick_nsec + adjtime_adjustment() * 1000;
- return ((u64) delta_nsec << (SHIFT_SCALE - 10)) + time_adj;
+ ret = ((u64) delta_nsec << (SHIFT_SCALE - 10)) + time_adj;
+
+ /* convert from (SHIFT_SCALE - 10) to specified shift scale: */
+ shift = shift - (SHIFT_SCALE - 10);
+ if (shift < 0)
+ ret >>= -shift;
+ else
+ ret <<= shift;
+
+ return ret;
}
/* XXX - all of this timekeeping code should be later moved to time.c */
next prev parent reply other threads:[~2006-03-23 3:06 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-03-23 3:05 [PATCHSET 0/10] Time: Generic Timekeeping (v.C1) john stultz
2006-03-23 3:05 ` [PATCH 1/10] Time: Clocksource Infrastructure john stultz
2006-03-23 3:06 ` [PATCH 2/10] Time: Use clocksource infrastructure for update_wall_time john stultz
2006-03-23 3:06 ` john stultz [this message]
2006-03-23 3:06 ` [PATCH 4/10] Time: Use clocksource abstraction for NTP adjustments john stultz
2006-03-23 3:06 ` [PATCH 5/10] Time: Introduce arch generic time accessors john stultz
2006-03-23 3:06 ` [PATCH 6/10] Time: i386 Conversion - part 1: Move timer_pit.c to i8253.c john stultz
2006-03-23 3:06 ` [PATCH 7/10] Time: i386 Conversion - part 2: Rework TSC Support john stultz
2006-03-23 3:06 ` [PATCH 8/10] Time: i386 Conversion - part 3: Enable Generic Timekeeping john stultz
2006-03-23 3:06 ` [PATCH 9/10] Time: i386 Conversion - part 4: Remove Old timer_opts Code john stultz
2006-03-23 3:06 ` [PATCH 10/10] Time: i386 Clocksource Drivers john stultz
2006-03-23 12:48 ` [PATCHSET 0/10] Time: Generic Timekeeping (v.C1) Roman Zippel
2006-03-23 14:20 ` Thomas Gleixner
2006-03-23 13:45 ` Roman Zippel
2006-03-23 19:40 ` john stultz
-- strict thread matches above, loose matches on Subject: below --
2006-03-18 0:39 [PATCHSET 0/10] Time: Generic Timekeeping (v.C0) john stultz
2006-03-18 0:40 ` [PATCH 3/10] Time: Let user request precision from current_tick_length() john stultz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060323030606.19338.46175.sendpatchset@cog.beaverton.ibm.com \
--to=johnstul@us.ibm.com \
--cc=akpm@osdl.org \
--cc=george@wildturkeyranch.net \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=paulus@samba.org \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--cc=ulrich.windl@rz.uni-regensburg.de \
--cc=zippel@linux-m68k.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox