Skip to content

Commit e8e9d21

Browse files
ahunter6KAGA-KOKO
authored andcommitted
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 <[email protected]> Signed-off-by: Adrian Hunter <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 670be12 commit e8e9d21

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

kernel/time/timekeeping.c

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ static void timekeeping_check_update(struct timekeeper *tk, u64 offset)
237237
}
238238
}
239239

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)
241241
{
242242
struct timekeeper *tk = &tk_core.timekeeper;
243243
u64 now, last, mask, max, delta;
@@ -281,17 +281,9 @@ static inline u64 timekeeping_get_delta(const struct tk_read_base *tkr)
281281
static inline void timekeeping_check_update(struct timekeeper *tk, u64 offset)
282282
{
283283
}
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)
285285
{
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();
295287
}
296288
#endif
297289

@@ -396,10 +388,10 @@ static __always_inline u64 __timekeeping_get_ns(const struct tk_read_base *tkr)
396388

397389
static inline u64 timekeeping_get_ns(const struct tk_read_base *tkr)
398390
{
399-
u64 delta;
391+
if (IS_ENABLED(CONFIG_DEBUG_TIMEKEEPING))
392+
return timekeeping_delta_to_ns(tkr, timekeeping_debug_get_delta(tkr));
400393

401-
delta = timekeeping_get_delta(tkr);
402-
return timekeeping_delta_to_ns(tkr, delta);
394+
return __timekeeping_get_ns(tkr);
403395
}
404396

405397
/**

0 commit comments

Comments
 (0)