summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Emde <C.Emde@osadl.org>2010-02-24 09:51:14 +0100
committerThomas Gleixner <tglx@linutronix.de>2010-02-24 12:10:52 +0100
commitd740a0190499992ffc6fca56922b1771bdb77189 (patch)
tree5d59b70e83c8cb8746a7d059def052fbfddcfbd1
parent18efbf5b5a41937fa7dd3839a3a8a42fda538cf1 (diff)
downloadlwn-d740a0190499992ffc6fca56922b1771bdb77189.tar.gz
lwn-d740a0190499992ffc6fca56922b1771bdb77189.zip
sched: Fix taskstates in sched_switch and proc
The sched_switch trace event displays erroneous character codes of task states, after a new task state was added in the scheduler code but omitted to add in the trace event code. Define character codes of task states individually. In addition, define task state descriptions needed in /proc at the same place. This will help to keep the task state bits, characters and descriptions in sync should they ever need to be changed again. Signed-off-by: Carsten Emde <C.Emde@osadl.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-rw-r--r--fs/proc/array.c27
-rw-r--r--include/linux/sched.h44
-rw-r--r--include/trace/events/sched.h9
3 files changed, 62 insertions, 18 deletions
diff --git a/fs/proc/array.c b/fs/proc/array.c
index 3dc90164e8a1..768d3e2d1087 100644
--- a/fs/proc/array.c
+++ b/fs/proc/array.c
@@ -129,22 +129,23 @@ static inline void task_name(struct seq_file *m, struct task_struct *p)
/*
* The task state array is a strange "bitmap" of
- * reasons to sleep. Thus "running" is zero, and
- * you can test for combinations of others with
+ * reasons to sleep. Thus, the first element is zero,
+ * and you can test for combinations of others with
* simple bit tests.
*/
+#define TASK_STATE_X(num) TASK_STATE_##num " (" DESCR_TASK_STATE_##num ")"
static const char *task_state_array[] = {
- "R (running)", /* 0 */
- "M (running-mutex)", /* 1 */
- "S (sleeping)", /* 2 */
- "D (disk sleep)", /* 4 */
- "T (stopped)", /* 8 */
- "t (tracing stop)", /* 16 */
- "Z (zombie)", /* 32 */
- "X (dead)", /* 64 */
- "x (dead)", /* 128 */
- "K (wakekill)", /* 256 */
- "W (waking)", /* 512 */
+ TASK_STATE_X(0),
+ TASK_STATE_X(1),
+ TASK_STATE_X(2),
+ TASK_STATE_X(4),
+ TASK_STATE_X(8),
+ TASK_STATE_X(16),
+ TASK_STATE_X(32),
+ TASK_STATE_X(64),
+ TASK_STATE_X(128),
+ TASK_STATE_X(256),
+ TASK_STATE_X(512)
};
static inline const char *get_task_state(struct task_struct *tsk)
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 9a9f376c4f44..a88462a32617 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -191,7 +191,9 @@ extern struct mutex kernel_sem;
/*
* Task state bitmask. NOTE! These bits are also
- * encoded in fs/proc/array.c: get_task_state().
+ * used in fs/proc/array.c: get_task_state() and
+ * in include/trace/events/sched.h in the
+ * sched_switch trace event.
*
* We have two separate sets of flags: task->state
* is about runnability, while task->exit_state are
@@ -200,21 +202,59 @@ extern struct mutex kernel_sem;
* mistake.
*/
#define TASK_RUNNING 0
+#define TASK_STATE_0 "R"
+#define DESCR_TASK_STATE_0 "running"
+
#define TASK_RUNNING_MUTEX 1
+#define TASK_STATE_1 "M"
+#define DESCR_TASK_STATE_1 "running-mutex"
+
#define TASK_INTERRUPTIBLE 2
+#define TASK_STATE_2 "S"
+#define DESCR_TASK_STATE_2 "sleeping"
+
#define TASK_UNINTERRUPTIBLE 4
+#define TASK_STATE_4 "D"
+#define DESCR_TASK_STATE_4 "disk sleep"
+
#define __TASK_STOPPED 8
+#define TASK_STATE_8 "T"
+#define DESCR_TASK_STATE_8 "stopped"
+
#define __TASK_TRACED 16
+#define TASK_STATE_16 "t"
+#define DESCR_TASK_STATE_16 "tracing stop"
+
/* in tsk->exit_state */
#define EXIT_ZOMBIE 32
+#define TASK_STATE_32 "Z"
+#define DESCR_TASK_STATE_32 "zombie"
+
#define EXIT_DEAD 64
+#define TASK_STATE_64 "X"
+#define DESCR_TASK_STATE_64 "dead"
+
/* in tsk->state again */
#define TASK_DEAD 128
+#define TASK_STATE_128 "x"
+#define DESCR_TASK_STATE_128 "dead"
+
#define TASK_WAKEKILL 256
+#define TASK_STATE_256 "K"
+#define DESCR_TASK_STATE_256 "wakekill"
+
#define TASK_WAKING 512
+#define TASK_STATE_512 "W"
+#define DESCR_TASK_STATE_512 "waking"
+
#define TASK_STATE_MAX 1024
-#define TASK_STATE_TO_CHAR_STR "RMSDTtZXxKW"
+#define TASK_STATE_TO_CHAR_STR \
+ TASK_STATE_0 TASK_STATE_1 TASK_STATE_2 TASK_STATE_4 TASK_STATE_8 \
+ TASK_STATE_16 TASK_STATE_32 TASK_STATE_64 TASK_STATE_128 TASK_STATE_256 \
+ TASK_STATE_512
+
+#define TASK_STATE_MAX 1024
extern char ___assert_task_state[1 - 2*!!(
sizeof(TASK_STATE_TO_CHAR_STR)-1 != ilog2(TASK_STATE_MAX)+1)];
diff --git a/include/trace/events/sched.h b/include/trace/events/sched.h
index 354e98fa3872..ad2ae9137ae9 100644
--- a/include/trace/events/sched.h
+++ b/include/trace/events/sched.h
@@ -161,9 +161,12 @@ TRACE_EVENT(sched_switch,
__entry->prev_comm, __entry->prev_pid, __entry->prev_prio,
__entry->prev_state ?
__print_flags(__entry->prev_state, "|",
- { 1, "S"} , { 2, "D" }, { 4, "T" }, { 8, "t" },
- { 16, "Z" }, { 32, "X" }, { 64, "x" },
- { 128, "W" }) : "R",
+ { 1, TASK_STATE_1} , { 2, TASK_STATE_2 },
+ { 4, TASK_STATE_4 }, { 8, TASK_STATE_8 },
+ { 16, TASK_STATE_16 }, { 32, TASK_STATE_32 },
+ { 64, TASK_STATE_64 }, { 128, TASK_STATE_128 },
+ { 256, TASK_STATE_256 }, { 512, TASK_STATE_512 }
+ ) : TASK_STATE_0,
__entry->next_comm, __entry->next_pid, __entry->next_prio)
);