linux-rt-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Fix conversion of task state to char in latency tracer
@ 2008-04-09 18:16 Ankita Garg
  2008-04-11  9:30 ` Ingo Molnar
  0 siblings, 1 reply; 2+ messages in thread
From: Ankita Garg @ 2008-04-09 18:16 UTC (permalink / raw)
  To: linux-rt-users; +Cc: Steven Rostedt, Ingo Molnar, Chirag Jog

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@in.ibm.com> 

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@in.ibm.com)
Linux Technology Center
IBM India Systems & Technology Labs, 
Bangalore, India   

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Fix conversion of task state to char in latency tracer
  2008-04-09 18:16 [PATCH] Fix conversion of task state to char in latency tracer Ankita Garg
@ 2008-04-11  9:30 ` Ingo Molnar
  0 siblings, 0 replies; 2+ messages in thread
From: Ingo Molnar @ 2008-04-11  9:30 UTC (permalink / raw)
  To: Ankita Garg, linux-rt-users, Steven Rostedt, Chirag Jog


* Ankita Garg <ankita@in.ibm.com> wrote:

> 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@in.ibm.com>

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-04-11  9:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-09 18:16 [PATCH] Fix conversion of task state to char in latency tracer Ankita Garg
2008-04-11  9:30 ` Ingo Molnar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).