<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Hi the developers !</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
CONTEXT</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
I am currently working on a Raspberry pi 3B with Xenomai and LTTng tools.</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Raspbian 10.9 Buster - kernel 4.19.85</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<span style="background-color:rgb(255, 255, 255);display:inline !important">uname -a : Linux raspberrypi 4.19.85-v7+ #5 SMP PREEMPT Wed May 12 10:13:37</span><br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<div style="margin:0px; font-size:12pt">Both tools are working, but I wonder about the accuracy of LTTng libraries.</div>
<div style="margin:0px; font-size:12pt"><br>
</div>
<div style="margin:0px; font-size:12pt"><br>
</div>
<div style="margin:0px; font-size:12pt">METHOD</div>
<div style="margin:0px; font-size:12pt"><span style="font-size: 12pt;">The code used is quite simple, it is written with the alchemy skin.</span></div>
<div style="margin:0px; font-size:12pt"><span style="font-size: 12pt;">A </span><span style="font-size: 12pt;">rt_task_spawn calls a function that has rt_task_set_periodic(NULL, TM_NOW, period) and rt_task_wait_period(NULL). </span></div>
<div style="margin:0px; font-size:12pt"><span style="font-size: 12pt;">->The <span style="background-color:rgb(255, 255, 255);display:inline !important">rt_task_set_periodic is based on 1ms.</span></span></div>
<div style="margin:0px; font-size:12pt"><span style="font-size: 12pt;">->The <span style="background-color:rgb(255, 255, 255);display:inline !important"><span> </span>rt_task_wait_period(NULL) is of course inside a while loop (see below at the very end)</span>.</span><br>
</div>
<div style="margin:0px; font-size:12pt"><span style="font-size: 12pt;"><br>
</span></div>
<div style="margin:0px; font-size:12pt"><span style="font-size: 12pt;">My goal is to get accurate traces from Xenomai.</span></div>
<div style="margin:0px; font-size:12pt"><span style="font-size: 12pt;">I took two methods to do so : </span></div>
<div style="margin:0px; font-size:12pt">
<div><span style="font-size: 12pt;">-> lttng</span></div>
<div><span style="font-size: 12pt;">-> basic calculation based on <span style="text-align:start;background-color:rgb(255, 255, 255);display:inline !important"><span> </span>rt_timer_read()</span></span></div>
<div><span style="font-size: 12pt;"><span style="text-align:start;background-color:rgb(255, 255, 255);display:inline !important"><br>
</span></span></div>
<div><span style="font-size: 12pt;"><span style="text-align:start;background-color:rgb(255, 255, 255);display:inline !important"><span style="background-color:rgb(255, 255, 255);display:inline !important">What a surprise when I found both method have two different
results.</span></span></span></div>
<div>-> LTTng shows me traces [0.870;1.13] ms (or even less precise)</div>
<div>-> rt_time_read shows me traces [0.980;1.020] ms</div>
<div><br>
</div>
<div>Thing to note : </div>
<div>-> The use of LTTng has no influence on rt_time_read(), you can use both methods at the same time.</div>
<div><br>
</div>
<div>Then, I saved the output of <span style="background-color:rgb(255, 255, 255);display:inline !important">rt_time_read inside a tracepoint.</span></div>
<div><span style="background-color:rgb(255, 255, 255);display:inline !important"><span>It appeared the LTTng is always called at the right time because the value got by <span style="background-color:rgb(255, 255, 255);display:inline !important">rt_time_read<span> ()
is really good.</span></span></span></span></div>
<div><span style="background-color:rgb(255, 255, 255);display:inline !important"><span><span style="background-color:rgb(255, 255, 255);display:inline !important"><span><br>
</span></span></span></span></div>
<div><span style="background-color:rgb(255, 255, 255);display:inline !important"><span><span style="background-color:rgb(255, 255, 255);display:inline !important"><span><br>
</span></span></span></span></div>
<div><span style="background-color:rgb(255, 255, 255);display:inline !important"><span><span style="background-color:rgb(255, 255, 255);display:inline !important"><span>QUESTIONS</span></span></span></span></div>
<div>These are now my questions :</div>
<div>- What is the method I should trust ?</div>
<div>- I have searched on the forum and I found LTTng uses a MONOTONIC clock for the timestamp. Can/Should I modify it ?</div>
</div>
<div style="margin:0px; font-size:12pt"><span style="font-size: 12pt;"><br>
</span></div>
<div style="margin:0px; font-size:12pt"><span style="font-size: 12pt;"><br>
</span></div>
<div style="margin:0px; font-size:12pt"><span style="font-size: 12pt;">CODE</span></div>
<div style="margin:0px; font-size:12pt">-----------------------------------------------------------------------</div>
<div style="margin:0px; font-size:12pt"><span style="font-size: 12pt;"><span style="margin:0px;font-size:12pt">A small part of my function called by <span style="margin:0px;background-color:rgb(255, 255, 255);display:inline !important">rt_task_spawn<span style="margin:0px"> :</span></span></span>
<div style="margin:0px;font-size:12pt">[...]</div>
<div style="margin:0px;font-size:12pt"> RTIME period = 1000*1000; // in ns
<div style="margin:0px"> RTIME now;</div>
<div style="margin:0px"> RTIME previous = 0;</div>
RTIME duration;<br>
</div>
<div style="margin:0px;font-size:12pt">[...]</div>
<div style="margin:0px;font-size:12pt"> while(1)
<div style="margin:0px"> {</div>
<div style="margin:0px"> overruns = 0;</div>
<div style="margin:0px"> err = rt_task_wait_period(&overruns);</div>
<div style="margin:0px"><span style="background-color:rgb(255, 255, 255);display:inline !important"> now = rt_timer_read();</span><br>
</div>
<div style="margin:0px"> tracepoint(tp_provider, tracepoint_tick_ms, now, "tick");</div>
<div style="margin:0px"> </div>
<div style="margin:0px"> if (previous != 0)</div>
<div style="margin:0px"> {</div>
<div style="margin:0px"> duration=now-previous;</div>
<div style="margin:0px"> rt_printf("%llu\n \n", duration/1000);</div>
<div style="margin:0px"> }</div>
<div style="margin:0px"> previous=now;</div>
[...]<br>
</div>
<span style="margin:0px;font-size:12pt">}</span><br>
</span></div>
<div style="margin:0px; font-size:12pt"><span style="font-size: 12pt;"><span style="margin:0px;font-size:12pt">------------------------------------------------------------------------</span></span></div>
<div style="margin:0px; font-size:12pt"><span style="font-size: 12pt;"><span style="margin:0px;font-size:12pt"><br>
</span></span></div>
<div style="margin:0px; font-size:12pt"><span style="font-size: 12pt;"><span style="margin:0px;font-size:12pt">Regards,</span></span></div>
<div style="margin:0px; font-size:12pt"><span style="font-size: 12pt;"><span style="margin:0px;font-size:12pt"><br>
</span></span></div>
<div style="margin:0px; font-size:12pt"><span style="font-size: 12pt;"><span style="margin:0px;font-size:12pt">Julien</span></span></div>
<span style="margin:0px; font-size:12pt"></span></div>
</body>
</html>