diff options
author | Cassio Neri <cassio.neri@gmail.com> | 2021-06-22 23:36:16 +0200 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2021-06-24 11:51:59 +0200 |
commit | 276010551664f73b6f1616dde471d6f0d63a73ba (patch) | |
tree | 36bdb68afbbc7088b00c1ea0c9c55e8693b16960 /kernel/time/Kconfig | |
parent | clockevents: Use list_move() instead of list_del()/list_add() (diff) | |
download | linux-276010551664f73b6f1616dde471d6f0d63a73ba.tar.xz linux-276010551664f73b6f1616dde471d6f0d63a73ba.zip |
time: Improve performance of time64_to_tm()
The current implementation of time64_to_tm() contains unnecessary loops,
branches and look-up tables. The new one uses an arithmetic-based algorithm
appeared in [1] and is approximately 3x faster (YMMV).
The drawback is that the new code isn't intuitive and contains many 'magic
numbers' (not unusual for this type of algorithm). However, [1] justifies
all those numbers and, given this function's history, the code is unlikely
to need much maintenance, if any at all.
Add a KUnit test for it which checks every day in a 160,000 years interval
centered at 1970-01-01 against the expected result.
[1] Neri, Schneider, "Euclidean Affine Functions and Applications to
Calendar Algorithms". https://arxiv.org/abs/2102.06959
Signed-off-by: Cassio Neri <cassio.neri@gmail.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20210622213616.313046-1-cassio.neri@gmail.com
Diffstat (limited to 'kernel/time/Kconfig')
-rw-r--r-- | kernel/time/Kconfig | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/kernel/time/Kconfig b/kernel/time/Kconfig index 83e158d016ba..3610b1bef142 100644 --- a/kernel/time/Kconfig +++ b/kernel/time/Kconfig @@ -64,6 +64,15 @@ config LEGACY_TIMER_TICK lack support for the generic clockevent framework. New platforms should use generic clockevents instead. +config TIME_KUNIT_TEST + tristate "KUnit test for kernel/time functions" if !KUNIT_ALL_TESTS + depends on KUNIT + default KUNIT_ALL_TESTS + help + Enable this option to test RTC library functions. + + If unsure, say N. + if GENERIC_CLOCKEVENTS menu "Timers subsystem" |