<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On 22 May 2018 at 11:16, Vlad <span dir="ltr"><<a href="mailto:vlad@demoninsight.com" target="_blank">vlad@demoninsight.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="overflow-wrap: break-word;"><div><div>Greetings,</div><div><br></div><div><span class="gmail-m_2645552137873417523Apple-tab-span" style="white-space:pre-wrap"> </span>I have what I hope is a related question:</div><div><br></div><div>- my use case is:</div><div><span class="gmail-m_2645552137873417523Apple-tab-span" style="white-space:pre-wrap"> </span>- I use LTTng for userspace events only (at this time);</div><div><span class="gmail-m_2645552137873417523Apple-tab-span" style="white-space:pre-wrap"> </span>- I have the system clock (CLOCK_REALTIME) driven by a PTP driver that comes with a NIC (SolarFlare) that slaves the system to an externally provided high-grade PTP master;</div><div><span class="gmail-m_2645552137873417523Apple-tab-span" style="white-space:pre-wrap"> </span>- the NIC stamps all arriving IP packets at the hardware level and the driver then makes the timestamps available in userspace along with each packet;</div><div><span class="gmail-m_2645552137873417523Apple-tab-span" style="white-space:pre-wrap"> </span>- I would like to be able to correlate these timestamps with LTTng timestamps on the same system.</div></div><div><br></div><div>- is there a way to configure LTTng to use a user-specified CLOCK_* type? I understand that that would de-cohere the timestamps from other interesting timestamps (kernel events, etc) but my case above is valuable enough that I’d be willing to forgo everything else.</div></div></blockquote><div><br></div><div>Hi Vlad,</div><div><br></div><div>lttng-ust's clock plug-in interface seems like a good fit for what you want.</div><div><br></div><div>Have a look at the example in lttng-ust's source tree:<br></div><div><a href="https://github.com/lttng/lttng-ust/tree/master/doc/examples/clock-override">https://github.com/lttng/lttng-ust/tree/master/doc/examples/clock-override</a></div><div><br></div><div>Thanks!</div><div>Jérémie<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="overflow-wrap: break-word;"><div><br></div><div>Thank you in advance,</div><div>Vlad</div><br><div><div>On Apr 20, 2018, at 4:53 PM, Mohamad Gebai <<a href="mailto:mgebai@suse.de" target="_blank">mgebai@suse.de</a>> wrote:</div><br class="gmail-m_2645552137873417523Apple-interchange-newline"><blockquote type="cite">
<div bgcolor="#FFFFFF">
LTTng uses the monotonic clock [1] to timestamp the event at
trace-time. The monotonic clock is more appropriate than the real
time (CLOCK_REALTIME) when you want to timestamp/compare/order
certain events within the same system relatively to each other.
Using the real time clock would cause a problem if say someone (or
something, like ntp, or kvm in a VM) changed the system's time while
tracing.<br>
<br>
With that being said, the monotonic clock doesn't give you a time
that is very meaningful as a human (its reference is the system
boot). Having the timestamps as an actual date and time would be
more interesting. LTTng stores the real time at the beginning of the
trace and stores it in the metadata, which is later used to convert
the timestamps from monotonic time to real time. If you change the
system's real time while tracing, it won't have any effect on the
timestamps of the recorded events.<br>
<br>
Mohamad<br>
<br>
[1] <a class="gmail-m_2645552137873417523moz-txt-link-freetext" href="https://linux.die.net/man/3/clock_gettime" target="_blank">https://linux.die.net/man/3/<wbr>clock_gettime</a><br>
[2]
<a class="gmail-m_2645552137873417523moz-txt-link-freetext" href="http://linuxmogeb.blogspot.ca/2013/10/how-does-clockgettime-work.html" target="_blank">http://linuxmogeb.blogspot.ca/<wbr>2013/10/how-does-clockgettime-<wbr>work.html</a><br>
<br>
<br>
<div class="gmail-m_2645552137873417523moz-cite-prefix">On 04/20/2018 11:37 AM, Jérémie
Galarneau wrote:<br>
</div>
<blockquote type="cite">
<div dir="ltr">
<div>
<div>
<div>
<div>
<div>
<div>Hi,<br>
<br>
</div>
<div>I'm adding the LTTng mailing list in CC for the
benefit of the community and so people add to or
correct my explanation.<br>
</div>
<div><br>
The CTF specification describes the meaning of those
fields:<br>
<a href="http://diamon.org/ctf/#spec8" target="_blank">http://diamon.org/ctf/#spec8</a><br>
<br>
</div>
In your case, this means that the timestamps in the
trace are expressed relative to an arbitrary time set
1524226572435601778 clock ticks after 00:00:00 on 1
January 1970.<br>
<br>
</div>
To take your specific example:<br>
</div>
Your clock is running at 1,000,000,000 Hz, meaning the
duration of a clock tick (period) is of 1 ns.<br>
<br>
</div>
The event has occurred at<br>
</div>
1524226572435601778 (offset) + 00000003827855360941 (event
clock value) nanoseconds after UNIX Epoch. That leads us to
around Friday, April 20, 2018 1:20:00 PM (GMT).<br>
<br>
</div>
<div>Regards,<br>
</div>
Jérémie<br>
<div><br>
<div>
<div>
<div>
<div><br>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On 20 April 2018 at 11:06, Sai Tujala <span dir="ltr"><<a href="mailto:Sai.Tujala@mathworks.in" target="_blank">Sai.Tujala@mathworks.in</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div lang="EN-US">
<div class="gmail-m_2645552137873417523m_-293747052095318529WordSection1"><p class="MsoNormal">Hi Jeremie,</p><div> <br class="gmail-m_2645552137873417523webkit-block-placeholder"></div><p class="MsoNormal"> In metadata file of
LTTng trace session, offset from Epoch is
“1524226572435601778” and time stamp of an event in
channel data files is starting from
“00000003827855360941”. Can you brief about relevance
between these two time stamps. </p><div> <br class="gmail-m_2645552137873417523webkit-block-placeholder"></div><p class="MsoNormal" style="text-indent:0.5in">freq =
1000000000; /* Frequency, in Hz */</p><p class="MsoNormal"> /* clock value offset from
Epoch is: offset * (1/freq) */</p><p class="MsoNormal"> offset =
1524226572435601778;</p><div> <br class="gmail-m_2645552137873417523webkit-block-placeholder"></div><div> <br class="gmail-m_2645552137873417523webkit-block-placeholder"></div><p class="MsoNormal">Thanks & Regards,</p><p class="MsoNormal">T Sai Kiran</p><div> <br class="gmail-m_2645552137873417523webkit-block-placeholder"></div>
</div>
</div>
</blockquote>
</div>
<br>
<br clear="all">
<br>
-- <br>
<div class="gmail-m_2645552137873417523gmail_signature">Jérémie
Galarneau<br>
EfficiOS Inc.<br>
<a href="http://www.efficios.com/" target="_blank">http://www.efficios.com</a></div>
</div>
<br>
<fieldset class="gmail-m_2645552137873417523mimeAttachmentHeader"></fieldset>
<br>
<pre>______________________________<wbr>_________________
lttng-dev mailing list
<a class="gmail-m_2645552137873417523moz-txt-link-abbreviated" href="mailto:lttng-dev@lists.lttng.org" target="_blank">lttng-dev@lists.lttng.org</a>
<a class="gmail-m_2645552137873417523moz-txt-link-freetext" href="https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev" target="_blank">https://lists.lttng.org/cgi-<wbr>bin/mailman/listinfo/lttng-dev</a>
</pre>
</blockquote>
<br>
</div>
______________________________<wbr>_________________<br>lttng-dev mailing list<br><a href="mailto:lttng-dev@lists.lttng.org" target="_blank">lttng-dev@lists.lttng.org</a><br><a href="https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev" target="_blank">https://lists.lttng.org/cgi-<wbr>bin/mailman/listinfo/lttng-dev</a><br></blockquote></div><br></div></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature">Jérémie Galarneau<br>EfficiOS Inc.<br><a href="http://www.efficios.com" target="_blank">http://www.efficios.com</a></div>
</div></div>