Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[S390] introduce get_clock_monotonic

Introduce get_clock_monotonic() function which can be used to get a
(fast) timestamp. Resolution is the same as for get_clock(). The
only difference is that the timestamps are monotonic and don't jump
backward or forward.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>

authored by

Heiko Carstens and committed by
Martin Schwidefsky
05e7ff7d ca99dab0

+16 -1
+14
arch/s390/include/asm/timex.h
··· 90 90 91 91 extern u64 sched_clock_base_cc; 92 92 93 + /** 94 + * get_clock_monotonic - returns current time in clock rate units 95 + * 96 + * The caller must ensure that preemption is disabled. 97 + * The clock and sched_clock_base get changed via stop_machine. 98 + * Therefore preemption must be disabled when calling this 99 + * function, otherwise the returned value is not guaranteed to 100 + * be monotonic. 101 + */ 102 + static inline unsigned long long get_clock_monotonic(void) 103 + { 104 + return get_clock_xt() - sched_clock_base_cc; 105 + } 106 + 93 107 #endif
+2 -1
arch/s390/kernel/time.c
··· 60 60 #define TICK_SIZE tick 61 61 62 62 u64 sched_clock_base_cc = -1; /* Force to data section. */ 63 + EXPORT_SYMBOL_GPL(sched_clock_base_cc); 63 64 64 65 static DEFINE_PER_CPU(struct clock_event_device, comparators); 65 66 ··· 69 68 */ 70 69 unsigned long long notrace sched_clock(void) 71 70 { 72 - return ((get_clock_xt() - sched_clock_base_cc) * 125) >> 9; 71 + return (get_clock_monotonic() * 125) >> 9; 73 72 } 74 73 75 74 /*