From: Thomas Gleixner Date: Wed, 9 Oct 2024 08:28:54 +0000 (+0200) Subject: timekeeping: Read NTP tick length only once X-Git-Tag: v6.13-rc1~171^2~89 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=14f1e3b3dfc7fc8b61fcb79f956f05625af6f049;p=linux-block.git timekeeping: Read NTP tick length only once No point in reading it a second time when the comparison fails. Signed-off-by: Thomas Gleixner Signed-off-by: Anna-Maria Behnsen Signed-off-by: Thomas Gleixner Acked-by: John Stultz Link: https://lore.kernel.org/all/20241009-devel-anna-maria-b4-timers-ptp-timekeeping-v2-1-554456a44a15@linutronix.de --- diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 1427c58e9802..2bc3542f29a2 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -2161,16 +2161,17 @@ static __always_inline void timekeeping_apply_adjustment(struct timekeeper *tk, */ static void timekeeping_adjust(struct timekeeper *tk, s64 offset) { + u64 ntp_tl = ntp_tick_length(); u32 mult; /* * Determine the multiplier from the current NTP tick length. * Avoid expensive division when the tick length doesn't change. */ - if (likely(tk->ntp_tick == ntp_tick_length())) { + if (likely(tk->ntp_tick == ntp_tl)) { mult = tk->tkr_mono.mult - tk->ntp_err_mult; } else { - tk->ntp_tick = ntp_tick_length(); + tk->ntp_tick = ntp_tl; mult = div64_u64((tk->ntp_tick >> tk->ntp_error_shift) - tk->xtime_remainder, tk->cycle_interval); }