]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
timekeeping: Allow inlining clocksource::read()
authorThomas Gleixner <tglx@kernel.org>
Tue, 24 Feb 2026 16:36:20 +0000 (17:36 +0100)
committerPeter Zijlstra <peterz@infradead.org>
Fri, 27 Feb 2026 15:40:07 +0000 (16:40 +0100)
commit2e27beeb66e43f3b84aef5a07e486a5d50695c06
tree73f132f851c9fc1be9d48feb56f7d1fa2a6ff453
parent70802807398c65f5a49b2baec87e1f6c8db43de6
timekeeping: Allow inlining clocksource::read()

On some architectures clocksource::read() boils down to a single
instruction, so the indirect function call is just a massive overhead
especially with speculative execution mitigations in effect.

Allow architectures to enable conditional inlining of that read to avoid
that by:

   - providing a static branch to switch to the inlined variant

   - disabling the branch before clocksource changes

   - enabling the branch after a clocksource change, when the clocksource
     indicates in a feature flag that it is the one which provides the
     inlined variant

This is intentionally not a static call as that would only remove the
indirect call, but not the rest of the overhead.

Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://patch.msgid.link/20260224163429.675151545@kernel.org
include/linux/clocksource.h
kernel/time/Kconfig
kernel/time/timekeeping.c