<html><body><div style="font-family: arial, helvetica, sans-serif; font-size: 12pt; color: #000000"><div><span id="zwchr" data-marker="__DIVIDER__">---- On Nov 26, 2015, at 7:34 AM, Luetkebohle Ingo (CR/AEA2) <Ingo.Luetkebohle@de.bosch.com> wrote:<br></span></div><div data-marker="__QUOTED_TEXT__"><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><style><!--

@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}

p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Arial",sans-serif;
        color:windowtext;
        font-weight:normal;
        font-style:normal;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 2.0cm 70.85pt;}
div.WordSection1
        {page:WordSection1;}
--></style><div class="WordSection1"><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif" lang="EN-US">Hi,</span></p><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif" lang="EN-US"> </span></p><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif" lang="EN-US">I noticed that the “procname” and “tid” *<b>context</b>* variables can differ from the “comm” and “tid” variables of the sched_stat_-tracepoints (e.g., for sched_stat_runtime).</span></p><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif" lang="EN-US"> </span></p><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif" lang="EN-US">For example, see the following two outputs:</span></p><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif" lang="EN-US">[15:49:33.674072890] (+0.000029771) rng2070 sched_stat_sleep: { cpu_id = 4 }, { pid = 26974, procname = "amcl", tid = 26975 }, { comm = "lttng-sessiond", tid = 798,
 delay = 194122524 }</span></p><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif" lang="EN-US">[15:49:33.722894563] (+0.000004851) rng2070 sched_stat_sleep: { cpu_id = 0 }, { pid = 0, procname = "swapper/0", tid = 0 }, { comm = "amcl", tid = 27078, delay =
 10043658 }</span></p><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif" lang="EN-US"> </span></p><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif" lang="EN-US">In both cases, procname differs from comm.  I’ve looked at the kernel source code, and the “comm” variable is taken from task_struct.filename. Barring renames, this
 would be the correct one, so I’m assuming that the context is sometimes incorrect.</span></p><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif" lang="EN-US"> </span></p><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif" lang="EN-US">Now, for this particular case, I can take the correct variables from the tracepoint, but of course, this makes me worried that the context might also be wrong in
 other cases… Do you have any idea what could be going on here?</span></p><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif" lang="EN-US"> </span></p><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif" lang="EN-US">LTTng is Version 2.7.x+stable+bzr2948+pack17+201511192116~ubuntu14.04.1 and this is on a 3.19.0-33-generic kernel (btw, that’s not the default kernel for Ubuntu
 14.04, but the LTS vivid backport kernel).</span></p></div></blockquote><div>Hi,<br></div><div><br data-mce-bogus="1"></div><div>Looking at lttng-modules lttng-context-tid.c tid_record(), we see that it uses task_pid_nr(current).<br data-mce-bogus="1"></div><div>It therefore gets the tid of the currently scheduled task. This is similar for procname.<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><div>Now looking at the Linux kernel kernel/sched/fair.c: enqueue_sleeper(), which calls<br data-mce-bogus="1"></div><div>trace_sched_stat_sleep(), we see that it passes "tsk" as parameter to the tracepoint.<br data-mce-bogus="1"></div><div>Already here, nothing seems to ensure that "tsk" is the currently scheduled task. It's<br data-mce-bogus="1"></div><div>rather a task that is being put to sleep. Looking at the callers of enqueue_sleeper(),<br data-mce-bogus="1"></div><div>we can understand that the current task is first scheduled out before being enqueued<br data-mce-bogus="1"></div><div>as a sleeper. This is why, when we hit the sched_stat_sleep tracepoint, the current<br data-mce-bogus="1"></div><div>task is not "tsk", which explains the difference between the context information<br data-mce-bogus="1"></div><div>and the tracepoint payload information: they really target different tasks.<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><div>Does this help solve your concerns ?<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><div>Thanks,<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><div>Mathieu<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><div class="WordSection1"><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif" lang="EN-US"> </span></p><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif;color:black;mso-fareast-language:DE" lang="EN-US">Mit freundlichen Grüßen / Best regards
<br>
<br>
<b>Ingo Luetkebohle<br>
</b><br>
Application Software (CR/AEA2) <br>
Tel. +49(711)811-12248 | Fax +49(711)811-0 | </span><span style="font-size:10.0pt;font-family:"Arial",sans-serif;color:black;mso-fareast-language:DE"><a href="mailto:Ingo.Luetkebohle@de.bosch.com" target="_blank"><span style="color:blue" lang="EN-US">Ingo.Luetkebohle@de.bosch.com</span></a></span><span style="font-size:10.0pt;font-family:"Arial",sans-serif;color:black;mso-fareast-language:DE">
</span><span style="font-size:8.0pt;font-family:"Arial",sans-serif;color:black;mso-fareast-language:DE" lang="EN-US"><br>
</span><span style="font-size:10.0pt;font-family:"Arial",sans-serif;color:black;mso-fareast-language:DE" lang="EN-US"><br>
<br>
</span></p></div><br>_______________________________________________<br>lttng-dev mailing list<br>lttng-dev@lists.lttng.org<br>http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev<br></blockquote></div><div><br></div><div data-marker="__SIG_POST__">-- <br></div><div>Mathieu Desnoyers<br>EfficiOS Inc.<br>http://www.efficios.com</div></div></body></html>