projects
/
lttng-modules.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix: handle negative clock offset
[lttng-modules.git]
/
lttng-events.c
diff --git
a/lttng-events.c
b/lttng-events.c
index d0ebb2987518fd61b68cd6455602c3a39c8135c6..aac9c5899355df496ec5a31f9635b43918220726 100644
(file)
--- a/
lttng-events.c
+++ b/
lttng-events.c
@@
-1960,11
+1960,14
@@
int _lttng_event_header_declare(struct lttng_session *session)
* taken at start of trace.
* Yes, this is only an approximation. Yes, we can (and will) do better
* in future versions.
* taken at start of trace.
* Yes, this is only an approximation. Yes, we can (and will) do better
* in future versions.
+ * Return 0 if offset is negative. It may happen if the system sets
+ * the REALTIME clock to 0 after boot.
*/
static
uint64_t measure_clock_offset(void)
{
*/
static
uint64_t measure_clock_offset(void)
{
- uint64_t offset, monotonic[2], realtime;
+ uint64_t monotonic_avg, monotonic[2], realtime;
+ int64_t offset;
struct timespec rts = { 0, 0 };
unsigned long flags;
struct timespec rts = { 0, 0 };
unsigned long flags;
@@
-1975,10
+1978,12
@@
uint64_t measure_clock_offset(void)
monotonic[1] = trace_clock_read64();
local_irq_restore(flags);
monotonic[1] = trace_clock_read64();
local_irq_restore(flags);
-
offset
= (monotonic[0] + monotonic[1]) >> 1;
+
monotonic_avg
= (monotonic[0] + monotonic[1]) >> 1;
realtime = (uint64_t) rts.tv_sec * NSEC_PER_SEC;
realtime += rts.tv_nsec;
realtime = (uint64_t) rts.tv_sec * NSEC_PER_SEC;
realtime += rts.tv_nsec;
- offset = realtime - offset;
+ offset = (int64_t) realtime - monotonic_avg;
+ if (offset < 0)
+ return 0;
return offset;
}
return offset;
}
This page took
0.024609 seconds
and
4
git commands to generate.