<div dir="ltr"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">>     On 2019-07-24 2:44 a.m., Ravindra Kumar Meena wrote:<br>
>     > Hi,<br>
>     ><br>
>     > I had a looked at TraceCompass example. I came across sched_swithc event in present in the metadata.<br>
>     ><br>
>     > event {<br>
>     > name = "sched_switch";<br>
>     > id = 27;<br>
>     > stream_id = 0;<br>
>     > fields := struct {<br>
>     > integer { size = 8; align = 8; signed = 0; encoding = UTF8; base = 10; } _prev_comm[16];<br>
>     > integer { size = 32; align = 8; signed = 1; encoding = none; base = 10; } _prev_tid;<br>
>     > integer { size = 32; align = 8; signed = 1; encoding = none; base = 10; } _prev_prio;<br>
>     > integer { size = 64; align = 8; signed = 1; encoding = none; base = 10; } _prev_state;<br>
>     > integer { size = 8; align = 8; signed = 0; encoding = UTF8; base = 10; } _next_comm[16];<br>
>     > integer { size = 32; align = 8; signed = 1; encoding = none; base = 10; } _next_tid;<br>
>     > integer { size = 32; align = 8; signed = 1; encoding = none; base = 10; } _next_prio;<br>
>     > };<br>
>     > };<br>
>     ><br>
>     > All event.fields variables are clear to me but what does _prev_state do here? I had a looked at its babeltrace output but found no pattern in _prev_state value.<br><br>
In the Linux kernel, the tracepoint for sched_switch does not have the<br>
field prev_state:<br>
<br>
<a href="https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/tracepoint.h?id=52a6e82ac27288f591c750f201de5c3e6ef24385#n465" rel="noreferrer" target="_blank">https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/tracepoint.h?id=52a6e82ac27288f591c750f201de5c3e6ef24385#n465</a><br>
<br>
<br>
In lttng-modules, however, there is the field prev_state:<br>
<br>
<a href="http://git.lttng.org/?p=lttng-modules.git;a=blob;f=instrumentation/events/lttng-module/sched.h;h=77d77b2aeeddbe6ac34e2228b077734721f45b18;hb=4ea9b7c98ade603b08f0d945f4d99bc079eb57b6#l237" rel="noreferrer" target="_blank">http://git.lttng.org/?p=lttng-modules.git;a=blob;f=instrumentation/events/lttng-module/sched.h;h=77d77b2aeeddbe6ac34e2228b077734721f45b18;hb=4ea9b7c98ade603b08f0d945f4d99bc079eb57b6#l237</a><br>
<br>
<br>
My guess would be that prev_state is the previous state of the thread (TID):<br></blockquote><div>Okay. The above link was somewhat helpful but I still didn't get what is the meaning of {0, 1, 1026, 4096} values in _prev_state. </div><div><br></div><div>In babeltrace output _prev_state have { 0, 1, 1026, 4096 } values.</div><div><br></div><div>The example can be found here <a href="https://github.com/tuxology/tracevizlab/blob/master/labs/TraceCompassTutorialTraces.tgz">https://github.com/tuxology/tracevizlab/blob/master/labs/TraceCompassTutorialTraces.tgz</a></div><div><br></div><div>At folder "102-tracing-wget-critical-path/wget-first-call" babeltrace gives following output.</div><div><br></div><div>babeltrace . | grep sched_switch</div><div><br></div>[21:20:44.207247650] (+0.000000799) arnaud-desktop sched_switch: { cpu_id = 3 }, { prev_comm = "swapper/3", prev_tid = 0, prev_prio = 20, prev_state = 0, next_comm = "kworker/u8:2", next_tid = 8363, next_prio = 20 }<br>[21:20:44.207252919] (+0.000000085) arnaud-desktop sched_switch: { cpu_id = 3 }, { prev_comm = "kworker/u8:2", prev_tid = 8363, prev_prio = 20, prev_state = 1026, next_comm = "swapper/3", next_tid = 0, next_prio = 20 }<br>[21:20:44.207253370] (+0.000000143) arnaud-desktop sched_switch: { cpu_id = 0 }, { prev_comm = "code", prev_tid = 3876, prev_prio = 20, prev_state = 0, next_comm = "code", next_tid = 4140, next_prio = 20 }<br>[21:20:44.207257279] (+0.000000656) arnaud-desktop sched_switch: { cpu_id = 3 }, { prev_comm = "swapper/3", prev_tid = 0, prev_prio = 20, prev_state = 0, next_comm = "kworker/u8:2", next_tid = 8363, next_prio = 20 }<br>[21:20:44.207258485] (+0.000000903) arnaud-desktop sched_switch: { cpu_id = 3 }, { prev_comm = "kworker/u8:2", prev_tid = 8363, prev_prio = 20, prev_state = 1026, next_comm = "swapper/3", next_tid = 0, next_prio = 20 }<br>[21:20:44.207270164] (+0.000000081) arnaud-desktop sched_switch: { cpu_id = 3 }, { prev_comm = "swapper/3", prev_tid = 0, prev_prio = 20, prev_state = 0, next_comm = "kworker/u8:2", next_tid = 8363, next_prio = 20 }</div><div class="gmail_quote"><br></div><div class="gmail_quote">P.S: This is not a full babeltrace output.</div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><font size="4"><b>Ravindra Kumar Meena</b></font>,<div><span style="color:rgb(102,102,102)">B. Tech. Computer Science and Engineering,<br></span></div><div><span style="color:rgb(102,102,102)"><a href="https://www.iitism.ac.in/" style="color:rgb(17,85,204)" target="_blank">Indian Institute of Technology (Indian School of Mines)</a>, Dhanbad</span></div></div></div></div></div></div>