Skip to content

Commit e84f43e

Browse files
ahunter6KAGA-KOKO
authored andcommitted
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 <[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 e8e9d21 commit e84f43e

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

kernel/time/timekeeping.c

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

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)
241243
{
242244
struct timekeeper *tk = &tk_core.timekeeper;
243245
u64 now, last, mask, max, delta;
@@ -266,22 +268,22 @@ static inline u64 timekeeping_debug_get_delta(const struct tk_read_base *tkr)
266268
*/
267269
if (unlikely((~delta & mask) < (mask >> 3))) {
268270
tk->underflow_seen = 1;
269-
delta = 0;
271+
now = last;
270272
}
271273

272274
/* Cap delta value to the max_cycles values to avoid mult overflows */
273275
if (unlikely(delta > max)) {
274276
tk->overflow_seen = 1;
275-
delta = tkr->clock->max_cycles;
277+
now = last + max;
276278
}
277279

278-
return delta;
280+
return timekeeping_cycles_to_ns(tkr, now);
279281
}
280282
#else
281283
static inline void timekeeping_check_update(struct timekeeper *tk, u64 offset)
282284
{
283285
}
284-
static inline u64 timekeeping_debug_get_delta(const struct tk_read_base *tkr)
286+
static inline u64 timekeeping_debug_get_ns(const struct tk_read_base *tkr)
285287
{
286288
BUG();
287289
}
@@ -389,7 +391,7 @@ static __always_inline u64 __timekeeping_get_ns(const struct tk_read_base *tkr)
389391
static inline u64 timekeeping_get_ns(const struct tk_read_base *tkr)
390392
{
391393
if (IS_ENABLED(CONFIG_DEBUG_TIMEKEEPING))
392-
return timekeeping_delta_to_ns(tkr, timekeeping_debug_get_delta(tkr));
394+
return timekeeping_debug_get_ns(tkr);
393395

394396
return __timekeeping_get_ns(tkr);
395397
}

0 commit comments

Comments
 (0)