diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2009-09-18 12:15:24 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-09-18 12:15:24 -0400 |
commit | a03fdb7612874834d6847107198712d18b5242c7 (patch) | |
tree | 9ae81170509fd8b1c23d1b7e8edfa7a2203ffce3 /include | |
parent | 202c4675c55ddf6b443c7e057d2dff6b42ef71aa (diff) | |
parent | 12e09337fe238981cb0c87543306e23775d1a143 (diff) |
Merge branch 'timers-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'timers-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: (34 commits)
time: Prevent 32 bit overflow with set_normalized_timespec()
clocksource: Delay clocksource down rating to late boot
clocksource: clocksource_select must be called with mutex locked
clocksource: Resolve cpu hotplug dead lock with TSC unstable, fix crash
timers: Drop a function prototype
clocksource: Resolve cpu hotplug dead lock with TSC unstable
timer.c: Fix S/390 comments
timekeeping: Fix invalid getboottime() value
timekeeping: Fix up read_persistent_clock() breakage on sh
timekeeping: Increase granularity of read_persistent_clock(), build fix
time: Introduce CLOCK_REALTIME_COARSE
x86: Do not unregister PIT clocksource on PIT oneshot setup/shutdown
clocksource: Avoid clocksource watchdog circular locking dependency
clocksource: Protect the watchdog rating changes with clocksource_mutex
clocksource: Call clocksource_change_rating() outside of watchdog_lock
timekeeping: Introduce read_boot_clock
timekeeping: Increase granularity of read_persistent_clock()
timekeeping: Update clocksource with stop_machine
timekeeping: Add timekeeper read_clock helper functions
timekeeping: Move NTP adjusted clock multiplier to struct timekeeper
...
Fix trivial conflict due to MIPS lemote -> loongson renaming.
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/clocksource.h | 122 | ||||
-rw-r--r-- | include/linux/hrtimer.h | 2 | ||||
-rw-r--r-- | include/linux/time.h | 10 | ||||
-rw-r--r-- | include/linux/timer.h | 5 |
4 files changed, 19 insertions, 120 deletions
diff --git a/include/linux/clocksource.h b/include/linux/clocksource.h index 1219be4fb42e..83d2fbd81b93 100644 --- a/include/linux/clocksource.h +++ b/include/linux/clocksource.h | |||
@@ -14,6 +14,7 @@ | |||
14 | #include <linux/list.h> | 14 | #include <linux/list.h> |
15 | #include <linux/cache.h> | 15 | #include <linux/cache.h> |
16 | #include <linux/timer.h> | 16 | #include <linux/timer.h> |
17 | #include <linux/init.h> | ||
17 | #include <asm/div64.h> | 18 | #include <asm/div64.h> |
18 | #include <asm/io.h> | 19 | #include <asm/io.h> |
19 | 20 | ||
@@ -148,14 +149,11 @@ extern u64 timecounter_cyc2time(struct timecounter *tc, | |||
148 | * @disable: optional function to disable the clocksource | 149 | * @disable: optional function to disable the clocksource |
149 | * @mask: bitmask for two's complement | 150 | * @mask: bitmask for two's complement |
150 | * subtraction of non 64 bit counters | 151 | * subtraction of non 64 bit counters |
151 | * @mult: cycle to nanosecond multiplier (adjusted by NTP) | 152 | * @mult: cycle to nanosecond multiplier |
152 | * @mult_orig: cycle to nanosecond multiplier (unadjusted by NTP) | ||
153 | * @shift: cycle to nanosecond divisor (power of two) | 153 | * @shift: cycle to nanosecond divisor (power of two) |
154 | * @flags: flags describing special properties | 154 | * @flags: flags describing special properties |
155 | * @vread: vsyscall based read | 155 | * @vread: vsyscall based read |
156 | * @resume: resume function for the clocksource, if necessary | 156 | * @resume: resume function for the clocksource, if necessary |
157 | * @cycle_interval: Used internally by timekeeping core, please ignore. | ||
158 | * @xtime_interval: Used internally by timekeeping core, please ignore. | ||
159 | */ | 157 | */ |
160 | struct clocksource { | 158 | struct clocksource { |
161 | /* | 159 | /* |
@@ -169,7 +167,6 @@ struct clocksource { | |||
169 | void (*disable)(struct clocksource *cs); | 167 | void (*disable)(struct clocksource *cs); |
170 | cycle_t mask; | 168 | cycle_t mask; |
171 | u32 mult; | 169 | u32 mult; |
172 | u32 mult_orig; | ||
173 | u32 shift; | 170 | u32 shift; |
174 | unsigned long flags; | 171 | unsigned long flags; |
175 | cycle_t (*vread)(void); | 172 | cycle_t (*vread)(void); |
@@ -181,19 +178,12 @@ struct clocksource { | |||
181 | #define CLKSRC_FSYS_MMIO_SET(mmio, addr) do { } while (0) | 178 | #define CLKSRC_FSYS_MMIO_SET(mmio, addr) do { } while (0) |
182 | #endif | 179 | #endif |
183 | 180 | ||
184 | /* timekeeping specific data, ignore */ | ||
185 | cycle_t cycle_interval; | ||
186 | u64 xtime_interval; | ||
187 | u32 raw_interval; | ||
188 | /* | 181 | /* |
189 | * Second part is written at each timer interrupt | 182 | * Second part is written at each timer interrupt |
190 | * Keep it in a different cache line to dirty no | 183 | * Keep it in a different cache line to dirty no |
191 | * more than one cache line. | 184 | * more than one cache line. |
192 | */ | 185 | */ |
193 | cycle_t cycle_last ____cacheline_aligned_in_smp; | 186 | cycle_t cycle_last ____cacheline_aligned_in_smp; |
194 | u64 xtime_nsec; | ||
195 | s64 error; | ||
196 | struct timespec raw_time; | ||
197 | 187 | ||
198 | #ifdef CONFIG_CLOCKSOURCE_WATCHDOG | 188 | #ifdef CONFIG_CLOCKSOURCE_WATCHDOG |
199 | /* Watchdog related data, used by the framework */ | 189 | /* Watchdog related data, used by the framework */ |
@@ -202,8 +192,6 @@ struct clocksource { | |||
202 | #endif | 192 | #endif |
203 | }; | 193 | }; |
204 | 194 | ||
205 | extern struct clocksource *clock; /* current clocksource */ | ||
206 | |||
207 | /* | 195 | /* |
208 | * Clock source flags bits:: | 196 | * Clock source flags bits:: |
209 | */ | 197 | */ |
@@ -212,6 +200,7 @@ extern struct clocksource *clock; /* current clocksource */ | |||
212 | 200 | ||
213 | #define CLOCK_SOURCE_WATCHDOG 0x10 | 201 | #define CLOCK_SOURCE_WATCHDOG 0x10 |
214 | #define CLOCK_SOURCE_VALID_FOR_HRES 0x20 | 202 | #define CLOCK_SOURCE_VALID_FOR_HRES 0x20 |
203 | #define CLOCK_SOURCE_UNSTABLE 0x40 | ||
215 | 204 | ||
216 | /* simplify initialization of mask field */ | 205 | /* simplify initialization of mask field */ |
217 | #define CLOCKSOURCE_MASK(bits) (cycle_t)((bits) < 64 ? ((1ULL<<(bits))-1) : -1) | 206 | #define CLOCKSOURCE_MASK(bits) (cycle_t)((bits) < 64 ? ((1ULL<<(bits))-1) : -1) |
@@ -268,108 +257,15 @@ static inline u32 clocksource_hz2mult(u32 hz, u32 shift_constant) | |||
268 | } | 257 | } |
269 | 258 | ||
270 | /** | 259 | /** |
271 | * clocksource_read: - Access the clocksource's current cycle value | 260 | * clocksource_cyc2ns - converts clocksource cycles to nanoseconds |
272 | * @cs: pointer to clocksource being read | ||
273 | * | ||
274 | * Uses the clocksource to return the current cycle_t value | ||
275 | */ | ||
276 | static inline cycle_t clocksource_read(struct clocksource *cs) | ||
277 | { | ||
278 | return cs->read(cs); | ||
279 | } | ||
280 | |||
281 | /** | ||
282 | * clocksource_enable: - enable clocksource | ||
283 | * @cs: pointer to clocksource | ||
284 | * | ||
285 | * Enables the specified clocksource. The clocksource callback | ||
286 | * function should start up the hardware and setup mult and field | ||
287 | * members of struct clocksource to reflect hardware capabilities. | ||
288 | */ | ||
289 | static inline int clocksource_enable(struct clocksource *cs) | ||
290 | { | ||
291 | int ret = 0; | ||
292 | |||
293 | if (cs->enable) | ||
294 | ret = cs->enable(cs); | ||
295 | |||
296 | /* | ||
297 | * The frequency may have changed while the clocksource | ||
298 | * was disabled. If so the code in ->enable() must update | ||
299 | * the mult value to reflect the new frequency. Make sure | ||
300 | * mult_orig follows this change. | ||
301 | */ | ||
302 | cs->mult_orig = cs->mult; | ||
303 | |||
304 | return ret; | ||
305 | } | ||
306 | |||
307 | /** | ||
308 | * clocksource_disable: - disable clocksource | ||
309 | * @cs: pointer to clocksource | ||
310 | * | ||
311 | * Disables the specified clocksource. The clocksource callback | ||
312 | * function should power down the now unused hardware block to | ||
313 | * save power. | ||
314 | */ | ||
315 | static inline void clocksource_disable(struct clocksource *cs) | ||
316 | { | ||
317 | /* | ||
318 | * Save mult_orig in mult so clocksource_enable() can | ||
319 | * restore the value regardless if ->enable() updates | ||
320 | * the value of mult or not. | ||
321 | */ | ||
322 | cs->mult = cs->mult_orig; | ||
323 | |||
324 | if (cs->disable) | ||
325 | cs->disable(cs); | ||
326 | } | ||
327 | |||
328 | /** | ||
329 | * cyc2ns - converts clocksource cycles to nanoseconds | ||
330 | * @cs: Pointer to clocksource | ||
331 | * @cycles: Cycles | ||
332 | * | 261 | * |
333 | * Uses the clocksource and ntp ajdustment to convert cycle_ts to nanoseconds. | 262 | * Converts cycles to nanoseconds, using the given mult and shift. |
334 | * | 263 | * |
335 | * XXX - This could use some mult_lxl_ll() asm optimization | 264 | * XXX - This could use some mult_lxl_ll() asm optimization |
336 | */ | 265 | */ |
337 | static inline s64 cyc2ns(struct clocksource *cs, cycle_t cycles) | 266 | static inline s64 clocksource_cyc2ns(cycle_t cycles, u32 mult, u32 shift) |
338 | { | ||
339 | u64 ret = (u64)cycles; | ||
340 | ret = (ret * cs->mult) >> cs->shift; | ||
341 | return ret; | ||
342 | } | ||
343 | |||
344 | /** | ||
345 | * clocksource_calculate_interval - Calculates a clocksource interval struct | ||
346 | * | ||
347 | * @c: Pointer to clocksource. | ||
348 | * @length_nsec: Desired interval length in nanoseconds. | ||
349 | * | ||
350 | * Calculates a fixed cycle/nsec interval for a given clocksource/adjustment | ||
351 | * pair and interval request. | ||
352 | * | ||
353 | * Unless you're the timekeeping code, you should not be using this! | ||
354 | */ | ||
355 | static inline void clocksource_calculate_interval(struct clocksource *c, | ||
356 | unsigned long length_nsec) | ||
357 | { | 267 | { |
358 | u64 tmp; | 268 | return ((u64) cycles * mult) >> shift; |
359 | |||
360 | /* Do the ns -> cycle conversion first, using original mult */ | ||
361 | tmp = length_nsec; | ||
362 | tmp <<= c->shift; | ||
363 | tmp += c->mult_orig/2; | ||
364 | do_div(tmp, c->mult_orig); | ||
365 | |||
366 | c->cycle_interval = (cycle_t)tmp; | ||
367 | if (c->cycle_interval == 0) | ||
368 | c->cycle_interval = 1; | ||
369 | |||
370 | /* Go back from cycles -> shifted ns, this time use ntp adjused mult */ | ||
371 | c->xtime_interval = (u64)c->cycle_interval * c->mult; | ||
372 | c->raw_interval = ((u64)c->cycle_interval * c->mult_orig) >> c->shift; | ||
373 | } | 269 | } |
374 | 270 | ||
375 | 271 | ||
@@ -380,6 +276,8 @@ extern void clocksource_touch_watchdog(void); | |||
380 | extern struct clocksource* clocksource_get_next(void); | 276 | extern struct clocksource* clocksource_get_next(void); |
381 | extern void clocksource_change_rating(struct clocksource *cs, int rating); | 277 | extern void clocksource_change_rating(struct clocksource *cs, int rating); |
382 | extern void clocksource_resume(void); | 278 | extern void clocksource_resume(void); |
279 | extern struct clocksource * __init __weak clocksource_default_clock(void); | ||
280 | extern void clocksource_mark_unstable(struct clocksource *cs); | ||
383 | 281 | ||
384 | #ifdef CONFIG_GENERIC_TIME_VSYSCALL | 282 | #ifdef CONFIG_GENERIC_TIME_VSYSCALL |
385 | extern void update_vsyscall(struct timespec *ts, struct clocksource *c); | 283 | extern void update_vsyscall(struct timespec *ts, struct clocksource *c); |
@@ -394,4 +292,6 @@ static inline void update_vsyscall_tz(void) | |||
394 | } | 292 | } |
395 | #endif | 293 | #endif |
396 | 294 | ||
295 | extern void timekeeping_notify(struct clocksource *clock); | ||
296 | |||
397 | #endif /* _LINUX_CLOCKSOURCE_H */ | 297 | #endif /* _LINUX_CLOCKSOURCE_H */ |
diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h index 4759917adc71..ff037f0b1b4e 100644 --- a/include/linux/hrtimer.h +++ b/include/linux/hrtimer.h | |||
@@ -91,7 +91,6 @@ enum hrtimer_restart { | |||
91 | * @function: timer expiry callback function | 91 | * @function: timer expiry callback function |
92 | * @base: pointer to the timer base (per cpu and per clock) | 92 | * @base: pointer to the timer base (per cpu and per clock) |
93 | * @state: state information (See bit values above) | 93 | * @state: state information (See bit values above) |
94 | * @cb_entry: list head to enqueue an expired timer into the callback list | ||
95 | * @start_site: timer statistics field to store the site where the timer | 94 | * @start_site: timer statistics field to store the site where the timer |
96 | * was started | 95 | * was started |
97 | * @start_comm: timer statistics field to store the name of the process which | 96 | * @start_comm: timer statistics field to store the name of the process which |
@@ -108,7 +107,6 @@ struct hrtimer { | |||
108 | enum hrtimer_restart (*function)(struct hrtimer *); | 107 | enum hrtimer_restart (*function)(struct hrtimer *); |
109 | struct hrtimer_clock_base *base; | 108 | struct hrtimer_clock_base *base; |
110 | unsigned long state; | 109 | unsigned long state; |
111 | struct list_head cb_entry; | ||
112 | #ifdef CONFIG_TIMER_STATS | 110 | #ifdef CONFIG_TIMER_STATS |
113 | int start_pid; | 111 | int start_pid; |
114 | void *start_site; | 112 | void *start_site; |
diff --git a/include/linux/time.h b/include/linux/time.h index ea16c1a01d51..56787c093345 100644 --- a/include/linux/time.h +++ b/include/linux/time.h | |||
@@ -75,7 +75,7 @@ extern unsigned long mktime(const unsigned int year, const unsigned int mon, | |||
75 | const unsigned int day, const unsigned int hour, | 75 | const unsigned int day, const unsigned int hour, |
76 | const unsigned int min, const unsigned int sec); | 76 | const unsigned int min, const unsigned int sec); |
77 | 77 | ||
78 | extern void set_normalized_timespec(struct timespec *ts, time_t sec, long nsec); | 78 | extern void set_normalized_timespec(struct timespec *ts, time_t sec, s64 nsec); |
79 | extern struct timespec timespec_add_safe(const struct timespec lhs, | 79 | extern struct timespec timespec_add_safe(const struct timespec lhs, |
80 | const struct timespec rhs); | 80 | const struct timespec rhs); |
81 | 81 | ||
@@ -101,7 +101,8 @@ extern struct timespec xtime; | |||
101 | extern struct timespec wall_to_monotonic; | 101 | extern struct timespec wall_to_monotonic; |
102 | extern seqlock_t xtime_lock; | 102 | extern seqlock_t xtime_lock; |
103 | 103 | ||
104 | extern unsigned long read_persistent_clock(void); | 104 | extern void read_persistent_clock(struct timespec *ts); |
105 | extern void read_boot_clock(struct timespec *ts); | ||
105 | extern int update_persistent_clock(struct timespec now); | 106 | extern int update_persistent_clock(struct timespec now); |
106 | extern int no_sync_cmos_clock __read_mostly; | 107 | extern int no_sync_cmos_clock __read_mostly; |
107 | void timekeeping_init(void); | 108 | void timekeeping_init(void); |
@@ -109,6 +110,8 @@ extern int timekeeping_suspended; | |||
109 | 110 | ||
110 | unsigned long get_seconds(void); | 111 | unsigned long get_seconds(void); |
111 | struct timespec current_kernel_time(void); | 112 | struct timespec current_kernel_time(void); |
113 | struct timespec __current_kernel_time(void); /* does not hold xtime_lock */ | ||
114 | struct timespec get_monotonic_coarse(void); | ||
112 | 115 | ||
113 | #define CURRENT_TIME (current_kernel_time()) | 116 | #define CURRENT_TIME (current_kernel_time()) |
114 | #define CURRENT_TIME_SEC ((struct timespec) { get_seconds(), 0 }) | 117 | #define CURRENT_TIME_SEC ((struct timespec) { get_seconds(), 0 }) |
@@ -147,6 +150,7 @@ extern struct timespec timespec_trunc(struct timespec t, unsigned gran); | |||
147 | extern int timekeeping_valid_for_hres(void); | 150 | extern int timekeeping_valid_for_hres(void); |
148 | extern void update_wall_time(void); | 151 | extern void update_wall_time(void); |
149 | extern void update_xtime_cache(u64 nsec); | 152 | extern void update_xtime_cache(u64 nsec); |
153 | extern void timekeeping_leap_insert(int leapsecond); | ||
150 | 154 | ||
151 | struct tms; | 155 | struct tms; |
152 | extern void do_sys_times(struct tms *); | 156 | extern void do_sys_times(struct tms *); |
@@ -241,6 +245,8 @@ struct itimerval { | |||
241 | #define CLOCK_PROCESS_CPUTIME_ID 2 | 245 | #define CLOCK_PROCESS_CPUTIME_ID 2 |
242 | #define CLOCK_THREAD_CPUTIME_ID 3 | 246 | #define CLOCK_THREAD_CPUTIME_ID 3 |
243 | #define CLOCK_MONOTONIC_RAW 4 | 247 | #define CLOCK_MONOTONIC_RAW 4 |
248 | #define CLOCK_REALTIME_COARSE 5 | ||
249 | #define CLOCK_MONOTONIC_COARSE 6 | ||
244 | 250 | ||
245 | /* | 251 | /* |
246 | * The IDs of various hardware clocks: | 252 | * The IDs of various hardware clocks: |
diff --git a/include/linux/timer.h b/include/linux/timer.h index be62ec2ebea5..a2d1eb6cb3f0 100644 --- a/include/linux/timer.h +++ b/include/linux/timer.h | |||
@@ -175,11 +175,6 @@ extern int mod_timer_pinned(struct timer_list *timer, unsigned long expires); | |||
175 | 175 | ||
176 | /* | 176 | /* |
177 | * Return when the next timer-wheel timeout occurs (in absolute jiffies), | 177 | * Return when the next timer-wheel timeout occurs (in absolute jiffies), |
178 | * locks the timer base: | ||
179 | */ | ||
180 | extern unsigned long next_timer_interrupt(void); | ||
181 | /* | ||
182 | * Return when the next timer-wheel timeout occurs (in absolute jiffies), | ||
183 | * locks the timer base and does the comparison against the given | 178 | * locks the timer base and does the comparison against the given |
184 | * jiffie. | 179 | * jiffie. |
185 | */ | 180 | */ |