timekeeping.c (0588000eac9ba4178cebade437da3b28e8fad48f) timekeeping.c (d6ad418763888f617ac5b4849823e4cd670df1dd)
1/*
2 * linux/kernel/time/timekeeping.c
3 *
4 * Kernel timekeeping code and accessor functions
5 *
6 * This code was moved from linux/kernel/timer.c.
7 * Please see that file for copyright and history logs.
8 *

--- 11 unchanged lines hidden (view full) ---

20#include <linux/jiffies.h>
21#include <linux/time.h>
22#include <linux/tick.h>
23#include <linux/stop_machine.h>
24
25
26static struct timekeeper timekeeper;
27
1/*
2 * linux/kernel/time/timekeeping.c
3 *
4 * Kernel timekeeping code and accessor functions
5 *
6 * This code was moved from linux/kernel/timer.c.
7 * Please see that file for copyright and history logs.
8 *

--- 11 unchanged lines hidden (view full) ---

20#include <linux/jiffies.h>
21#include <linux/time.h>
22#include <linux/tick.h>
23#include <linux/stop_machine.h>
24
25
26static struct timekeeper timekeeper;
27
28/*
29 * This read-write spinlock protects us from races in SMP while
30 * playing with xtime.
31 */
32__cacheline_aligned_in_smp DEFINE_SEQLOCK(xtime_lock);
33
34/* flag for if timekeeping is suspended */
35int __read_mostly timekeeping_suspended;
36
37static inline void tk_normalize_xtime(struct timekeeper *tk)
38{
39 while (tk->xtime_nsec >= ((u64)NSEC_PER_SEC << tk->shift)) {
40 tk->xtime_nsec -= (u64)NSEC_PER_SEC << tk->shift;
41 tk->xtime_sec++;

--- 1252 unchanged lines hidden (view full) ---

1294 } while (read_seqretry(&tk->lock, seq));
1295
1296 set_normalized_timespec(&now, now.tv_sec + mono.tv_sec,
1297 now.tv_nsec + mono.tv_nsec);
1298 return now;
1299}
1300
1301/*
28/* flag for if timekeeping is suspended */
29int __read_mostly timekeeping_suspended;
30
31static inline void tk_normalize_xtime(struct timekeeper *tk)
32{
33 while (tk->xtime_nsec >= ((u64)NSEC_PER_SEC << tk->shift)) {
34 tk->xtime_nsec -= (u64)NSEC_PER_SEC << tk->shift;
35 tk->xtime_sec++;

--- 1252 unchanged lines hidden (view full) ---

1288 } while (read_seqretry(&tk->lock, seq));
1289
1290 set_normalized_timespec(&now, now.tv_sec + mono.tv_sec,
1291 now.tv_nsec + mono.tv_nsec);
1292 return now;
1293}
1294
1295/*
1302 * The 64-bit jiffies value is not atomic - you MUST NOT read it
1303 * without sampling the sequence number in xtime_lock.
1304 * jiffies is defined in the linker script...
1296 * Must hold jiffies_lock
1305 */
1306void do_timer(unsigned long ticks)
1307{
1308 jiffies_64 += ticks;
1309 update_wall_time();
1310 calc_global_load(ticks);
1311}
1312

--- 71 unchanged lines hidden (view full) ---

1384/**
1385 * xtime_update() - advances the timekeeping infrastructure
1386 * @ticks: number of ticks, that have elapsed since the last call.
1387 *
1388 * Must be called with interrupts disabled.
1389 */
1390void xtime_update(unsigned long ticks)
1391{
1297 */
1298void do_timer(unsigned long ticks)
1299{
1300 jiffies_64 += ticks;
1301 update_wall_time();
1302 calc_global_load(ticks);
1303}
1304

--- 71 unchanged lines hidden (view full) ---

1376/**
1377 * xtime_update() - advances the timekeeping infrastructure
1378 * @ticks: number of ticks, that have elapsed since the last call.
1379 *
1380 * Must be called with interrupts disabled.
1381 */
1382void xtime_update(unsigned long ticks)
1383{
1392 write_seqlock(&xtime_lock);
1384 write_seqlock(&jiffies_lock);
1393 do_timer(ticks);
1385 do_timer(ticks);
1394 write_sequnlock(&xtime_lock);
1386 write_sequnlock(&jiffies_lock);
1395}
1387}