[PATCH] Fix conversion of task state to char in latency tracer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

Signed-off-by: Ankita Garg <ankita@xxxxxxxxxx> 

Index: linux-2.6.24.3/kernel/trace/trace.c
===================================================================
--- linux-2.6.24.3.orig/kernel/trace/trace.c	2008-04-09 15:30:54.000000000 +0530
+++ linux-2.6.24.3/kernel/trace/trace.c	2008-04-09 23:37:03.000000000 +0530
@@ -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,


-- 
Regards,
Ankita Garg (ankita@xxxxxxxxxx)
Linux Technology Center
IBM India Systems & Technology Labs, 
Bangalore, India   
--
To unsubscribe from this list: send the line "unsubscribe linux-rt-users" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [RT Stable]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux