clock offset: print negative value in metadata
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 8 Feb 2016 21:52:05 +0000 (16:52 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 8 Feb 2016 21:52:05 +0000 (16:52 -0500)
In the upcoming 2.8, we can print the negative value of clock offset in
the metadata, and expect users to update their viewers to correct any
bug that could prevent them from handling those negative values.

This happens only in cases where the system sets CLOCK_REALTIME to 0
after boot, thus leading to a negative clock offset value between
realtime and monotonic clocks.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
lttng-events.c

index bd6f44d977dba95e36c769f828b60e4fb9502c1f..e1364dd5fbd9b6692bf5055f3be07048b1c951b7 100644 (file)
@@ -2027,7 +2027,7 @@ int _lttng_event_header_declare(struct lttng_session *session)
  * the REALTIME clock to 0 after boot.
  */
 static
-uint64_t measure_clock_offset(void)
+int64_t measure_clock_offset(void)
 {
        uint64_t monotonic_avg, monotonic[2], realtime;
        uint64_t tcf = trace_clock_freq();
@@ -2053,8 +2053,6 @@ uint64_t measure_clock_offset(void)
                realtime += n;
        }
        offset = (int64_t) realtime - monotonic_avg;
-       if (offset < 0)
-               return 0;
        return offset;
 }
 
@@ -2166,11 +2164,11 @@ int _lttng_session_metadata_statedump(struct lttng_session *session)
                "       description = \"%s\";\n"
                "       freq = %llu; /* Frequency, in Hz */\n"
                "       /* clock value offset from Epoch is: offset * (1/freq) */\n"
-               "       offset = %llu;\n"
+               "       offset = %lld;\n"
                "};\n\n",
                trace_clock_description(),
                (unsigned long long) trace_clock_freq(),
-               (unsigned long long) measure_clock_offset()
+               (long long) measure_clock_offset()
                );
        if (ret)
                goto end;
This page took 0.028286 seconds and 4 git commands to generate.