linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V2] kernel/hung_task.c: Force console verbose before panic
@ 2018-12-13  1:51 Liu, Chuansheng
  2018-12-13 11:54 ` Petr Mladek
  2018-12-13 12:40 ` Sergey Senozhatsky
  0 siblings, 2 replies; 3+ messages in thread
From: Liu, Chuansheng @ 2018-12-13  1:51 UTC (permalink / raw)
  To: Petr Mladek, Tetsuo Handa, Sergey Senozhatsky, akpm,
	sergey.senozhatsky, rostedt, dvyukov
  Cc: linux-kernel, Liu, Chuansheng

Based on patch commit 401c636a0eeb ("kernel/hung_task.c:
show all hung tasks before panic"), we could get the
call stack of hung task.

However, if the console loglevel is not high, we still
can not see the useful panic information in practice,
and in most cases users don't set console loglevel to
high level.

This patch is to force console verbose before system
panic, so that the real useful information can be seen
in the console, instead of being like the following,
which doesn't have hung task information.

[  246.916600] INFO: task init:1 blocked for more than 120 seconds.
[  246.922320]       Tainted: G     U  W         4.19.0-quilt-2e5dc0ac-g51b6c21d76cc #1
[  246.926790] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[  246.932553] Kernel panic - not syncing: hung_task: blocked tasks
[  246.938503] CPU: 2 PID: 479 Comm: khungtaskd Tainted: G     U  W         4.19.0-quilt-2e5dc0ac-g51b6c21d76cc #1
[  246.990266] Call Trace:
[  246.991707]  dump_stack+0x4f/0x65
[  246.993710]  panic+0xde/0x231
[  246.995445]  watchdog+0x290/0x410
[  246.997390]  kthread+0x12c/0x150
[  246.999301]  ? reset_hung_task_detector+0x20/0x20
[  247.004825]  ? kthread_create_worker_on_cpu+0x70/0x70
[  247.007735]  ret_from_fork+0x35/0x40
[  247.010280] reboot: panic mode set: p,w
[  247.012619] Kernel Offset: 0x34000000 from 0xffffffff81000000 (relocation range: 0xffffffff80000000-0xffffffffbfffffff)

V1: console_verbose() is used instead of ignore_loglevel,
    suggested by Sergey.
    Tweak the function check_hung_task() suggested by
    Tetsuo to make code more readable.

V2: Petr suggests to make 2 patches:
    One is addressing console_verbose() only, which is
    this patch's aim.
    The other is about forcing sched_show_task() during
    panic, which needs more discussion yet.

Cc: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
Cc: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
Cc: Petr Mladek <pmladek@suse.com>
Signed-off-by: Chuansheng Liu <chuansheng.liu@intel.com>
---
 kernel/hung_task.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/kernel/hung_task.c b/kernel/hung_task.c
index cb8e3e8..85af0cd 100644
--- a/kernel/hung_task.c
+++ b/kernel/hung_task.c
@@ -112,8 +112,11 @@ static void check_hung_task(struct task_struct *t, unsigned long timeout)

        trace_sched_process_hang(t);

-       if (!sysctl_hung_task_warnings && !sysctl_hung_task_panic)
-               return;
+       if (sysctl_hung_task_panic) {
+               console_verbose();
+               hung_task_show_lock = true;
+               hung_task_call_panic = true;
+       }

        /*
         * Ok, the task did not get scheduled for more than 2 minutes,
@@ -135,11 +138,6 @@ static void check_hung_task(struct task_struct *t, unsigned long timeout)
        }

        touch_nmi_watchdog();
-
-       if (sysctl_hung_task_panic) {
-               hung_task_show_lock = true;
-               hung_task_call_panic = true;
-       }
 }

 /*
--
2.7.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH V2] kernel/hung_task.c: Force console verbose before panic
  2018-12-13  1:51 [PATCH V2] kernel/hung_task.c: Force console verbose before panic Liu, Chuansheng
@ 2018-12-13 11:54 ` Petr Mladek
  2018-12-13 12:40 ` Sergey Senozhatsky
  1 sibling, 0 replies; 3+ messages in thread
From: Petr Mladek @ 2018-12-13 11:54 UTC (permalink / raw)
  To: Liu, Chuansheng
  Cc: Tetsuo Handa, Sergey Senozhatsky, akpm, sergey.senozhatsky,
	rostedt, dvyukov, linux-kernel

On Thu 2018-12-13 01:51:22, Liu, Chuansheng wrote:
> Based on patch commit 401c636a0eeb ("kernel/hung_task.c:
> show all hung tasks before panic"), we could get the
> call stack of hung task.
> 
> However, if the console loglevel is not high, we still
> can not see the useful panic information in practice,
> and in most cases users don't set console loglevel to
> high level.
> 
> This patch is to force console verbose before system
> panic, so that the real useful information can be seen
> in the console, instead of being like the following,
> which doesn't have hung task information.
> 
> Signed-off-by: Chuansheng Liu <chuansheng.liu@intel.com>

Makes sense and looks good to me:

Reviewed-by: Petr Mladek <pmladek@suse.com>

Best Regards,
Petr

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH V2] kernel/hung_task.c: Force console verbose before panic
  2018-12-13  1:51 [PATCH V2] kernel/hung_task.c: Force console verbose before panic Liu, Chuansheng
  2018-12-13 11:54 ` Petr Mladek
@ 2018-12-13 12:40 ` Sergey Senozhatsky
  1 sibling, 0 replies; 3+ messages in thread
From: Sergey Senozhatsky @ 2018-12-13 12:40 UTC (permalink / raw)
  To: Liu, Chuansheng
  Cc: Petr Mladek, Tetsuo Handa, Sergey Senozhatsky, akpm,
	sergey.senozhatsky, rostedt, dvyukov, linux-kernel

On (12/13/18 01:51), Liu, Chuansheng wrote:
> V1: console_verbose() is used instead of ignore_loglevel,
>     suggested by Sergey.
>     Tweak the function check_hung_task() suggested by
>     Tetsuo to make code more readable.
> 
> V2: Petr suggests to make 2 patches:
>     One is addressing console_verbose() only, which is
>     this patch's aim.
>     The other is about forcing sched_show_task() during
>     panic, which needs more discussion yet.
> 
> Cc: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
> Cc: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
> Cc: Petr Mladek <pmladek@suse.com>
> Signed-off-by: Chuansheng Liu <chuansheng.liu@intel.com>

Reviewed-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>

	-ss

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-12-13 12:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-13  1:51 [PATCH V2] kernel/hung_task.c: Force console verbose before panic Liu, Chuansheng
2018-12-13 11:54 ` Petr Mladek
2018-12-13 12:40 ` Sergey Senozhatsky

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).