aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/time
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-09-21 17:25:46 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-09-21 17:25:46 -0400
commit519b3b742d7d29c3386f0f35f3cee5dd362dd8e2 (patch)
tree1be195c58ea6e209ddd1c1325e3c9d9565972f21 /kernel/time
parent18f5600ba2629feca202a7d6387b9c32371af329 (diff)
parentec145babe754f9ea1079034a108104b6001e001c (diff)
Merge branch 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/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
Diffstat (limited to 'kernel/time')
-rw-r--r--kernel/time/timekeeping.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 34e5eac8142..d3b91e75cec 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -303,10 +303,11 @@ void getnstimeofday(struct timespec *ts)
303 seq = read_seqbegin(&tk->lock); 303 seq = read_seqbegin(&tk->lock);
304 304
305 ts->tv_sec = tk->xtime_sec; 305 ts->tv_sec = tk->xtime_sec;
306 ts->tv_nsec = timekeeping_get_ns(tk); 306 nsecs = timekeeping_get_ns(tk);
307 307
308 } while (read_seqretry(&tk->lock, seq)); 308 } while (read_seqretry(&tk->lock, seq));
309 309
310 ts->tv_nsec = 0;
310 timespec_add_ns(ts, nsecs); 311 timespec_add_ns(ts, nsecs);
311} 312}
312EXPORT_SYMBOL(getnstimeofday); 313EXPORT_SYMBOL(getnstimeofday);
@@ -345,6 +346,7 @@ void ktime_get_ts(struct timespec *ts)
345{ 346{
346 struct timekeeper *tk = &timekeeper; 347 struct timekeeper *tk = &timekeeper;
347 struct timespec tomono; 348 struct timespec tomono;
349 s64 nsec;
348 unsigned int seq; 350 unsigned int seq;
349 351
350 WARN_ON(timekeeping_suspended); 352 WARN_ON(timekeeping_suspended);
@@ -352,13 +354,14 @@ void ktime_get_ts(struct timespec *ts)
352 do { 354 do {
353 seq = read_seqbegin(&tk->lock); 355 seq = read_seqbegin(&tk->lock);
354 ts->tv_sec = tk->xtime_sec; 356 ts->tv_sec = tk->xtime_sec;
355 ts->tv_nsec = timekeeping_get_ns(tk); 357 nsec = timekeeping_get_ns(tk);
356 tomono = tk->wall_to_monotonic; 358 tomono = tk->wall_to_monotonic;
357 359
358 } while (read_seqretry(&tk->lock, seq)); 360 } while (read_seqretry(&tk->lock, seq));
359 361
360 set_normalized_timespec(ts, ts->tv_sec + tomono.tv_sec, 362 ts->tv_sec += tomono.tv_sec;
361 ts->tv_nsec + tomono.tv_nsec); 363 ts->tv_nsec = 0;
364 timespec_add_ns(ts, nsec + tomono.tv_nsec);
362} 365}
363EXPORT_SYMBOL_GPL(ktime_get_ts); 366EXPORT_SYMBOL_GPL(ktime_get_ts);
364 367
@@ -1244,6 +1247,7 @@ void get_monotonic_boottime(struct timespec *ts)
1244{ 1247{
1245 struct timekeeper *tk = &timekeeper; 1248 struct timekeeper *tk = &timekeeper;
1246 struct timespec tomono, sleep; 1249 struct timespec tomono, sleep;
1250 s64 nsec;
1247 unsigned int seq; 1251 unsigned int seq;
1248 1252
1249 WARN_ON(timekeeping_suspended); 1253 WARN_ON(timekeeping_suspended);
@@ -1251,14 +1255,15 @@ void get_monotonic_boottime(struct timespec *ts)
1251 do { 1255 do {
1252 seq = read_seqbegin(&tk->lock); 1256 seq = read_seqbegin(&tk->lock);
1253 ts->tv_sec = tk->xtime_sec; 1257 ts->tv_sec = tk->xtime_sec;
1254 ts->tv_nsec = timekeeping_get_ns(tk); 1258 nsec = timekeeping_get_ns(tk);
1255 tomono = tk->wall_to_monotonic; 1259 tomono = tk->wall_to_monotonic;
1256 sleep = tk->total_sleep_time; 1260 sleep = tk->total_sleep_time;
1257 1261
1258 } while (read_seqretry(&tk->lock, seq)); 1262 } while (read_seqretry(&tk->lock, seq));
1259 1263
1260 set_normalized_timespec(ts, ts->tv_sec + tomono.tv_sec + sleep.tv_sec, 1264 ts->tv_sec += tomono.tv_sec + sleep.tv_sec;
1261 ts->tv_nsec + tomono.tv_nsec + sleep.tv_nsec); 1265 ts->tv_nsec = 0;
1266 timespec_add_ns(ts, nsec + tomono.tv_nsec + sleep.tv_nsec);
1262} 1267}
1263EXPORT_SYMBOL_GPL(get_monotonic_boottime); 1268EXPORT_SYMBOL_GPL(get_monotonic_boottime);
1264 1269