Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

timekeeping: Consolidate timekeeping helpers

Consolidate timekeeping helpers, making use of timekeeping_cycles_to_ns()
in preference to directly using timekeeping_delta_to_ns().

No functional change.

Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20240325064023.2997-15-adrian.hunter@intel.com

authored by

Adrian Hunter and committed by
Thomas Gleixner
e84f43e3 e8e9d21a

+8 -6
+8 -6
kernel/time/timekeeping.c
··· 237 237 } 238 238 } 239 239 240 - static inline u64 timekeeping_debug_get_delta(const struct tk_read_base *tkr) 240 + static inline u64 timekeeping_cycles_to_ns(const struct tk_read_base *tkr, u64 cycles); 241 + 242 + static inline u64 timekeeping_debug_get_ns(const struct tk_read_base *tkr) 241 243 { 242 244 struct timekeeper *tk = &tk_core.timekeeper; 243 245 u64 now, last, mask, max, delta; ··· 268 266 */ 269 267 if (unlikely((~delta & mask) < (mask >> 3))) { 270 268 tk->underflow_seen = 1; 271 - delta = 0; 269 + now = last; 272 270 } 273 271 274 272 /* Cap delta value to the max_cycles values to avoid mult overflows */ 275 273 if (unlikely(delta > max)) { 276 274 tk->overflow_seen = 1; 277 - delta = tkr->clock->max_cycles; 275 + now = last + max; 278 276 } 279 277 280 - return delta; 278 + return timekeeping_cycles_to_ns(tkr, now); 281 279 } 282 280 #else 283 281 static inline void timekeeping_check_update(struct timekeeper *tk, u64 offset) 284 282 { 285 283 } 286 - static inline u64 timekeeping_debug_get_delta(const struct tk_read_base *tkr) 284 + static inline u64 timekeeping_debug_get_ns(const struct tk_read_base *tkr) 287 285 { 288 286 BUG(); 289 287 } ··· 391 389 static inline u64 timekeeping_get_ns(const struct tk_read_base *tkr) 392 390 { 393 391 if (IS_ENABLED(CONFIG_DEBUG_TIMEKEEPING)) 394 - return timekeeping_delta_to_ns(tkr, timekeeping_debug_get_delta(tkr)); 392 + return timekeeping_debug_get_ns(tkr); 395 393 396 394 return __timekeeping_get_ns(tkr); 397 395 }