Commit 05e7ff7d authored by Heiko Carstens's avatar Heiko Carstens Committed by Martin Schwidefsky

[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: default avatarHeiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
parent ca99dab0
...@@ -90,4 +90,18 @@ unsigned long long monotonic_clock(void); ...@@ -90,4 +90,18 @@ unsigned long long monotonic_clock(void);
extern u64 sched_clock_base_cc; extern u64 sched_clock_base_cc;
/**
* get_clock_monotonic - returns current time in clock rate units
*
* The caller must ensure that preemption is disabled.
* The clock and sched_clock_base get changed via stop_machine.
* Therefore preemption must be disabled when calling this
* function, otherwise the returned value is not guaranteed to
* be monotonic.
*/
static inline unsigned long long get_clock_monotonic(void)
{
return get_clock_xt() - sched_clock_base_cc;
}
#endif #endif
...@@ -60,6 +60,7 @@ ...@@ -60,6 +60,7 @@
#define TICK_SIZE tick #define TICK_SIZE tick
u64 sched_clock_base_cc = -1; /* Force to data section. */ u64 sched_clock_base_cc = -1; /* Force to data section. */
EXPORT_SYMBOL_GPL(sched_clock_base_cc);
static DEFINE_PER_CPU(struct clock_event_device, comparators); static DEFINE_PER_CPU(struct clock_event_device, comparators);
...@@ -68,7 +69,7 @@ static DEFINE_PER_CPU(struct clock_event_device, comparators); ...@@ -68,7 +69,7 @@ static DEFINE_PER_CPU(struct clock_event_device, comparators);
*/ */
unsigned long long notrace sched_clock(void) unsigned long long notrace sched_clock(void)
{ {
return ((get_clock_xt() - sched_clock_base_cc) * 125) >> 9; return (get_clock_monotonic() * 125) >> 9;
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment