Skip to contentSkip to conversation

Fix conversion of task state to char in latency tracer

PATCH In review Ankita Garg 2 participants 2 messages Apr 9, 2008 – Apr 11, 2008 Tracing

lore
Share & tools
lore
#0 lore raw

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
Index: linux-2.6.24.3/kernel/trace/trace.c
===================================================================
@@ -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   
#1 lore raw
Quoted 10 lines · Ankita Garg

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

Quoted 3 lines

The patch has been compile and run tested.

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