summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorPeter Zijlstra <peterz@infradead.org>2017-09-22 18:30:40 +0200
committerIngo Molnar <mingo@kernel.org>2017-09-29 11:02:56 +0200
commit06eb61844d841d0032a9950ce7f8e783ee49c0d0 (patch)
tree2c1db5ade5acc687e67f37d69e711bf0470df532 /include/linux
parent5f6ad26ea353fdf3dad2328052cbee49e0b9c5b4 (diff)
sched/debug: Add explicit TASK_IDLE printing
Markus reported that kthreads that idle using TASK_IDLE instead of TASK_INTERRUPTIBLE are reported in as TASK_UNINTERRUPTIBLE and things like htop mark those red. This is undesirable, so add an explicit state for TASK_IDLE. Reported-by: Markus Trippelsdorf <markus@trippelsdorf.de> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: linux-kernel@vger.kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/sched.h12
1 files changed, 10 insertions, 2 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h
index bc7807933415..286fc1117046 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1241,22 +1241,30 @@ static inline pid_t task_pgrp_nr(struct task_struct *tsk)
return task_pgrp_nr_ns(tsk, &init_pid_ns);
}
+#define TASK_REPORT_IDLE (TASK_REPORT + 1)
+#define TASK_REPORT_MAX (TASK_REPORT_IDLE << 1)
+
static inline unsigned int __get_task_state(struct task_struct *tsk)
{
unsigned int tsk_state = READ_ONCE(tsk->state);
unsigned int state = (tsk_state | tsk->exit_state) & TASK_REPORT;
+ BUILD_BUG_ON_NOT_POWER_OF_2(TASK_REPORT_MAX);
+
if (tsk_state == TASK_PARKED)
state = TASK_INTERRUPTIBLE;
+ if (tsk_state == TASK_IDLE)
+ state = TASK_REPORT_IDLE;
+
return fls(state);
}
static inline char __task_state_to_char(unsigned int state)
{
- static const char state_char[] = "RSDTtXZ";
+ static const char state_char[] = "RSDTtXZI";
- BUILD_BUG_ON(1 + ilog2(TASK_REPORT) != sizeof(state_char) - 2);
+ BUILD_BUG_ON(1 + ilog2(TASK_REPORT_MAX) != sizeof(state_char) - 1);
return state_char[state];
}