From: Xie XiuQi <xiexiuqi@huawei.com>
To: <mingo@redhat.com>, <peterz@infradead.org>
Cc: <linux-kernel@vger.kernel.org>, <huawei.libin@huawei.com>,
<cj.chengjian@huawei.com>, <xiexiuqi@huawei.com>
Subject: [PATCH 1/2] sched/debug: show task state on /proc/sched_debug
Date: Mon, 7 Aug 2017 16:44:22 +0800 [thread overview]
Message-ID: <1502095463-160172-2-git-send-email-xiexiuqi@huawei.com> (raw)
In-Reply-To: <1502095463-160172-1-git-send-email-xiexiuqi@huawei.com>
Currently, we print the runnable task in /proc/sched_debug, but there is no task state information.
We don't know which task is in runqueue, and which task is in sleep. For the convenience of debugging,
in this patch, we add task state in runnable task list, like this:
runnable tasks:
S task PID tree-key switches prio wait-time sum-exec sum-sleep
-----------------------------------------------------------------------------------------------------------
S watchdog/239 1452 -11.917445 2811 0 0.000000 8.949306 0.000000 7 0 /
S migration/239 1453 20686.367740 8 0 0.000000 16215.720897 0.000000 7 0 /
S ksoftirqd/239 1454 115383.841071 12 120 0.000000 0.200683 0.000000 7 0 /
>R test 21287 4872.190970 407 120 0.000000 4874.911790 0.000000 7 0 /autogroup-150
R test 21288 4868.385454 401 120 0.000000 3672.341489 0.000000 7 0 /autogroup-150
R test 21289 4868.326776 384 120 0.000000 3424.934159 0.000000 7 0 /autogroup-150
Signed-off-by: Xie XiuQi <xiexiuqi@huawei.com>
---
kernel/sched/debug.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
index 38f0193..60f7e20 100644
--- a/kernel/sched/debug.c
+++ b/kernel/sched/debug.c
@@ -421,13 +421,19 @@ static char *task_group_path(struct task_group *tg)
}
#endif
+static const char stat_nam[] = TASK_STATE_TO_CHAR_STR;
+
static void
print_task(struct seq_file *m, struct rq *rq, struct task_struct *p)
{
- if (rq->curr == p)
- SEQ_printf(m, "R");
- else
- SEQ_printf(m, " ");
+ unsigned long state;
+
+ if (rq->curr == p) {
+ SEQ_printf(m, ">R");
+ } else {
+ state = p->state ? __ffs(p->state) + 1 : 0;
+ SEQ_printf(m, " %c", state < sizeof(stat_nam) - 1 ? stat_nam[state] : '?');
+ }
SEQ_printf(m, "%15s %5d %9Ld.%06ld %9Ld %5d ",
p->comm, task_pid_nr(p),
@@ -456,9 +462,9 @@ static void print_rq(struct seq_file *m, struct rq *rq, int rq_cpu)
SEQ_printf(m,
"\nrunnable tasks:\n"
- " task PID tree-key switches prio"
+ " S task PID tree-key switches prio"
" wait-time sum-exec sum-sleep\n"
- "------------------------------------------------------"
+ "-------------------------------------------------------"
"----------------------------------------------------\n");
rcu_read_lock();
--
1.8.3.1
next prev parent reply other threads:[~2017-08-07 8:41 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-07 8:44 [PATCH 0/2] sched/debug: show task state on /proc/sched_debug Xie XiuQi
2017-08-07 8:44 ` Xie XiuQi [this message]
2017-08-10 12:09 ` [tip:sched/core] sched/debug: Show task state in /proc/sched_debug tip-bot for Xie XiuQi
2017-08-07 8:44 ` [PATCH 2/2] sched/debug: intruduce task_state_to_char helper function Xie XiuQi
2017-08-08 6:42 ` kbuild test robot
2017-08-08 8:43 ` Xie XiuQi
2017-08-09 1:16 ` Xie XiuQi
2017-08-08 17:27 ` kbuild test robot
2017-08-10 12:10 ` [tip:sched/core] sched/debug: Intruduce task_state_to_char() " tip-bot for Xie XiuQi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1502095463-160172-2-git-send-email-xiexiuqi@huawei.com \
--to=xiexiuqi@huawei.com \
--cc=cj.chengjian@huawei.com \
--cc=huawei.libin@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).