2017-08-07 08:42:01

by Xie XiuQi

[permalink] [raw]
Subject: [PATCH 0/2] sched/debug: show task state on /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 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


2017-08-07 08:41:58

by Xie XiuQi

[permalink] [raw]
Subject: [PATCH 2/2] sched/debug: intruduce task_state_to_char helper function

Now we have more than one place to get the task state,
so intruduce task_state_to_char helper to save some code.

No function changed.

Signed-off-by: Xie XiuQi <[email protected]>
---
include/linux/sched.h | 13 +++++++++++++
kernel/sched/core.c | 15 ++++-----------
kernel/sched/debug.c | 10 +++-------
3 files changed, 20 insertions(+), 18 deletions(-)

diff --git a/include/linux/sched.h b/include/linux/sched.h
index 2b69fc6..d20edc0 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1189,6 +1189,19 @@ static inline pid_t task_pgrp_nr(struct task_struct *tsk)
return task_pgrp_nr_ns(tsk, &init_pid_ns);
}

+static inline char task_state_to_char(struct task_struct *task)
+{
+ const char stat_nam[] = TASK_STATE_TO_CHAR_STR;
+ unsigned long state = task->state;
+
+ state = state ? __ffs(state) + 1 : 0;
+
+ /* Make sure the string lines up properly with the number of task states: */
+ BUILD_BUG_ON(sizeof(TASK_STATE_TO_CHAR_STR)-1 != ilog2(TASK_STATE_MAX)+1);
+
+ return state < sizeof(stat_nam) - 1 ? stat_nam[state] : '?';
+}
+
/**
* is_global_init - check if a task structure is init. Since init
* is free to have sub-threads we need to check tgid.
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 326d4f8..aa9cf40 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -5316,24 +5316,17 @@ void io_schedule(void)
return retval;
}

-static const char stat_nam[] = TASK_STATE_TO_CHAR_STR;
-
void sched_show_task(struct task_struct *p)
{
unsigned long free = 0;
int ppid;
- unsigned long state = p->state;
-
- /* Make sure the string lines up properly with the number of task states: */
- BUILD_BUG_ON(sizeof(TASK_STATE_TO_CHAR_STR)-1 != ilog2(TASK_STATE_MAX)+1);

if (!try_get_task_stack(p))
return;
- if (state)
- state = __ffs(state) + 1;
- printk(KERN_INFO "%-15.15s %c", p->comm,
- state < sizeof(stat_nam) - 1 ? stat_nam[state] : '?');
- if (state == TASK_RUNNING)
+
+ printk(KERN_INFO "%-15.15s %c", p->comm, task_state_to_char(p);
+
+ if (p->state == TASK_RUNNING)
printk(KERN_CONT " running task ");
#ifdef CONFIG_DEBUG_STACK_USAGE
free = stack_not_used(p);
diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
index 60f7e20..1447266 100644
--- a/kernel/sched/debug.c
+++ b/kernel/sched/debug.c
@@ -426,14 +426,10 @@ static char *task_group_path(struct task_group *tg)
static void
print_task(struct seq_file *m, struct rq *rq, struct task_struct *p)
{
- unsigned long state;
-
- if (rq->curr == p) {
+ 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] : '?');
- }
+ else
+ SEQ_printf(m, " %c", task_sate_to_char(p));

SEQ_printf(m, "%15s %5d %9Ld.%06ld %9Ld %5d ",
p->comm, task_pid_nr(p),
--
1.8.3.1

2017-08-07 08:41:59

by Xie XiuQi

[permalink] [raw]
Subject: [PATCH 1/2] sched/debug: show task state on /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 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 <[email protected]>
---
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

2017-08-08 06:42:23

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH 2/2] sched/debug: intruduce task_state_to_char helper function

Hi Xie,

