aboutsummaryrefslogtreecommitdiffstats
path: root/fs/proc/array.c
diff options
context:
space:
mode:
authorChris Metcalf <cmetcalf@ezchip.com>2015-06-24 19:55:48 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2015-06-24 20:49:40 -0400
commitf51c0eaee39e306458d2bf8a30e010615fa451cc (patch)
tree9e30381d84917c1ef727dac28691e648833c17df /fs/proc/array.c
parentfe4ba3c34352b7e8068b7f18eb233444aed17011 (diff)
procfs: treat parked tasks as sleeping for task state
Allowing watchdog threads to be parked means that we now have the opportunity of actually seeing persistent parked threads in the output of /proc/<pid>/stat and /proc/<pid>/status. The existing code reported such threads as "Running", which is kind-of true if you think of the case where we park them as part of taking cpus offline. But if we allow parking them indefinitely, "Running" is pretty misleading, so we report them as "Sleeping" instead. We could simply report them with a new string, "Parked", but it feels like it's a bit risky for userspace to see unexpected new values; the output is already documented in Documentation/filesystems/proc.txt, and it seems like a mistake to change that lightly. The scheduler does report parked tasks with a "P" in debugging output from sched_show_task() or dump_cpu_task(), but that's a different API. Similarly, the trace_ctxwake_* routines report a "P" for parked tasks, but again, different API. This change seemed slightly cleaner than updating the task_state_array to have additional rows. TASK_DEAD should be subsumed by the exit_state bits; TASK_WAKEKILL is just a modifier; and TASK_WAKING can very reasonably be reported as "Running" (as it is now). Only TASK_PARKED shows up with unreasonable output here. Signed-off-by: Chris Metcalf <cmetcalf@ezchip.com> Cc: Don Zickus <dzickus@redhat.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Ulrich Obergfell <uobergfe@redhat.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Frederic Weisbecker <fweisbec@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/proc/array.c')
-rw-r--r--fs/proc/array.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/fs/proc/array.c b/fs/proc/array.c
index fd02a9ebfc30..3f57dac31ba6 100644
--- a/fs/proc/array.c
+++ b/fs/proc/array.c
@@ -126,6 +126,14 @@ static inline const char *get_task_state(struct task_struct *tsk)
126{ 126{
127 unsigned int state = (tsk->state | tsk->exit_state) & TASK_REPORT; 127 unsigned int state = (tsk->state | tsk->exit_state) & TASK_REPORT;
128 128
129 /*
130 * Parked tasks do not run; they sit in __kthread_parkme().
131 * Without this check, we would report them as running, which is
132 * clearly wrong, so we report them as sleeping instead.
133 */
134 if (tsk->state == TASK_PARKED)
135 state = TASK_INTERRUPTIBLE;
136
129 BUILD_BUG_ON(1 + ilog2(TASK_REPORT) != ARRAY_SIZE(task_state_array)-1); 137 BUILD_BUG_ON(1 + ilog2(TASK_REPORT) != ARRAY_SIZE(task_state_array)-1);
130 138
131 return task_state_array[fls(state)]; 139 return task_state_array[fls(state)];