linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] exec: make de_thread() freezable
@ 2018-11-09  8:37 Chanho Min
  2018-11-09  9:21 ` Oleg Nesterov
  0 siblings, 1 reply; 3+ messages in thread
From: Chanho Min @ 2018-11-09  8:37 UTC (permalink / raw)
  To: Rafael J. Wysocki, Pavel Machek, Len Brown, Andrew Morton,
	Eric W. Biederman, Christian Brauner, Oleg Nesterov,
	Anna-Maria Gleixner, Alexander Viro
  Cc: linux-pm, linux-kernel, linux-fsdevel, Seungho Park, Inkyu Hwang,
	Donghwan Jung, Jongsung Kim, Chanho Min

Suspend fails due to the exec family of functions blocking the freezer.
The casue is that de_thread() sleeps in TASK_UNINTERRUPTIBLE waiting for
all sub-threads to die, and we have the deadlock if one of them is frozen.
In our machine, it causes freeze timeout as bellows.

Freezing of tasks failed after 20.010 seconds (1 tasks refusing to freeze, wq_busy=0):
setcpushares-ls D ffffffc00008ed70     0  5817   1483 0x0040000d
 Call trace:
[<ffffffc00008ed70>] __switch_to+0x88/0xa0
[<ffffffc000d1c30c>] __schedule+0x1bc/0x720
[<ffffffc000d1ca90>] schedule+0x40/0xa8
[<ffffffc0001cd784>] flush_old_exec+0xdc/0x640
[<ffffffc000220360>] load_elf_binary+0x2a8/0x1090
[<ffffffc0001ccff4>] search_binary_handler+0x9c/0x240
[<ffffffc00021c584>] load_script+0x20c/0x228
[<ffffffc0001ccff4>] search_binary_handler+0x9c/0x240
[<ffffffc0001ce8e0>] do_execveat_common.isra.14+0x4f8/0x6e8
[<ffffffc0001cedd0>] compat_SyS_execve+0x38/0x48
[<ffffffc00008de30>] el0_svc_naked+0x24/0x28

To fix this, make de_thread() freezable. It looks safe and works fine.

Suggested-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Chanho Min <chanho.min@lge.com>
---
 fs/exec.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/exec.c b/fs/exec.c
index 1ebf6e5..70ccfc8 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -62,6 +62,7 @@
 #include <linux/oom.h>
 #include <linux/compat.h>
 #include <linux/vmalloc.h>
+#include <linux/freezer.h>
 
 #include <linux/uaccess.h>
 #include <asm/mmu_context.h>
@@ -1083,7 +1084,7 @@ static int de_thread(struct task_struct *tsk)
 	while (sig->notify_count) {
 		__set_current_state(TASK_KILLABLE);
 		spin_unlock_irq(lock);
-		schedule();
+		freezable_schedule();
 		if (unlikely(__fatal_signal_pending(tsk)))
 			goto killed;
 		spin_lock_irq(lock);
-- 
2.1.4


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

* Re: [PATCH] exec: make de_thread() freezable
  2018-11-09  8:37 [PATCH] exec: make de_thread() freezable Chanho Min
@ 2018-11-09  9:21 ` Oleg Nesterov
  2018-11-12  2:00   ` Chanho Min
  0 siblings, 1 reply; 3+ messages in thread
From: Oleg Nesterov @ 2018-11-09  9:21 UTC (permalink / raw)
  To: Chanho Min
  Cc: Rafael J. Wysocki, Pavel Machek, Len Brown, Andrew Morton,
	Eric W. Biederman, Christian Brauner, Anna-Maria Gleixner,
	Alexander Viro, linux-pm, linux-kernel, linux-fsdevel,
	Seungho Park, Inkyu Hwang, Donghwan Jung, Jongsung Kim

On 11/09, Chanho Min wrote:
>
> @@ -1083,7 +1084,7 @@ static int de_thread(struct task_struct *tsk)
>  	while (sig->notify_count) {
>  		__set_current_state(TASK_KILLABLE);
>  		spin_unlock_irq(lock);
> -		schedule();
> +		freezable_schedule();

Thanks, but please note another schedule() in "if (!thread_group_leader(tsk))"
branch, we probably want to change it too?

Oleg.


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

* RE: [PATCH] exec: make de_thread() freezable
  2018-11-09  9:21 ` Oleg Nesterov
@ 2018-11-12  2:00   ` Chanho Min
  0 siblings, 0 replies; 3+ messages in thread
From: Chanho Min @ 2018-11-12  2:00 UTC (permalink / raw)
  To: 'Oleg Nesterov'
  Cc: 'Rafael J. Wysocki', 'Pavel Machek',
	'Len Brown', 'Andrew Morton',
	'Eric W. Biederman', 'Christian Brauner',
	'Anna-Maria Gleixner', 'Alexander Viro',
	linux-pm, linux-kernel, linux-fsdevel, 'Seungho Park',
	'Inkyu Hwang', 'Donghwan Jung',
	'Jongsung Kim'

> Thanks, but please note another schedule() in "if
> (!thread_group_leader(tsk))"
> branch, we probably want to change it too?
> 
> Oleg.
Sounds right, The thread group leader might be frozen as well.
I'll prepare v2.


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

end of thread, other threads:[~2018-11-12  2:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-09  8:37 [PATCH] exec: make de_thread() freezable Chanho Min
2018-11-09  9:21 ` Oleg Nesterov
2018-11-12  2:00   ` Chanho Min

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