[auto build test ERROR on tip/sched/core]
[also build test ERROR on v4.13-rc4 next-20170807]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Xie-XiuQi/sched-debug-show-task-state-on-proc-sched_debug/20170808-135825
config: i386-randconfig-x019-201732 (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
# save the attached .config to linux build tree
make ARCH=i386

All errors (new ones prefixed by >>):

kernel/sched/core.c: In function 'sched_show_task':
>> kernel/sched/core.c:5114:64: error: expected ')' before ';' token
printk(KERN_INFO "%-15.15s %c", p->comm, task_state_to_char(p);
^
>> kernel/sched/core.c:5133:1: error: expected ';' before '}' token
}
^
kernel/sched/core.c:5109:6: warning: unused variable 'ppid' [-Wunused-variable]
int ppid;
^~~~
kernel/sched/core.c:5108:16: warning: unused variable 'free' [-Wunused-variable]
unsigned long free = 0;
^~~~
In file included from arch/x86/include/asm/current.h:4:0,
from include/linux/sched.h:11,
from kernel/sched/core.c:8:
kernel/sched/core.c: At top level:
include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'strcpy' which is not static
______f = { \
^
include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
#define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
^~~~~~~~~~
include/linux/string.h:390:2: note: in expansion of macro 'if'
if (p_size == (size_t)-1 && q_size == (size_t)-1)
^~
include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'kmemdup' which is not static
______f = { \
^
include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
#define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
^~~~~~~~~~
include/linux/string.h:380:2: note: in expansion of macro 'if'
if (p_size < size)
^~
include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'kmemdup' which is not static
______f = { \
^
include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
#define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
^~~~~~~~~~
include/linux/string.h:378:2: note: in expansion of macro 'if'
if (__builtin_constant_p(size) && p_size < size)
^~
include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'memchr_inv' which is not static
______f = { \
^
include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
#define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
^~~~~~~~~~
include/linux/string.h:369:2: note: in expansion of macro 'if'
if (p_size < size)
^~
include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'memchr_inv' which is not static
______f = { \
^
include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
#define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
^~~~~~~~~~
include/linux/string.h:367:2: note: in expansion of macro 'if'
if (__builtin_constant_p(size) && p_size < size)
^~
include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'memchr' which is not static
______f = { \
^
include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
#define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
^~~~~~~~~~
include/linux/string.h:358:2: note: in expansion of macro 'if'
if (p_size < size)
^~
include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'memchr' which is not static
______f = { \
^
include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
#define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
^~~~~~~~~~
include/linux/string.h:356:2: note: in expansion of macro 'if'
if (__builtin_constant_p(size) && p_size < size)
^~
include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'memcmp' which is not static
______f = { \
^
include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
#define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
^~~~~~~~~~
include/linux/string.h:348:2: note: in expansion of macro 'if'
if (p_size < size || q_size < size)
^~
include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'memcmp' which is not static
______f = { \
^
include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
#define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
^~~~~~~~~~
include/linux/string.h:345:3: note: in expansion of macro 'if'
if (q_size < size)
^~
include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'memcmp' which is not static
______f = { \
^
include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
#define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
^~~~~~~~~~
include/linux/string.h:343:3: note: in expansion of macro 'if'
--
kernel/sched/debug.c: In function 'print_task':
>> kernel/sched/debug.c:432:24: error: implicit declaration of function 'task_sate_to_char' [-Werror=implicit-function-declaration]
SEQ_printf(m, " %c", task_sate_to_char(p));
^
kernel/sched/debug.c:33:17: note: in definition of macro 'SEQ_printf'
seq_printf(m, x); \
^
In file included from include/uapi/linux/stddef.h:1:0,
from include/linux/stddef.h:4,
from include/uapi/linux/posix_types.h:4,
from include/uapi/linux/types.h:13,
from include/linux/types.h:5,
from include/linux/proc_fs.h:7,
from kernel/sched/debug.c:13:
kernel/sched/debug.c: At top level:
include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'strcpy' which is not static
______f = { \
^
include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
#define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
^~~~~~~~~~
include/linux/string.h:390:2: note: in expansion of macro 'if'
if (p_size == (size_t)-1 && q_size == (size_t)-1)
^~
include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'kmemdup' which is not static
______f = { \
^
include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
#define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
^~~~~~~~~~
include/linux/string.h:380:2: note: in expansion of macro 'if'
if (p_size < size)
^~
include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'kmemdup' which is not static
______f = { \
^
include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
#define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
^~~~~~~~~~
include/linux/string.h:378:2: note: in expansion of macro 'if'
if (__builtin_constant_p(size) && p_size < size)
^~
include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'memchr_inv' which is not static
______f = { \
^
include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
#define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
^~~~~~~~~~
include/linux/string.h:369:2: note: in expansion of macro 'if'
if (p_size < size)
^~
include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'memchr_inv' which is not static
______f = { \
^
include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
#define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
^~~~~~~~~~
include/linux/string.h:367:2: note: in expansion of macro 'if'
if (__builtin_constant_p(size) && p_size < size)
^~
include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'memchr' which is not static
______f = { \
^
include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
#define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
^~~~~~~~~~
include/linux/string.h:358:2: note: in expansion of macro 'if'
if (p_size < size)
^~
include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'memchr' which is not static
______f = { \
^
include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
#define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
^~~~~~~~~~
include/linux/string.h:356:2: note: in expansion of macro 'if'
if (__builtin_constant_p(size) && p_size < size)
^~
include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'memcmp' which is not static
______f = { \
^
include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
#define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
^~~~~~~~~~
include/linux/string.h:348:2: note: in expansion of macro 'if'
if (p_size < size || q_size < size)
^~
include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'memcmp' which is not static
______f = { \
^
include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
#define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
^~~~~~~~~~
include/linux/string.h:345:3: note: in expansion of macro 'if'
if (q_size < size)
^~
include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'memcmp' which is not static
______f = { \
^
include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
#define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
^~~~~~~~~~

vim +5114 kernel/sched/core.c

5105
5106 void sched_show_task(struct task_struct *p)
5107 {
5108 unsigned long free = 0;
5109 int ppid;
5110
5111 if (!try_get_task_stack(p))
5112 return;
5113
> 5114 printk(KERN_INFO "%-15.15s %c", p->comm, task_state_to_char(p);
5115
5116 if (p->state == TASK_RUNNING)
5117 printk(KERN_CONT " running task ");
5118 #ifdef CONFIG_DEBUG_STACK_USAGE
5119 free = stack_not_used(p);
5120 #endif
5121 ppid = 0;
5122 rcu_read_lock();
5123 if (pid_alive(p))
5124 ppid = task_pid_nr(rcu_dereference(p->real_parent));
5125 rcu_read_unlock();
5126 printk(KERN_CONT "%5lu %5d %6d 0x%08lx\n", free,
5127 task_pid_nr(p), ppid,
5128 (unsigned long)task_thread_info(p)->flags);
5129
5130 print_worker_info(KERN_INFO, p);
5131 show_stack(p, NULL);
5132 put_task_stack(p);
> 5133 }
5134

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation


Attachments:
(No filename) (11.80 kB)
.config.gz (27.34 kB)
Download all attachments

2017-08-08 08:44:13

by Xie XiuQi

[permalink] [raw]
Subject: Re: [PATCH 2/2] sched/debug: intruduce task_state_to_char helper function

Hi,

On 2017/8/8 14:42, kbuild test robot wrote:
> Hi Xie,
>
> [auto build test ERROR on tip/sched/core]
> [also build test ERROR on v4.13-rc4 next-20170807]
> [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

Thanks for your testing, I'll fix it in v2.

--
Xie XiuQi

>
> url: https://github.com/0day-ci/linux/commits/Xie-XiuQi/sched-debug-show-task-state-on-proc-sched_debug/20170808-135825
> config: i386-randconfig-x019-201732 (attached as .config)
> compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
> reproduce:
> # save the attached .config to linux build tree
> make ARCH=i386
>
> All errors (new ones prefixed by >>):
>
> kernel/sched/core.c: In function 'sched_show_task':
>>> kernel/sched/core.c:5114:64: error: expected ')' before ';' token
> printk(KERN_INFO "%-15.15s %c", p->comm, task_state_to_char(p);
> ^
>>> kernel/sched/core.c:5133:1: error: expected ';' before '}' token
> }
> ^
> kernel/sched/core.c:5109:6: warning: unused variable 'ppid' [-Wunused-variable]
> int ppid;
> ^~~~
> kernel/sched/core.c:5108:16: warning: unused variable 'free' [-Wunused-variable]
> unsigned long free = 0;
> ^~~~
> In file included from arch/x86/include/asm/current.h:4:0,
> from include/linux/sched.h:11,
> from kernel/sched/core.c:8:
> kernel/sched/core.c: At top level:
> include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'strcpy' which is not static
> ______f = { \
> ^
> include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
> #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
> ^~~~~~~~~~
> include/linux/string.h:390:2: note: in expansion of macro 'if'
> if (p_size == (size_t)-1 && q_size == (size_t)-1)
> ^~
> include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'kmemdup' which is not static
> ______f = { \
> ^
> include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
> #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
> ^~~~~~~~~~
> include/linux/string.h:380:2: note: in expansion of macro 'if'
> if (p_size < size)
> ^~
> include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'kmemdup' which is not static
> ______f = { \
> ^
> include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
> #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
> ^~~~~~~~~~
> include/linux/string.h:378:2: note: in expansion of macro 'if'
> if (__builtin_constant_p(size) && p_size < size)
> ^~
> include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'memchr_inv' which is not static
> ______f = { \
> ^
> include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
> #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
> ^~~~~~~~~~
> include/linux/string.h:369:2: note: in expansion of macro 'if'
> if (p_size < size)
> ^~
> include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'memchr_inv' which is not static
> ______f = { \
> ^
> include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
> #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
> ^~~~~~~~~~
> include/linux/string.h:367:2: note: in expansion of macro 'if'
> if (__builtin_constant_p(size) && p_size < size)
> ^~
> include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'memchr' which is not static
> ______f = { \
> ^
> include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
> #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
> ^~~~~~~~~~
> include/linux/string.h:358:2: note: in expansion of macro 'if'
> if (p_size < size)
> ^~
> include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'memchr' which is not static
> ______f = { \
> ^
> include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
> #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
> ^~~~~~~~~~
> include/linux/string.h:356:2: note: in expansion of macro 'if'
> if (__builtin_constant_p(size) && p_size < size)
> ^~
> include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'memcmp' which is not static
> ______f = { \
> ^
> include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
> #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
> ^~~~~~~~~~
> include/linux/string.h:348:2: note: in expansion of macro 'if'
> if (p_size < size || q_size < size)
> ^~
> include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'memcmp' which is not static
> ______f = { \
> ^
> include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
> #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
> ^~~~~~~~~~
> include/linux/string.h:345:3: note: in expansion of macro 'if'
> if (q_size < size)
> ^~
> include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'memcmp' which is not static
> ______f = { \
> ^
> include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
> #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
> ^~~~~~~~~~
> include/linux/string.h:343:3: note: in expansion of macro 'if'
> --
> kernel/sched/debug.c: In function 'print_task':
>>> kernel/sched/debug.c:432:24: error: implicit declaration of function 'task_sate_to_char' [-Werror=implicit-function-declaration]
> SEQ_printf(m, " %c", task_sate_to_char(p));
> ^
> kernel/sched/debug.c:33:17: note: in definition of macro 'SEQ_printf'
> seq_printf(m, x); \
> ^
> In file included from include/uapi/linux/stddef.h:1:0,
> from include/linux/stddef.h:4,
> from include/uapi/linux/posix_types.h:4,
> from include/uapi/linux/types.h:13,
> from include/linux/types.h:5,
> from include/linux/proc_fs.h:7,
> from kernel/sched/debug.c:13:
> kernel/sched/debug.c: At top level:
> include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'strcpy' which is not static
> ______f = { \
> ^
> include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
> #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
> ^~~~~~~~~~
> include/linux/string.h:390:2: note: in expansion of macro 'if'
> if (p_size == (size_t)-1 && q_size == (size_t)-1)
> ^~
> include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'kmemdup' which is not static
> ______f = { \
> ^
> include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
> #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
> ^~~~~~~~~~
> include/linux/string.h:380:2: note: in expansion of macro 'if'
> if (p_size < size)
> ^~
> include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'kmemdup' which is not static
> ______f = { \
> ^
> include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
> #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
> ^~~~~~~~~~
> include/linux/string.h:378:2: note: in expansion of macro 'if'
> if (__builtin_constant_p(size) && p_size < size)
> ^~
> include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'memchr_inv' which is not static
> ______f = { \
> ^
> include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
> #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
> ^~~~~~~~~~
> include/linux/string.h:369:2: note: in expansion of macro 'if'
> if (p_size < size)
> ^~
> include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'memchr_inv' which is not static
> ______f = { \
> ^
> include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
> #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
> ^~~~~~~~~~
> include/linux/string.h:367:2: note: in expansion of macro 'if'
> if (__builtin_constant_p(size) && p_size < size)
> ^~
> include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'memchr' which is not static
> ______f = { \
> ^
> include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
> #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
> ^~~~~~~~~~
> include/linux/string.h:358:2: note: in expansion of macro 'if'
> if (p_size < size)
> ^~
> include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'memchr' which is not static
> ______f = { \
> ^
> include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
> #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
> ^~~~~~~~~~
> include/linux/string.h:356:2: note: in expansion of macro 'if'
> if (__builtin_constant_p(size) && p_size < size)
> ^~
> include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'memcmp' which is not static
> ______f = { \
> ^
> include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
> #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
> ^~~~~~~~~~
> include/linux/string.h:348:2: note: in expansion of macro 'if'
> if (p_size < size || q_size < size)
> ^~
> include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'memcmp' which is not static
> ______f = { \
> ^
> include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
> #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
> ^~~~~~~~~~
> include/linux/string.h:345:3: note: in expansion of macro 'if'
> if (q_size < size)
> ^~
> include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'memcmp' which is not static
> ______f = { \
> ^
> include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
> #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
> ^~~~~~~~~~
>
> vim +5114 kernel/sched/core.c
>
> 5105
> 5106 void sched_show_task(struct task_struct *p)
> 5107 {
> 5108 unsigned long free = 0;
> 5109 int ppid;
> 5110
> 5111 if (!try_get_task_stack(p))
> 5112 return;
> 5113
>> 5114 printk(KERN_INFO "%-15.15s %c", p->comm, task_state_to_char(p);
> 5115
> 5116 if (p->state == TASK_RUNNING)
> 5117 printk(KERN_CONT " running task ");
> 5118 #ifdef CONFIG_DEBUG_STACK_USAGE
> 5119 free = stack_not_used(p);
> 5120 #endif
> 5121 ppid = 0;
> 5122 rcu_read_lock();
> 5123 if (pid_alive(p))
> 5124 ppid = task_pid_nr(rcu_dereference(p->real_parent));
> 5125 rcu_read_unlock();
> 5126 printk(KERN_CONT "%5lu %5d %6d 0x%08lx\n", free,
> 5127 task_pid_nr(p), ppid,
> 5128 (unsigned long)task_thread_info(p)->flags);
> 5129
> 5130 print_worker_info(KERN_INFO, p);
> 5131 show_stack(p, NULL);
> 5132 put_task_stack(p);
>> 5133 }
> 5134
>
> ---
> 0-DAY kernel test infrastructure Open Source Technology Center
> https://lists.01.org/pipermail/kbuild-all Intel Corporation
>

--
Thanks,
Xie XiuQi

2017-08-08 17:28:28

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH 2/2] sched/debug: intruduce task_state_to_char helper function

Hi Xie,

[auto build test ERROR on tip/sched/core]
[also build test ERROR on v4.13-rc4 next-20170808]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Xie-XiuQi/sched-debug-show-task-state-on-proc-sched_debug/20170808-135825
config: x86_64-randconfig-ws0-08082012 (attached as .config)
compiler: gcc-4.8 (Debian 4.8.4-1) 4.8.4
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64

All error/warnings (new ones prefixed by >>):

In file included from include/uapi/linux/stddef.h:1:0,
from include/linux/stddef.h:4,
from include/uapi/linux/posix_types.h:4,
from include/uapi/linux/types.h:13,
from include/linux/types.h:5,
from include/linux/proc_fs.h:7,
from kernel/sched/debug.c:13:
kernel/sched/debug.c: In function 'print_task':
>> include/linux/compiler.h:159:17: error: implicit declaration of function 'task_sate_to_char' [-Werror=implicit-function-declaration]
static struct ftrace_branch_data \
^
include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
#define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
^
>> kernel/sched/debug.c:32:2: note: in expansion of macro 'if'
if (m) \
^
>> kernel/sched/debug.c:432:3: note: in expansion of macro 'SEQ_printf'
SEQ_printf(m, " %c", task_sate_to_char(p));
^
cc1: some warnings being treated as errors
--
In file included from include/uapi/linux/stddef.h:1:0,
from include/linux/stddef.h:4,
from include/uapi/linux/posix_types.h:4,
from include/uapi/linux/types.h:13,
from include/linux/types.h:5,
from include/linux/proc_fs.h:7,
from kernel//sched/debug.c:13:
kernel//sched/debug.c: In function 'print_task':
>> include/linux/compiler.h:159:17: error: implicit declaration of function 'task_sate_to_char' [-Werror=implicit-function-declaration]
static struct ftrace_branch_data \
^
include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
#define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
^
kernel//sched/debug.c:32:2: note: in expansion of macro 'if'
if (m) \
^
kernel//sched/debug.c:432:3: note: in expansion of macro 'SEQ_printf'
SEQ_printf(m, " %c", task_sate_to_char(p));
^
cc1: some warnings being treated as errors

vim +/task_sate_to_char +159 include/linux/compiler.h

2bcd521a Steven Rostedt 2008-11-21 148
2bcd521a Steven Rostedt 2008-11-21 149 #ifdef CONFIG_PROFILE_ALL_BRANCHES
2bcd521a Steven Rostedt 2008-11-21 150 /*
2bcd521a Steven Rostedt 2008-11-21 151 * "Define 'is'", Bill Clinton
2bcd521a Steven Rostedt 2008-11-21 152 * "Define 'if'", Steven Rostedt
2bcd521a Steven Rostedt 2008-11-21 153 */
ab3c9c68 Linus Torvalds 2009-04-07 154 #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
ab3c9c68 Linus Torvalds 2009-04-07 155 #define __trace_if(cond) \
b33c8ff4 Arnd Bergmann 2016-02-12 156 if (__builtin_constant_p(!!(cond)) ? !!(cond) : \
2bcd521a Steven Rostedt 2008-11-21 157 ({ \
2bcd521a Steven Rostedt 2008-11-21 158 int ______r; \
2bcd521a Steven Rostedt 2008-11-21 @159 static struct ftrace_branch_data \
2bcd521a Steven Rostedt 2008-11-21 160 __attribute__((__aligned__(4))) \
2bcd521a Steven Rostedt 2008-11-21 161 __attribute__((section("_ftrace_branch"))) \
2bcd521a Steven Rostedt 2008-11-21 162 ______f = { \
2bcd521a Steven Rostedt 2008-11-21 163 .func = __func__, \
2bcd521a Steven Rostedt 2008-11-21 164 .file = __FILE__, \
2bcd521a Steven Rostedt 2008-11-21 165 .line = __LINE__, \
2bcd521a Steven Rostedt 2008-11-21 166 }; \
2bcd521a Steven Rostedt 2008-11-21 167 ______r = !!(cond); \
97e7e4f3 Witold Baryluk 2009-03-17 168 ______f.miss_hit[______r]++; \
2bcd521a Steven Rostedt 2008-11-21 169 ______r; \
2bcd521a Steven Rostedt 2008-11-21 170 }))
2bcd521a Steven Rostedt 2008-11-21 171 #endif /* CONFIG_PROFILE_ALL_BRANCHES */
2bcd521a Steven Rostedt 2008-11-21 172

:::::: The code at line 159 was first introduced by commit
:::::: 2bcd521a684cc94befbe2ce7d5b613c841b0d304 trace: profile all if conditionals

:::::: TO: Steven Rostedt <[email protected]>
:::::: CC: Ingo Molnar <[email protected]>

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation


Attachments:
(No filename) (4.71 kB)
.config.gz (29.32 kB)
Download all attachments

2017-08-09 01:16:57

by Xie XiuQi

[permalink] [raw]
Subject: Re: [PATCH 2/2] sched/debug: intruduce task_state_to_char helper function

Hi,

I complied patch 2 incomplete, I'll fix it soon.

--
Xie XiuQi

On 2017/8/8 14:42, kbuild test robot wrote:
> Hi Xie,
>
> [auto build test ERROR on tip/sched/core]
> [also build test ERROR on v4.13-rc4 next-20170807]
> [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
>
> url: https://github.com/0day-ci/linux/commits/Xie-XiuQi/sched-debug-show-task-state-on-proc-sched_debug/20170808-135825
> config: i386-randconfig-x019-201732 (attached as .config)
> compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
> reproduce:
> # save the attached .config to linux build tree
> make ARCH=i386
>
> All errors (new ones prefixed by >>):
>
> kernel/sched/core.c: In function 'sched_show_task':
>>> kernel/sched/core.c:5114:64: error: expected ')' before ';' token
> printk(KERN_INFO "%-15.15s %c", p->comm, task_state_to_char(p);
> ^
>>> kernel/sched/core.c:5133:1: error: expected ';' before '}' token
> }
> ^
> kernel/sched/core.c:5109:6: warning: unused variable 'ppid' [-Wunused-variable]
> int ppid;
> ^~~~
> kernel/sched/core.c:5108:16: warning: unused variable 'free' [-Wunused-variable]
> unsigned long free = 0;
> ^~~~
> In file included from arch/x86/include/asm/current.h:4:0,
> from include/linux/sched.h:11,
> from kernel/sched/core.c:8:
> kernel/sched/core.c: At top level:
> include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'strcpy' which is not static
> ______f = { \
> ^
> include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
> #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
> ^~~~~~~~~~
> include/linux/string.h:390:2: note: in expansion of macro 'if'
> if (p_size == (size_t)-1 && q_size == (size_t)-1)
> ^~
> include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'kmemdup' which is not static
> ______f = { \
> ^
> include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
> #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
> ^~~~~~~~~~
> include/linux/string.h:380:2: note: in expansion of macro 'if'
> if (p_size < size)
> ^~
> include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'kmemdup' which is not static
> ______f = { \
> ^
> include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
> #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
> ^~~~~~~~~~
> include/linux/string.h:378:2: note: in expansion of macro 'if'
> if (__builtin_constant_p(size) && p_size < size)
> ^~
> include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'memchr_inv' which is not static
> ______f = { \
> ^
> include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
> #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
> ^~~~~~~~~~
> include/linux/string.h:369:2: note: in expansion of macro 'if'
> if (p_size < size)
> ^~
> include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'memchr_inv' which is not static
> ______f = { \
> ^
> include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
> #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
> ^~~~~~~~~~
> include/linux/string.h:367:2: note: in expansion of macro 'if'
> if (__builtin_constant_p(size) && p_size < size)
> ^~
> include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'memchr' which is not static
> ______f = { \
> ^
> include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
> #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
> ^~~~~~~~~~
> include/linux/string.h:358:2: note: in expansion of macro 'if'
> if (p_size < size)
> ^~
> include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'memchr' which is not static
> ______f = { \
> ^
> include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
> #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
> ^~~~~~~~~~
> include/linux/string.h:356:2: note: in expansion of macro 'if'
> if (__builtin_constant_p(size) && p_size < size)
> ^~
> include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'memcmp' which is not static
> ______f = { \
> ^
> include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
> #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
> ^~~~~~~~~~
> include/linux/string.h:348:2: note: in expansion of macro 'if'
> if (p_size < size || q_size < size)
> ^~
> include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'memcmp' which is not static
> ______f = { \
> ^
> include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
> #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
> ^~~~~~~~~~
> include/linux/string.h:345:3: note: in expansion of macro 'if'
> if (q_size < size)
> ^~
> include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'memcmp' which is not static
> ______f = { \
> ^
> include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
> #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
> ^~~~~~~~~~
> include/linux/string.h:343:3: note: in expansion of macro 'if'
> --
> kernel/sched/debug.c: In function 'print_task':
>>> kernel/sched/debug.c:432:24: error: implicit declaration of function 'task_sate_to_char' [-Werror=implicit-function-declaration]
> SEQ_printf(m, " %c", task_sate_to_char(p));
> ^
> kernel/sched/debug.c:33:17: note: in definition of macro 'SEQ_printf'
> seq_printf(m, x); \
> ^
> In file included from include/uapi/linux/stddef.h:1:0,
> from include/linux/stddef.h:4,
> from include/uapi/linux/posix_types.h:4,
> from include/uapi/linux/types.h:13,
> from include/linux/types.h:5,
> from include/linux/proc_fs.h:7,
> from kernel/sched/debug.c:13:
> kernel/sched/debug.c: At top level:
> include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'strcpy' which is not static
> ______f = { \
> ^
> include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
> #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
> ^~~~~~~~~~
> include/linux/string.h:390:2: note: in expansion of macro 'if'
> if (p_size == (size_t)-1 && q_size == (size_t)-1)
> ^~
> include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'kmemdup' which is not static
> ______f = { \
> ^
> include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
> #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
> ^~~~~~~~~~
> include/linux/string.h:380:2: note: in expansion of macro 'if'
> if (p_size < size)
> ^~
> include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'kmemdup' which is not static
> ______f = { \
> ^
> include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
> #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
> ^~~~~~~~~~
> include/linux/string.h:378:2: note: in expansion of macro 'if'
> if (__builtin_constant_p(size) && p_size < size)
> ^~
> include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'memchr_inv' which is not static
> ______f = { \
> ^
> include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
> #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
> ^~~~~~~~~~
> include/linux/string.h:369:2: note: in expansion of macro 'if'
> if (p_size < size)
> ^~
> include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'memchr_inv' which is not static
> ______f = { \
> ^
> include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
> #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
> ^~~~~~~~~~
> include/linux/string.h:367:2: note: in expansion of macro 'if'
> if (__builtin_constant_p(size) && p_size < size)
> ^~
> include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'memchr' which is not static
> ______f = { \
> ^
> include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
> #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
> ^~~~~~~~~~
> include/linux/string.h:358:2: note: in expansion of macro 'if'
> if (p_size < size)
> ^~
> include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'memchr' which is not static
> ______f = { \
> ^
> include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
> #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
> ^~~~~~~~~~
> include/linux/string.h:356:2: note: in expansion of macro 'if'
> if (__builtin_constant_p(size) && p_size < size)
> ^~
> include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'memcmp' which is not static
> ______f = { \
> ^
> include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
> #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
> ^~~~~~~~~~
> include/linux/string.h:348:2: note: in expansion of macro 'if'
> if (p_size < size || q_size < size)
> ^~
> include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'memcmp' which is not static
> ______f = { \
> ^
> include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
> #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
> ^~~~~~~~~~
> include/linux/string.h:345:3: note: in expansion of macro 'if'
> if (q_size < size)
> ^~
> include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'memcmp' which is not static
> ______f = { \
> ^
> include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
> #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
> ^~~~~~~~~~
>
> vim +5114 kernel/sched/core.c
>
> 5105
> 5106 void sched_show_task(struct task_struct *p)
> 5107 {
> 5108 unsigned long free = 0;
> 5109 int ppid;
> 5110
> 5111 if (!try_get_task_stack(p))
> 5112 return;
> 5113
>> 5114 printk(KERN_INFO "%-15.15s %c", p->comm, task_state_to_char(p);
> 5115
> 5116 if (p->state == TASK_RUNNING)
> 5117 printk(KERN_CONT " running task ");
> 5118 #ifdef CONFIG_DEBUG_STACK_USAGE
> 5119 free = stack_not_used(p);
> 5120 #endif
> 5121 ppid = 0;
> 5122 rcu_read_lock();
> 5123 if (pid_alive(p))
> 5124 ppid = task_pid_nr(rcu_dereference(p->real_parent));
> 5125 rcu_read_unlock();
> 5126 printk(KERN_CONT "%5lu %5d %6d 0x%08lx\n", free,
> 5127 task_pid_nr(p), ppid,
> 5128 (unsigned long)task_thread_info(p)->flags);
> 5129
> 5130 print_worker_info(KERN_INFO, p);
> 5131 show_stack(p, NULL);
> 5132 put_task_stack(p);
>> 5133 }
> 5134
>
> ---
> 0-DAY kernel test infrastructure Open Source Technology Center
> https://lists.01.org/pipermail/kbuild-all Intel Corporation
>

--
Thanks,
Xie XiuQi

Subject: [tip:sched/core] sched/debug: Show task state in /proc/sched_debug

Commit-ID: e8c164954b926f06f109a42fb8595ed01275b141
Gitweb: http://git.kernel.org/tip/e8c164954b926f06f109a42fb8595ed01275b141
Author: Xie XiuQi <[email protected]>
AuthorDate: Mon, 7 Aug 2017 16:44:22 +0800
Committer: Ingo Molnar <[email protected]>
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 <[email protected]>
Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Cc: <[email protected]>
Cc: <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
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();

Subject: [tip:sched/core] sched/debug: Intruduce task_state_to_char() helper function

Commit-ID: 20435d84e5f2041c64c792399ab6f2948a2c2252
Gitweb: http://git.kernel.org/tip/20435d84e5f2041c64c792399ab6f2948a2c2252
Author: Xie XiuQi <[email protected]>
AuthorDate: Mon, 7 Aug 2017 16:44:23 +0800
Committer: Ingo Molnar <[email protected]>
CommitDate: Thu, 10 Aug 2017 12:18:20 +0200

sched/debug: Intruduce task_state_to_char() helper function

Now that we have more than one place to get the task state,
intruduce the task_state_to_char() helper function to save some code.

No functionality changed.

Signed-off-by: Xie XiuQi <[email protected]>
Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Cc: <[email protected]>
Cc: <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
include/linux/sched.h | 13 +++++++++++++
kernel/sched/core.c | 15 ++++-----------
kernel/sched/debug.c | 10 +++-------
3 files changed, 20 insertions(+), 18 deletions(-)

diff --git a/include/linux/sched.h b/include/linux/sched.h
index 8337e2d..c28b182 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1229,6 +1229,19 @@ static inline pid_t task_pgrp_nr(struct task_struct *tsk)
return task_pgrp_nr_ns(tsk, &init_pid_ns);
}

+static inline char task_state_to_char(struct task_struct *task)
+{
+ const char stat_nam[] = TASK_STATE_TO_CHAR_STR;
+ unsigned long state = task->state;
+
+ state = state ? __ffs(state) + 1 : 0;
+
+ /* Make sure the string lines up properly with the number of task states: */
+ BUILD_BUG_ON(sizeof(TASK_STATE_TO_CHAR_STR)-1 != ilog2(TASK_STATE_MAX)+1);
+
+ return state < sizeof(stat_nam) - 1 ? stat_nam[state] : '?';
+}
+
/**
* is_global_init - check if a task structure is init. Since init
* is free to have sub-threads we need to check tgid.
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 6d91c10..f9f9948 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -5103,24 +5103,17 @@ out_unlock:
return retval;
}

-static const char stat_nam[] = TASK_STATE_TO_CHAR_STR;
-
void sched_show_task(struct task_struct *p)
{
unsigned long free = 0;
int ppid;
- unsigned long state = p->state;
-
- /* Make sure the string lines up properly with the number of task states: */
- BUILD_BUG_ON(sizeof(TASK_STATE_TO_CHAR_STR)-1 != ilog2(TASK_STATE_MAX)+1);

if (!try_get_task_stack(p))
return;
- if (state)
- state = __ffs(state) + 1;
- printk(KERN_INFO "%-15.15s %c", p->comm,
- state < sizeof(stat_nam) - 1 ? stat_nam[state] : '?');
- if (state == TASK_RUNNING)
+
+ printk(KERN_INFO "%-15.15s %c", p->comm, task_state_to_char(p));
+
+ if (p->state == TASK_RUNNING)
printk(KERN_CONT " running task ");
#ifdef CONFIG_DEBUG_STACK_USAGE
free = stack_not_used(p);
diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
index d8d2ea2..cfd84f7 100644
--- a/kernel/sched/debug.c
+++ b/kernel/sched/debug.c
@@ -426,14 +426,10 @@ 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)
{
- unsigned long state;
-
- if (rq->curr == p) {
+ 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] : '?');
- }
+ else
+ SEQ_printf(m, " %c", task_state_to_char(p));

SEQ_printf(m, "%15s %5d %9Ld.%06ld %9Ld %5d ",
p->comm, task_pid_nr(p),