Colin Cross | 5c83545 | 2013-05-21 22:32:14 -0700 | [diff] [blame] | 1 | #ifndef _TIMEKEEPING_INTERNAL_H |
| 2 | #define _TIMEKEEPING_INTERNAL_H |
| 3 | /* |
| 4 | * timekeeping debug functions |
| 5 | */ |
Thomas Gleixner | 3a97837 | 2014-07-16 21:05:10 +0000 | [diff] [blame] | 6 | #include <linux/clocksource.h> |
Colin Cross | 5c83545 | 2013-05-21 22:32:14 -0700 | [diff] [blame] | 7 | #include <linux/time.h> |
| 8 | |
| 9 | #ifdef CONFIG_DEBUG_FS |
John Stultz | 7d489d1 | 2014-07-16 21:04:01 +0000 | [diff] [blame] | 10 | extern void tk_debug_account_sleep_time(struct timespec64 *t); |
Colin Cross | 5c83545 | 2013-05-21 22:32:14 -0700 | [diff] [blame] | 11 | #else |
| 12 | #define tk_debug_account_sleep_time(x) |
| 13 | #endif |
| 14 | |
Thomas Gleixner | 09ec544 | 2014-07-16 21:05:12 +0000 | [diff] [blame] | 15 | #ifdef CONFIG_CLOCKSOURCE_VALIDATE_LAST_CYCLE |
| 16 | static inline cycle_t clocksource_delta(cycle_t now, cycle_t last, cycle_t mask) |
| 17 | { |
| 18 | cycle_t ret = (now - last) & mask; |
| 19 | |
Yang Yingliang | 1f45f1f | 2015-10-31 18:20:55 +0800 | [diff] [blame] | 20 | /* |
| 21 | * Prevent time going backwards by checking the MSB of mask in |
| 22 | * the result. If set, return 0. |
| 23 | */ |
| 24 | return ret & ~(mask >> 1) ? 0 : ret; |
Thomas Gleixner | 09ec544 | 2014-07-16 21:05:12 +0000 | [diff] [blame] | 25 | } |
| 26 | #else |
Thomas Gleixner | 3a97837 | 2014-07-16 21:05:10 +0000 | [diff] [blame] | 27 | static inline cycle_t clocksource_delta(cycle_t now, cycle_t last, cycle_t mask) |
| 28 | { |
| 29 | return (now - last) & mask; |
| 30 | } |
Thomas Gleixner | 09ec544 | 2014-07-16 21:05:12 +0000 | [diff] [blame] | 31 | #endif |
Thomas Gleixner | 3a97837 | 2014-07-16 21:05:10 +0000 | [diff] [blame] | 32 | |
DengChao | dee3665 | 2015-12-13 12:24:18 +0800 | [diff] [blame] | 33 | extern time64_t __ktime_get_real_seconds(void); |
| 34 | |
Colin Cross | 5c83545 | 2013-05-21 22:32:14 -0700 | [diff] [blame] | 35 | #endif /* _TIMEKEEPING_INTERNAL_H */ |