[lttng-dev] What is _prev_state in sched_switch?

Ravindra Kumar Meena rmeena840 at gmail.com
Mon Jul 29 05:07:20 EDT 2019


>
> >     On 2019-07-24 2:44 a.m., Ravindra Kumar Meena wrote:
> >     > Hi,
> >     >
> >     > I had a looked at TraceCompass example. I came across sched_swithc
> event in present in the metadata.
> >     >
> >     > event {
> >     > name = "sched_switch";
> >     > id = 27;
> >     > stream_id = 0;
> >     > fields := struct {
> >     > integer { size = 8; align = 8; signed = 0; encoding = UTF8; base =
> 10; } _prev_comm[16];
> >     > integer { size = 32; align = 8; signed = 1; encoding = none; base
> = 10; } _prev_tid;
> >     > integer { size = 32; align = 8; signed = 1; encoding = none; base
> = 10; } _prev_prio;
> >     > integer { size = 64; align = 8; signed = 1; encoding = none; base
> = 10; } _prev_state;
> >     > integer { size = 8; align = 8; signed = 0; encoding = UTF8; base =
> 10; } _next_comm[16];
> >     > integer { size = 32; align = 8; signed = 1; encoding = none; base
> = 10; } _next_tid;
> >     > integer { size = 32; align = 8; signed = 1; encoding = none; base
> = 10; } _next_prio;
> >     > };
> >     > };
> >     >
> >     > 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.
>
> In the Linux kernel, the tracepoint for sched_switch does not have the
> field prev_state:
>
>
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/tracepoint.h?id=52a6e82ac27288f591c750f201de5c3e6ef24385#n465
>
>
> In lttng-modules, however, there is the field prev_state:
>
>
> http://git.lttng.org/?p=lttng-modules.git;a=blob;f=instrumentation/events/lttng-module/sched.h;h=77d77b2aeeddbe6ac34e2228b077734721f45b18;hb=4ea9b7c98ade603b08f0d945f4d99bc079eb57b6#l237
>
>
> My guess would be that prev_state is the previous state of the thread
> (TID):
>
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.

In babeltrace output _prev_state have { 0, 1, 1026, 4096 } values.

The example can be found here
https://github.com/tuxology/tracevizlab/blob/master/labs/TraceCompassTutorialTraces.tgz

At folder "102-tracing-wget-critical-path/wget-first-call" babeltrace gives
following output.

babeltrace . | grep sched_switch

[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 }
[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 }
[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 }
[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 }
[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 }
[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 }

P.S: This is not a full babeltrace output.


-- 
*Ravindra Kumar Meena*,
B. Tech. Computer Science and Engineering,
Indian Institute of Technology (Indian School of Mines)
<https://www.iitism.ac.in/>, Dhanbad
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.lttng.org/pipermail/lttng-dev/attachments/20190729/351c7f13/attachment.html>


More information about the lttng-dev mailing list