aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2008-12-17 16:34:13 -0500
committerIngo Molnar <mingo@elte.hu>2008-12-18 07:03:09 -0500
commit3d9101e92529e1ff6014f95a69afc82f37b9b13a (patch)
tree5147a9331a9a98d0ab073258d489aa0b052e524b /kernel
parent55dac3a5553b13891f0ae4bbd11920619b5436d4 (diff)
trace: fix task state printout
Impact: fix occasionally incorrect trace output The tracing code has interesting varieties of printing out task state. Unfortunalely only one of the instances is correct as it copies the code from sched.c:sched_show_task(). The others are plain wrong as they treatthe bitfield as an integer offset into the character array. Also the size check of the character array is wrong as it includes the trailing \0. Use a common state decoder inline which does the Right Thing. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Acked-by: Steven Rostedt <rostedt@goodmis.org> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/trace/trace.c39
1 files changed, 17 insertions, 22 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index d86e3252f300..803100518f11 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -1301,6 +1301,13 @@ lat_print_timestamp(struct trace_seq *s, u64 abs_usecs,
1301 1301
1302static const char state_to_char[] = TASK_STATE_TO_CHAR_STR; 1302static const char state_to_char[] = TASK_STATE_TO_CHAR_STR;
1303 1303
1304static int task_state_char(unsigned long state)
1305{
1306 int bit = state ? __ffs(state) + 1 : 0;
1307
1308 return bit < sizeof(state_to_char) - 1 ? state_to_char[bit] : '?';
1309}
1310
1304/* 1311/*
1305 * The message is supposed to contain an ending newline. 1312 * The message is supposed to contain an ending newline.
1306 * If the printing stops prematurely, try to add a newline of our own. 1313 * If the printing stops prematurely, try to add a newline of our own.
@@ -1396,12 +1403,8 @@ print_lat_fmt(struct trace_iterator *iter, unsigned int trace_idx, int cpu)
1396 1403
1397 trace_assign_type(field, entry); 1404 trace_assign_type(field, entry);
1398 1405
1399 T = field->next_state < sizeof(state_to_char) ? 1406 T = task_state_char(field->next_state);
1400 state_to_char[field->next_state] : 'X'; 1407 S = task_state_char(field->prev_state);
1401
1402 state = field->prev_state ?
1403 __ffs(field->prev_state) + 1 : 0;
1404 S = state < sizeof(state_to_char) - 1 ? state_to_char[state] : 'X';
1405 comm = trace_find_cmdline(field->next_pid); 1408 comm = trace_find_cmdline(field->next_pid);
1406 trace_seq_printf(s, " %5d:%3d:%c %s [%03d] %5d:%3d:%c %s\n", 1409 trace_seq_printf(s, " %5d:%3d:%c %s [%03d] %5d:%3d:%c %s\n",
1407 field->prev_pid, 1410 field->prev_pid,
@@ -1519,10 +1522,8 @@ static enum print_line_t print_trace_fmt(struct trace_iterator *iter)
1519 1522
1520 trace_assign_type(field, entry); 1523 trace_assign_type(field, entry);
1521 1524
1522 S = field->prev_state < sizeof(state_to_char) ? 1525 T = task_state_char(field->next_state);
1523 state_to_char[field->prev_state] : 'X'; 1526 S = task_state_char(field->prev_state);
1524 T = field->next_state < sizeof(state_to_char) ?
1525 state_to_char[field->next_state] : 'X';
1526 ret = trace_seq_printf(s, " %5d:%3d:%c %s [%03d] %5d:%3d:%c\n", 1527 ret = trace_seq_printf(s, " %5d:%3d:%c %s [%03d] %5d:%3d:%c\n",
1527 field->prev_pid, 1528 field->prev_pid,
1528 field->prev_prio, 1529 field->prev_prio,
@@ -1621,12 +1622,9 @@ static enum print_line_t print_raw_fmt(struct trace_iterator *iter)
1621 1622
1622 trace_assign_type(field, entry); 1623 trace_assign_type(field, entry);
1623 1624
1624 S = field->prev_state < sizeof(state_to_char) ? 1625 T = task_state_char(field->next_state);
1625 state_to_char[field->prev_state] : 'X'; 1626 S = entry->type == TRACE_WAKE ? '+' :
1626 T = field->next_state < sizeof(state_to_char) ? 1627 task_state_char(field->prev_state);
1627 state_to_char[field->next_state] : 'X';
1628 if (entry->type == TRACE_WAKE)
1629 S = '+';
1630 ret = trace_seq_printf(s, "%d %d %c %d %d %d %c\n", 1628 ret = trace_seq_printf(s, "%d %d %c %d %d %d %c\n",
1631 field->prev_pid, 1629 field->prev_pid,
1632 field->prev_prio, 1630 field->prev_prio,
@@ -1712,12 +1710,9 @@ static enum print_line_t print_hex_fmt(struct trace_iterator *iter)
1712 1710
1713 trace_assign_type(field, entry); 1711 trace_assign_type(field, entry);
1714 1712
1715 S = field->prev_state < sizeof(state_to_char) ? 1713 T = task_state_char(field->next_state);
1716 state_to_char[field->prev_state] : 'X'; 1714 S = entry->type == TRACE_WAKE ? '+' :
1717 T = field->next_state < sizeof(state_to_char) ? 1715 task_state_char(field->prev_state);
1718 state_to_char[field->next_state] : 'X';
1719 if (entry->type == TRACE_WAKE)
1720 S = '+';
1721 SEQ_PUT_HEX_FIELD_RET(s, field->prev_pid); 1716 SEQ_PUT_HEX_FIELD_RET(s, field->prev_pid);
1722 SEQ_PUT_HEX_FIELD_RET(s, field->prev_prio); 1717 SEQ_PUT_HEX_FIELD_RET(s, field->prev_prio);
1723 SEQ_PUT_HEX_FIELD_RET(s, S); 1718 SEQ_PUT_HEX_FIELD_RET(s, S);