aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/clocksource.h
diff options
context:
space:
mode:
authorJohn Stultz <johnstul@us.ibm.com>2008-08-20 19:37:30 -0400
committerIngo Molnar <mingo@elte.hu>2008-08-21 03:50:24 -0400
commit2d42244ae71d6c7b0884b5664cf2eda30fb2ae68 (patch)
tree947e86ec6e2d7362daa9a170a352c035f3618d64 /include/linux/clocksource.h
parent9a055117d3d9cb562f83f8d4cd88772761f4cab0 (diff)
clocksource: introduce CLOCK_MONOTONIC_RAW
In talking with Josip Loncaric, and his work on clock synchronization (see btime.sf.net), he mentioned that for really close synchronization, it is useful to have access to "hardware time", that is a notion of time that is not in any way adjusted by the clock slewing done to keep close time sync. Part of the issue is if we are using the kernel's ntp adjusted representation of time in order to measure how we should correct time, we can run into what Paul McKenney aptly described as "Painting a road using the lines we're painting as the guide". I had been thinking of a similar problem, and was trying to come up with a way to give users access to a purely hardware based time representation that avoided users having to know the underlying frequency and mask values needed to deal with the wide variety of possible underlying hardware counters. My solution is to introduce CLOCK_MONOTONIC_RAW. This exposes a nanosecond based time value, that increments starting at bootup and has no frequency adjustments made to it what so ever. The time is accessed from userspace via the posix_clock_gettime() syscall, passing CLOCK_MONOTONIC_RAW as the clock_id. Signed-off-by: John Stultz <johnstul@us.ibm.com> Signed-off-by: Roman Zippel <zippel@linux-m68k.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'include/linux/clocksource.h')
-rw-r--r--include/linux/clocksource.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/include/linux/clocksource.h b/include/linux/clocksource.h
index f0a7fb984413..f88d32f8ff7c 100644
--- a/include/linux/clocksource.h
+++ b/include/linux/clocksource.h
@@ -79,6 +79,7 @@ struct clocksource {
79 /* timekeeping specific data, ignore */ 79 /* timekeeping specific data, ignore */
80 cycle_t cycle_interval; 80 cycle_t cycle_interval;
81 u64 xtime_interval; 81 u64 xtime_interval;
82 u32 raw_interval;
82 /* 83 /*
83 * Second part is written at each timer interrupt 84 * Second part is written at each timer interrupt
84 * Keep it in a different cache line to dirty no 85 * Keep it in a different cache line to dirty no
@@ -87,6 +88,7 @@ struct clocksource {
87 cycle_t cycle_last ____cacheline_aligned_in_smp; 88 cycle_t cycle_last ____cacheline_aligned_in_smp;
88 u64 xtime_nsec; 89 u64 xtime_nsec;
89 s64 error; 90 s64 error;
91 struct timespec raw_time;
90 92
91#ifdef CONFIG_CLOCKSOURCE_WATCHDOG 93#ifdef CONFIG_CLOCKSOURCE_WATCHDOG
92 /* Watchdog related data, used by the framework */ 94 /* Watchdog related data, used by the framework */
@@ -215,6 +217,7 @@ static inline void clocksource_calculate_interval(struct clocksource *c,
215 217
216 /* Go back from cycles -> shifted ns, this time use ntp adjused mult */ 218 /* Go back from cycles -> shifted ns, this time use ntp adjused mult */
217 c->xtime_interval = (u64)c->cycle_interval * c->mult; 219 c->xtime_interval = (u64)c->cycle_interval * c->mult;
220 c->raw_interval = ((u64)c->cycle_interval * c->mult_orig) >> c->shift;
218} 221}
219 222
220 223