Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / kernel / time / timekeeping_internal.h
blob63e600e943a767cd60aa306966687be44c335b1e
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _TIMEKEEPING_INTERNAL_H
3 #define _TIMEKEEPING_INTERNAL_H
5 #include <linux/clocksource.h>
6 #include <linux/spinlock.h>
7 #include <linux/time.h>
9 /*
10 * timekeeping debug functions
12 #ifdef CONFIG_DEBUG_FS
14 DECLARE_PER_CPU(unsigned long, timekeeping_mg_floor_swaps);
16 static inline void timekeeping_inc_mg_floor_swaps(void)
18 this_cpu_inc(timekeeping_mg_floor_swaps);
21 extern void tk_debug_account_sleep_time(const struct timespec64 *t);
23 #else
25 #define tk_debug_account_sleep_time(x)
27 static inline void timekeeping_inc_mg_floor_swaps(void)
31 #endif
33 static inline u64 clocksource_delta(u64 now, u64 last, u64 mask)
35 u64 ret = (now - last) & mask;
38 * Prevent time going backwards by checking the MSB of mask in
39 * the result. If set, return 0.
41 return ret & ~(mask >> 1) ? 0 : ret;
44 /* Semi public for serialization of non timekeeper VDSO updates. */
45 unsigned long timekeeper_lock_irqsave(void);
46 void timekeeper_unlock_irqrestore(unsigned long flags);
48 #endif /* _TIMEKEEPING_INTERNAL_H */