Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1705247 > unrolled thread

[PATCH 0/2] sched/debug: show task state on /proc/sched_debug

Started byXie XiuQi <xiexiuqi@huawei.com>
First post2017-08-07 10:50 +0200
Last post2017-08-10 14:20 +0200
Articles 3 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 0/2] sched/debug: show task state on /proc/sched_debug Xie XiuQi <xiexiuqi@huawei.com> - 2017-08-07 10:50 +0200
    [PATCH 1/2] sched/debug: show task state on /proc/sched_debug Xie XiuQi <xiexiuqi@huawei.com> - 2017-08-07 10:50 +0200
      [tip:sched/core] sched/debug: Show task state in /proc/sched_debug tip-bot for Xie XiuQi <tipbot@zytor.com> - 2017-08-10 14:20 +0200

#1705247 — [PATCH 0/2] sched/debug: show task state on /proc/sched_debug

FromXie XiuQi <xiexiuqi@huawei.com>
Date2017-08-07 10:50 +0200
Subject[PATCH 0/2] sched/debug: show task state on /proc/sched_debug
Message-ID<ubLTz-5V4-7@gated-at.bofh.it>
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

Xie XiuQi (2):
  sched/debug: show task state on /proc/sched_debug
  sched/debug: intruduce task_state_to_char helper function

 include/linux/sched.h | 13 +++++++++++++
 kernel/sched/core.c   | 15 ++++-----------
 kernel/sched/debug.c  | 10 ++++++----
 3 files changed, 23 insertions(+), 15 deletions(-)

-- 
1.8.3.1

[toc] | [next] | [standalone]


#1705258 — [PATCH 1/2] sched/debug: show task state on /proc/sched_debug

FromXie XiuQi <xiexiuqi@huawei.com>
Date2017-08-07 10:50 +0200
Subject[PATCH 1/2] sched/debug: show task state on /proc/sched_debug
Message-ID<ubLTA-5V4-33@gated-at.bofh.it>
In reply to#1705247
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

[toc] | [prev] | [next] | [standalone]


#1708527 — [tip:sched/core] sched/debug: Show task state in /proc/sched_debug

Fromtip-bot for Xie XiuQi <tipbot@zytor.com>
Date2017-08-10 14:20 +0200
Subject[tip:sched/core] sched/debug: Show task state in /proc/sched_debug
Message-ID<ucUBt-5tj-51@gated-at.bofh.it>
In reply to#1705258
Commit-ID:  e8c164954b926f06f109a42fb8595ed01275b141
Gitweb:     http://git.kernel.org/tip/e8c164954b926f06f109a42fb8595ed01275b141
Author:     Xie XiuQi <xiexiuqi@huawei.com>
AuthorDate: Mon, 7 Aug 2017 16:44:22 +0800
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Thu, 10 Aug 2017 12:18:19 +0200

sched/debug: Show task state in /proc/sched_debug

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 the runqueue and which task is sleeping.

Add task state in the 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>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: <cj.chengjian@huawei.com>
Cc: <huawei.libin@huawei.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/1502095463-160172-2-git-send-email-xiexiuqi@huawei.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 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 ac34511..d8d2ea2 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();

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web