diff options
author | John Stultz <john.stultz@linaro.org> | 2014-07-16 17:03:53 -0400 |
---|---|---|
committer | John Stultz <john.stultz@linaro.org> | 2014-07-23 13:16:50 -0400 |
commit | 24e4a8c3e8868874835b0f1ad6dd417341e99822 (patch) | |
tree | d71c666cc53db7e0d906e838f23ff67855b86b6b /kernel | |
parent | 76f4108892d9a9e3408bba839914f97a54086a6f (diff) |
ktime: Kill non-scalar ktime_t implementation for 2038
The non-scalar ktime_t implementation is basically a timespec
which has to be changed to support dates past 2038 on 32bit
systems.
This patch removes the non-scalar ktime_t implementation, forcing
the scalar s64 nanosecond version on all architectures.
This may have additional performance overhead on some 32bit
systems when converting between ktime_t and timespec structures,
however the majority of 32bit systems (arm and i386) were already
using scalar ktime_t, so no performance regressions will be seen
on those platforms.
On affected platforms, I'm open to finding optimizations, including
avoiding converting to timespecs where possible.
[ tglx: We can now cleanup the ktime_t.tv64 mess, but thats a
different issue and we can throw a coccinelle script at it ]
Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/time/Kconfig | 4 | ||||
-rw-r--r-- | kernel/time/hrtimer.c | 54 | ||||
-rw-r--r-- | kernel/time/timekeeping.c | 7 |
3 files changed, 2 insertions, 63 deletions
diff --git a/kernel/time/Kconfig b/kernel/time/Kconfig index f448513a45ed..feccfd888732 100644 --- a/kernel/time/Kconfig +++ b/kernel/time/Kconfig | |||
@@ -20,10 +20,6 @@ config GENERIC_TIME_VSYSCALL | |||
20 | config GENERIC_TIME_VSYSCALL_OLD | 20 | config GENERIC_TIME_VSYSCALL_OLD |
21 | bool | 21 | bool |
22 | 22 | ||
23 | # ktime_t scalar 64bit nsec representation | ||
24 | config KTIME_SCALAR | ||
25 | bool | ||
26 | |||
27 | # Old style timekeeping | 23 | # Old style timekeeping |
28 | config ARCH_USES_GETTIMEOFFSET | 24 | config ARCH_USES_GETTIMEOFFSET |
29 | bool | 25 | bool |
diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c index 2f4ef8a1e5ff..19f211051c35 100644 --- a/kernel/time/hrtimer.c +++ b/kernel/time/hrtimer.c | |||
@@ -261,60 +261,6 @@ lock_hrtimer_base(const struct hrtimer *timer, unsigned long *flags) | |||
261 | * too large for inlining: | 261 | * too large for inlining: |
262 | */ | 262 | */ |
263 | #if BITS_PER_LONG < 64 | 263 | #if BITS_PER_LONG < 64 |
264 | # ifndef CONFIG_KTIME_SCALAR | ||
265 | /** | ||
266 | * ktime_add_ns - Add a scalar nanoseconds value to a ktime_t variable | ||
267 | * @kt: addend | ||
268 | * @nsec: the scalar nsec value to add | ||
269 | * | ||
270 | * Returns the sum of kt and nsec in ktime_t format | ||
271 | */ | ||
272 | ktime_t ktime_add_ns(const ktime_t kt, u64 nsec) | ||
273 | { | ||
274 | ktime_t tmp; | ||
275 | |||
276 | if (likely(nsec < NSEC_PER_SEC)) { | ||
277 | tmp.tv64 = nsec; | ||
278 | } else { | ||
279 | unsigned long rem = do_div(nsec, NSEC_PER_SEC); | ||
280 | |||
281 | /* Make sure nsec fits into long */ | ||
282 | if (unlikely(nsec > KTIME_SEC_MAX)) | ||
283 | return (ktime_t){ .tv64 = KTIME_MAX }; | ||
284 | |||
285 | tmp = ktime_set((long)nsec, rem); | ||
286 | } | ||
287 | |||
288 | return ktime_add(kt, tmp); | ||
289 | } | ||
290 | |||
291 | EXPORT_SYMBOL_GPL(ktime_add_ns); | ||
292 | |||
293 | /** | ||
294 | * ktime_sub_ns - Subtract a scalar nanoseconds value from a ktime_t variable | ||
295 | * @kt: minuend | ||
296 | * @nsec: the scalar nsec value to subtract | ||
297 | * | ||
298 | * Returns the subtraction of @nsec from @kt in ktime_t format | ||
299 | */ | ||
300 | ktime_t ktime_sub_ns(const ktime_t kt, u64 nsec) | ||
301 | { | ||
302 | ktime_t tmp; | ||
303 | |||
304 | if (likely(nsec < NSEC_PER_SEC)) { | ||
305 | tmp.tv64 = nsec; | ||
306 | } else { | ||
307 | unsigned long rem = do_div(nsec, NSEC_PER_SEC); | ||
308 | |||
309 | tmp = ktime_set((long)nsec, rem); | ||
310 | } | ||
311 | |||
312 | return ktime_sub(kt, tmp); | ||
313 | } | ||
314 | |||
315 | EXPORT_SYMBOL_GPL(ktime_sub_ns); | ||
316 | # endif /* !CONFIG_KTIME_SCALAR */ | ||
317 | |||
318 | /* | 264 | /* |
319 | * Divide a ktime value by a nanosecond value | 265 | * Divide a ktime value by a nanosecond value |
320 | */ | 266 | */ |
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index b94fa3652aaa..cafef242d8f9 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c | |||
@@ -344,11 +344,8 @@ ktime_t ktime_get(void) | |||
344 | nsecs = timekeeping_get_ns(tk) + tk->wall_to_monotonic.tv_nsec; | 344 | nsecs = timekeeping_get_ns(tk) + tk->wall_to_monotonic.tv_nsec; |
345 | 345 | ||
346 | } while (read_seqcount_retry(&timekeeper_seq, seq)); | 346 | } while (read_seqcount_retry(&timekeeper_seq, seq)); |
347 | /* | 347 | |
348 | * Use ktime_set/ktime_add_ns to create a proper ktime on | 348 | return ktime_set(secs, nsecs); |
349 | * 32-bit architectures without CONFIG_KTIME_SCALAR. | ||
350 | */ | ||
351 | return ktime_add_ns(ktime_set(secs, 0), nsecs); | ||
352 | } | 349 | } |
353 | EXPORT_SYMBOL_GPL(ktime_get); | 350 | EXPORT_SYMBOL_GPL(ktime_get); |
354 | 351 | ||