Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge branch 'timers-urgent-for-linus' of git://git.kernel.org/pub/sc…

…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...
commit 519b3b742d7d29c3386f0f35f3cee5dd362dd8e2 2 parents 18f5600 + ec145ba
Linus Torvalds authored September 21, 2012

Showing 1 changed file with 12 additions and 7 deletions. Show diff stats Hide diff stats

  1. 19  kernel/time/timekeeping.c
19  kernel/time/timekeeping.c
@@ -303,10 +303,11 @@ void getnstimeofday(struct timespec *ts)
303 303
 		seq = read_seqbegin(&tk->lock);
304 304
 
305 305
 		ts->tv_sec = tk->xtime_sec;
306  
-		ts->tv_nsec = timekeeping_get_ns(tk);
  306
+		nsecs = timekeeping_get_ns(tk);
307 307
 
308 308
 	} while (read_seqretry(&tk->lock, seq));
309 309
 
  310
+	ts->tv_nsec = 0;
310 311
 	timespec_add_ns(ts, nsecs);
311 312
 }
312 313
 EXPORT_SYMBOL(getnstimeofday);
@@ -345,6 +346,7 @@ void ktime_get_ts(struct timespec *ts)
345 346
 {
346 347
 	struct timekeeper *tk = &timekeeper;
347 348
 	struct timespec tomono;
  349
+	s64 nsec;
348 350
 	unsigned int seq;
349 351
 
350 352
 	WARN_ON(timekeeping_suspended);
@@ -352,13 +354,14 @@ void ktime_get_ts(struct timespec *ts)
352 354
 	do {
353 355
 		seq = read_seqbegin(&tk->lock);
354 356
 		ts->tv_sec = tk->xtime_sec;
355  
-		ts->tv_nsec = timekeeping_get_ns(tk);
  357
+		nsec = timekeeping_get_ns(tk);
356 358
 		tomono = tk->wall_to_monotonic;
357 359
 
358 360
 	} while (read_seqretry(&tk->lock, seq));
359 361
 
360  
-	set_normalized_timespec(ts, ts->tv_sec + tomono.tv_sec,
361  
-				ts->tv_nsec + tomono.tv_nsec);
  362
+	ts->tv_sec += tomono.tv_sec;
  363
+	ts->tv_nsec = 0;
  364
+	timespec_add_ns(ts, nsec + tomono.tv_nsec);
362 365
 }
363 366
 EXPORT_SYMBOL_GPL(ktime_get_ts);
364 367
 
@@ -1244,6 +1247,7 @@ void get_monotonic_boottime(struct timespec *ts)
1244 1247
 {
1245 1248
 	struct timekeeper *tk = &timekeeper;
1246 1249
 	struct timespec tomono, sleep;
  1250
+	s64 nsec;
1247 1251
 	unsigned int seq;
1248 1252
 
1249 1253
 	WARN_ON(timekeeping_suspended);
@@ -1251,14 +1255,15 @@ void get_monotonic_boottime(struct timespec *ts)
1251 1255
 	do {
1252 1256
 		seq = read_seqbegin(&tk->lock);
1253 1257
 		ts->tv_sec = tk->xtime_sec;
1254  
-		ts->tv_nsec = timekeeping_get_ns(tk);
  1258
+		nsec = timekeeping_get_ns(tk);
1255 1259
 		tomono = tk->wall_to_monotonic;
1256 1260
 		sleep = tk->total_sleep_time;
1257 1261
 
1258 1262
 	} while (read_seqretry(&tk->lock, seq));
1259 1263
 
1260  
-	set_normalized_timespec(ts, ts->tv_sec + tomono.tv_sec + sleep.tv_sec,
1261  
-			ts->tv_nsec + tomono.tv_nsec + sleep.tv_nsec);
  1264
+	ts->tv_sec += tomono.tv_sec + sleep.tv_sec;
  1265
+	ts->tv_nsec = 0;
  1266
+	timespec_add_ns(ts, nsec + tomono.tv_nsec + sleep.tv_nsec);
1262 1267
 }
1263 1268
 EXPORT_SYMBOL_GPL(get_monotonic_boottime);
1264 1269
 

0 notes on commit 519b3b7

Please sign in to comment.
Something went wrong with that request. Please try again.