* [PATCH] mm, oom_reaper: do not use siglock in try_oom_reaper
@ 2016-05-31 7:23 ` Michal Hocko
0 siblings, 0 replies; 4+ messages in thread
From: Michal Hocko @ 2016-05-31 7:23 UTC (permalink / raw)
To: Andrew Morton
Cc: Oleg Nesterov, Tetsuo Handa, David Rientjes, linux-mm, LKML,
Michal Hocko
From: Michal Hocko <mhocko@suse.com>
Oleg has noted that siglock usage in try_oom_reaper is both pointless
and dangerous. signal_group_exit can be checked lockless. The problem
is that sighand becomes NULL in __exit_signal so we can crash.
Fixes: 3ef22dfff239 ("oom, oom_reaper: try to reap tasks which skip regular OOM killer path")
Suggested-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Michal Hocko <mhocko@suse.com>
---
Hi Andrew,
Oleg has noticed this while reviewing http://lkml.kernel.org/r/20160530173505.GA25287@redhat.com
this should go in 4.7.
mm/oom_kill.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index e01cc3e2e755..25eac62c190c 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -625,8 +625,6 @@ void try_oom_reaper(struct task_struct *tsk)
if (atomic_read(&mm->mm_users) > 1) {
rcu_read_lock();
for_each_process(p) {
- bool exiting;
-
if (!process_shares_mm(p, mm))
continue;
if (fatal_signal_pending(p))
@@ -636,10 +634,7 @@ void try_oom_reaper(struct task_struct *tsk)
* If the task is exiting make sure the whole thread group
* is exiting and cannot acces mm anymore.
*/
- spin_lock_irq(&p->sighand->siglock);
- exiting = signal_group_exit(p->signal);
- spin_unlock_irq(&p->sighand->siglock);
- if (exiting)
+ if (signal_group_exit(p->signal))
continue;
/* Give up */
--
2.8.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] mm, oom_reaper: do not use siglock in try_oom_reaper
@ 2016-05-31 7:23 ` Michal Hocko
0 siblings, 0 replies; 4+ messages in thread
From: Michal Hocko @ 2016-05-31 7:23 UTC (permalink / raw)
To: Andrew Morton
Cc: Oleg Nesterov, Tetsuo Handa, David Rientjes, linux-mm, LKML,
Michal Hocko
From: Michal Hocko <mhocko@suse.com>
Oleg has noted that siglock usage in try_oom_reaper is both pointless
and dangerous. signal_group_exit can be checked lockless. The problem
is that sighand becomes NULL in __exit_signal so we can crash.
Fixes: 3ef22dfff239 ("oom, oom_reaper: try to reap tasks which skip regular OOM killer path")
Suggested-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Michal Hocko <mhocko@suse.com>
---
Hi Andrew,
Oleg has noticed this while reviewing http://lkml.kernel.org/r/20160530173505.GA25287@redhat.com
this should go in 4.7.
mm/oom_kill.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index e01cc3e2e755..25eac62c190c 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -625,8 +625,6 @@ void try_oom_reaper(struct task_struct *tsk)
if (atomic_read(&mm->mm_users) > 1) {
rcu_read_lock();
for_each_process(p) {
- bool exiting;
-
if (!process_shares_mm(p, mm))
continue;
if (fatal_signal_pending(p))
@@ -636,10 +634,7 @@ void try_oom_reaper(struct task_struct *tsk)
* If the task is exiting make sure the whole thread group
* is exiting and cannot acces mm anymore.
*/
- spin_lock_irq(&p->sighand->siglock);
- exiting = signal_group_exit(p->signal);
- spin_unlock_irq(&p->sighand->siglock);
- if (exiting)
+ if (signal_group_exit(p->signal))
continue;
/* Give up */
--
2.8.1
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] mm, oom_reaper: do not use siglock in try_oom_reaper
2016-05-31 7:23 ` Michal Hocko
@ 2016-05-31 21:25 ` Oleg Nesterov
-1 siblings, 0 replies; 4+ messages in thread
From: Oleg Nesterov @ 2016-05-31 21:25 UTC (permalink / raw)
To: Michal Hocko
Cc: Andrew Morton, Tetsuo Handa, David Rientjes, linux-mm, LKML,
Michal Hocko
On 05/31, Michal Hocko wrote:
>
> @@ -636,10 +634,7 @@ void try_oom_reaper(struct task_struct *tsk)
> * If the task is exiting make sure the whole thread group
> * is exiting and cannot acces mm anymore.
> */
> - spin_lock_irq(&p->sighand->siglock);
> - exiting = signal_group_exit(p->signal);
> - spin_unlock_irq(&p->sighand->siglock);
> - if (exiting)
> + if (signal_group_exit(p->signal))
> continue;
Yes, thanks Michal. signal_group_exit() is not really right too (coredump)
but this is not that important and you are going to rework this code anyway.
Oleg.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mm, oom_reaper: do not use siglock in try_oom_reaper
@ 2016-05-31 21:25 ` Oleg Nesterov
0 siblings, 0 replies; 4+ messages in thread
From: Oleg Nesterov @ 2016-05-31 21:25 UTC (permalink / raw)
To: Michal Hocko
Cc: Andrew Morton, Tetsuo Handa, David Rientjes, linux-mm, LKML,
Michal Hocko
On 05/31, Michal Hocko wrote:
>
> @@ -636,10 +634,7 @@ void try_oom_reaper(struct task_struct *tsk)
> * If the task is exiting make sure the whole thread group
> * is exiting and cannot acces mm anymore.
> */
> - spin_lock_irq(&p->sighand->siglock);
> - exiting = signal_group_exit(p->signal);
> - spin_unlock_irq(&p->sighand->siglock);
> - if (exiting)
> + if (signal_group_exit(p->signal))
> continue;
Yes, thanks Michal. signal_group_exit() is not really right too (coredump)
but this is not that important and you are going to rework this code anyway.
Oleg.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-05-31 21:25 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-31 7:23 [PATCH] mm, oom_reaper: do not use siglock in try_oom_reaper Michal Hocko
2016-05-31 7:23 ` Michal Hocko
2016-05-31 21:25 ` Oleg Nesterov
2016-05-31 21:25 ` Oleg Nesterov
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.