diff options
author | Nicolas Pitre <nicolas.pitre@linaro.org> | 2014-12-03 14:43:06 -0500 |
---|---|---|
committer | John Stultz <john.stultz@linaro.org> | 2015-01-23 20:21:31 -0500 |
commit | 8b618628b2bf83512fc8df5e8672619d65adfdfb (patch) | |
tree | c295bed4f4e702f5f39fcce622258e55242b1d93 /kernel | |
parent | eaa27f34e91a14cdceed26ed6c6793ec1d186115 (diff) |
ktime: Optimize ktime_divns for constant divisors
At least on ARM, do_div() is optimized to turn constant divisors into
an inline multiplication by the reciprocal value at compile time.
However this optimization is missed entirely whenever ktime_divns() is
used and the slow out-of-line division code is used all the time.
Let ktime_divns() use do_div() inline whenever the divisor is constant
and small enough. This will make things like ktime_to_us() and
ktime_to_ms() much faster.
Cc: Arnd Bergmann <arnd.bergmann@linaro.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Nicolas Pitre <nico@linaro.org>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Nicolas Pitre <nico@linaro.org>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/time/hrtimer.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c index 37e50aadd471..890535c41c2d 100644 --- a/kernel/time/hrtimer.c +++ b/kernel/time/hrtimer.c | |||
@@ -266,7 +266,7 @@ lock_hrtimer_base(const struct hrtimer *timer, unsigned long *flags) | |||
266 | /* | 266 | /* |
267 | * Divide a ktime value by a nanosecond value | 267 | * Divide a ktime value by a nanosecond value |
268 | */ | 268 | */ |
269 | u64 ktime_divns(const ktime_t kt, s64 div) | 269 | u64 __ktime_divns(const ktime_t kt, s64 div) |
270 | { | 270 | { |
271 | u64 dclc; | 271 | u64 dclc; |
272 | int sft = 0; | 272 | int sft = 0; |
@@ -282,7 +282,7 @@ u64 ktime_divns(const ktime_t kt, s64 div) | |||
282 | 282 | ||
283 | return dclc; | 283 | return dclc; |
284 | } | 284 | } |
285 | EXPORT_SYMBOL_GPL(ktime_divns); | 285 | EXPORT_SYMBOL_GPL(__ktime_divns); |
286 | #endif /* BITS_PER_LONG >= 64 */ | 286 | #endif /* BITS_PER_LONG >= 64 */ |
287 | 287 | ||
288 | /* | 288 | /* |