Skip to content

Commit

Permalink
Merge branch 'timers-urgent-for-linus' of git://git.kernel.org/pub/sc…
Browse files Browse the repository at this point in the history
…m/linux/kernel/git/tip/tip

Pull timer fix from Ingo Molnar:
 "One more timekeeping fix for v3.6"

* 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  time: Fix timeekeping_get_ns overflow on 32bit systems
  • Loading branch information
Linus Torvalds committed Sep 21, 2012
2 parents 18f5600 + ec145ba commit 519b3b7
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions kernel/time/timekeeping.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,10 +303,11 @@ void getnstimeofday(struct timespec *ts)
seq = read_seqbegin(&tk->lock);

ts->tv_sec = tk->xtime_sec;
ts->tv_nsec = timekeeping_get_ns(tk);
nsecs = timekeeping_get_ns(tk);

} while (read_seqretry(&tk->lock, seq));

ts->tv_nsec = 0;
timespec_add_ns(ts, nsecs);
}
EXPORT_SYMBOL(getnstimeofday);
Expand Down Expand Up @@ -345,20 +346,22 @@ void ktime_get_ts(struct timespec *ts)
{
struct timekeeper *tk = &timekeeper;
struct timespec tomono;
s64 nsec;
unsigned int seq;

WARN_ON(timekeeping_suspended);

do {
seq = read_seqbegin(&tk->lock);
ts->tv_sec = tk->xtime_sec;
ts->tv_nsec = timekeeping_get_ns(tk);
nsec = timekeeping_get_ns(tk);
tomono = tk->wall_to_monotonic;

} while (read_seqretry(&tk->lock, seq));

set_normalized_timespec(ts, ts->tv_sec + tomono.tv_sec,
ts->tv_nsec + tomono.tv_nsec);
ts->tv_sec += tomono.tv_sec;
ts->tv_nsec = 0;
timespec_add_ns(ts, nsec + tomono.tv_nsec);
}
EXPORT_SYMBOL_GPL(ktime_get_ts);

Expand Down Expand Up @@ -1244,21 +1247,23 @@ void get_monotonic_boottime(struct timespec *ts)
{
struct timekeeper *tk = &timekeeper;
struct timespec tomono, sleep;
s64 nsec;
unsigned int seq;

WARN_ON(timekeeping_suspended);

do {
seq = read_seqbegin(&tk->lock);
ts->tv_sec = tk->xtime_sec;
ts->tv_nsec = timekeeping_get_ns(tk);
nsec = timekeeping_get_ns(tk);
tomono = tk->wall_to_monotonic;
sleep = tk->total_sleep_time;

} while (read_seqretry(&tk->lock, seq));

set_normalized_timespec(ts, ts->tv_sec + tomono.tv_sec + sleep.tv_sec,
ts->tv_nsec + tomono.tv_nsec + sleep.tv_nsec);
ts->tv_sec += tomono.tv_sec + sleep.tv_sec;
ts->tv_nsec = 0;
timespec_add_ns(ts, nsec + tomono.tv_nsec + sleep.tv_nsec);
}
EXPORT_SYMBOL_GPL(get_monotonic_boottime);

Expand Down

0 comments on commit 519b3b7

Please sign in to comment.