clock plugin: increase offset measurement accuracy
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Sun, 12 Oct 2014 11:46:20 +0000 (13:46 +0200)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 7 Apr 2015 15:10:20 +0000 (11:10 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng-sessiond/ust-metadata.c

index b67921ef81b88c2712aea27365a694a8dcc113c0..ea5978888e6fe6705a3590d83ecf324f8e33fd3f 100644 (file)
@@ -38,6 +38,7 @@
 #define max_t(type, a, b)      ((type) ((a) > (b) ? (a) : (b)))
 #endif
 
+#define NSEC_PER_SEC                   1000000000ULL
 #define NR_CLOCK_OFFSET_SAMPLES                10
 
 struct offset_sample {
@@ -543,10 +544,11 @@ int measure_single_clock_offset(struct offset_sample *sample)
                return 0;
        }
        offset = (monotonic[0] + monotonic[1]) >> 1;
-       realtime = (uint64_t) rts.tv_sec * 1000000000ULL;
-       realtime += rts.tv_nsec;
-       if (tcf != 1000000000ULL) {
-               realtime /= 1000000000ULL / tcf;
+       realtime = (uint64_t) rts.tv_sec * tcf;
+       if (tcf == NSEC_PER_SEC) {
+               realtime += rts.tv_nsec;
+       } else {
+               realtime += (uint64_t) rts.tv_nsec * tcf / NSEC_PER_SEC;
        }
        offset = realtime - offset;
        sample->offset = offset;
This page took 0.027598 seconds and 4 git commands to generate.