Fix conversion of task state to char in latency tracer
PATCH 1/1 Fix conversion of task state to char in latency tracer
Hi,
The conversion of task states to a character in the sched_switch tracer (part of latency tracer infrastructure), seems to be incorrect. We currently do it by indexing into the state_to_char array using the state value. The state values do not map directly into the array index and are thus incorrect. The following patch addresses this issue. This is also what is being done even in the show_task() routine in kernel/sched.c
The patch has been compile and run tested.
kernel/trace/trace.c +3 -2
@@ -1086,6 +1086,7 @@char *comm;unsigned long nr;int S ; +unsigned state;if (!next_entry) next_entry = entry;
@@ -1114,8 +1115,8 @@seq_puts (m,")\n" );break ;case TRACE_CTX : -S = entry->ctx.prev_state <sizeof (state_to_char) ? - state_to_char[entry->ctx.prev_state] :'X' ; + state = entry->ctx.prev_state ?__ffs (entry->ctx.prev_state) +1 :0 ; +S = state <sizeof (state_to_char) -1 ? state_to_char[state] :'X' ; comm =trace_find_cmdline (entry->ctx.next_pid); seq_printf(m, " %d:%d:%c --> %d:%d %s\n", entry->ctx.prev_pid,
Signature · 5 lines
Regards, Ankita Garg ([email protected]) Linux Technology Center IBM India Systems & Technology Labs, Bangalore, India
Quoted 10 lines · Ankita Garg
Hi,
The conversion of task states to a character in the
sched_switchtracer (part of latency tracer infrastructure), seems to be incorrect. We currently do it by indexing into thestate_to_chararray using the state value. The state values do not map directly into the array index and are thus incorrect. The following patch addresses this issue. This is also what is being done even in theshow_task()routine inkernel/sched.c
Quoted 3 lines
The patch has been compile and run tested.
Signed-off-by Ankita Garg <[email protected]>
thanks Ankita, good catch. I applied your patch to sched-devel/latest as well (which carries the ftrace patches, and which patches -rt is tracking). You can track this upstream tree via:
http://people.redhat.com/mingo/sched-devel.git/README
Ingo