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: Refactor timekeeping helpers

Simplify the usage of timekeeping sanity checking, in preparation for
consolidating timekeeping helpers. This works towards eliminating
timekeeping_delta_to_ns() in favour of timekeeping_cycles_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-14-adrian.hunter@intel.com

authored by

Adrian Hunter and committed by
Thomas Gleixner
e8e9d21a 670be12b

+6 -14
+6 -14
kernel/time/timekeeping.c
··· 237 237 } 238 238 } 239 239 240 - static inline u64 timekeeping_get_delta(const struct tk_read_base *tkr) 240 + static inline u64 timekeeping_debug_get_delta(const struct tk_read_base *tkr) 241 241 { 242 242 struct timekeeper *tk = &tk_core.timekeeper; 243 243 u64 now, last, mask, max, delta; ··· 281 281 static inline void timekeeping_check_update(struct timekeeper *tk, u64 offset) 282 282 { 283 283 } 284 - static inline u64 timekeeping_get_delta(const struct tk_read_base *tkr) 284 + static inline u64 timekeeping_debug_get_delta(const struct tk_read_base *tkr) 285 285 { 286 - u64 cycle_now, delta; 287 - 288 - /* read clocksource */ 289 - cycle_now = tk_clock_read(tkr); 290 - 291 - /* calculate the delta since the last update_wall_time */ 292 - delta = clocksource_delta(cycle_now, tkr->cycle_last, tkr->mask); 293 - 294 - return delta; 286 + BUG(); 295 287 } 296 288 #endif 297 289 ··· 388 396 389 397 static inline u64 timekeeping_get_ns(const struct tk_read_base *tkr) 390 398 { 391 - u64 delta; 399 + if (IS_ENABLED(CONFIG_DEBUG_TIMEKEEPING)) 400 + return timekeeping_delta_to_ns(tkr, timekeeping_debug_get_delta(tkr)); 392 401 393 - delta = timekeeping_get_delta(tkr); 394 - return timekeeping_delta_to_ns(tkr, delta); 402 + return __timekeeping_get_ns(tkr); 395 403 } 396 404 397 405 /**