]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
ktime: Optimize ktime_divns for constant divisors
authorNicolas Pitre <nicolas.pitre@linaro.org>
Wed, 3 Dec 2014 19:43:06 +0000 (14:43 -0500)
committerSasha Levin <sasha.levin@oracle.com>
Tue, 9 Jun 2015 17:43:49 +0000 (13:43 -0400)
commit55fe6e07b589b0d11bced3ac1d74829b416e7fc6
tree008d8f1648f2260d6faa50df0952dec7820cbbc4
parent08a468bf87293f0d18f7ce8ad66a42f4371395f7
ktime: Optimize ktime_divns for constant divisors

[ Upstream commit 8b618628b2bf83512fc8df5e8672619d65adfdfb ]

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>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
include/linux/ktime.h
kernel/time/hrtimer.c