* [PATCH] android, lmk: Send SIGKILL before setting TIF_MEMDIE.
@ 2015-09-06 5:25 Tetsuo Handa
2015-09-09 21:55 ` David Rientjes
0 siblings, 1 reply; 3+ messages in thread
From: Tetsuo Handa @ 2015-09-06 5:25 UTC (permalink / raw)
To: gregkh, mhocko, linux-mm; +Cc: Tetsuo Handa
It was observed that setting TIF_MEMDIE before sending SIGKILL at
oom_kill_process() allows memory reserves to be depleted by allocations
which are not needed for terminating the OOM victim.
This patch reverts commit 6bc2b856bb7c ("staging: android: lowmemorykiller:
set TIF_MEMDIE before send kill sig"), for oom_kill_process() was updated
to send SIGKILL before setting TIF_MEMDIE.
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Acked-by: Michal Hocko <mhocko@suse.com>
---
drivers/staging/android/lowmemorykiller.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/drivers/staging/android/lowmemorykiller.c b/drivers/staging/android/lowmemorykiller.c
index 872bd60..569d12c 100644
--- a/drivers/staging/android/lowmemorykiller.c
+++ b/drivers/staging/android/lowmemorykiller.c
@@ -157,26 +157,22 @@ static unsigned long lowmem_scan(struct shrinker *s, struct shrink_control *sc)
}
if (selected) {
task_lock(selected);
- if (!selected->mm) {
- /* Already exited, cannot do mark_tsk_oom_victim() */
- task_unlock(selected);
- goto out;
- }
+ send_sig(SIGKILL, selected, 0);
/*
* FIXME: lowmemorykiller shouldn't abuse global OOM killer
* infrastructure. There is no real reason why the selected
* task should have access to the memory reserves.
*/
- mark_oom_victim(selected);
+ if (selected->mm)
+ mark_oom_victim(selected);
task_unlock(selected);
lowmem_print(1, "send sigkill to %d (%s), adj %hd, size %d\n",
selected->pid, selected->comm,
selected_oom_score_adj, selected_tasksize);
lowmem_deathpending_timeout = jiffies + HZ;
- send_sig(SIGKILL, selected, 0);
rem += selected_tasksize;
}
-out:
+
lowmem_print(4, "lowmem_scan %lu, %x, return %lu\n",
sc->nr_to_scan, sc->gfp_mask, rem);
rcu_read_unlock();
--
1.8.3.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] 3+ messages in thread
* Re: [PATCH] android, lmk: Send SIGKILL before setting TIF_MEMDIE.
2015-09-06 5:25 [PATCH] android, lmk: Send SIGKILL before setting TIF_MEMDIE Tetsuo Handa
@ 2015-09-09 21:55 ` David Rientjes
2015-09-11 13:51 ` Michal Hocko
0 siblings, 1 reply; 3+ messages in thread
From: David Rientjes @ 2015-09-09 21:55 UTC (permalink / raw)
To: Tetsuo Handa; +Cc: gregkh, mhocko, linux-mm
On Sun, 6 Sep 2015, Tetsuo Handa wrote:
> It was observed that setting TIF_MEMDIE before sending SIGKILL at
> oom_kill_process() allows memory reserves to be depleted by allocations
> which are not needed for terminating the OOM victim.
>
I don't understand what you are trying to fix. Sending a SIGKILL first
does not guarantee that it is handling that signal before accessing memory
reserves. I have no objection to the patch, but I don't think it actually
matters either way and is relatively pointless.
--
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] 3+ messages in thread
* Re: [PATCH] android, lmk: Send SIGKILL before setting TIF_MEMDIE.
2015-09-09 21:55 ` David Rientjes
@ 2015-09-11 13:51 ` Michal Hocko
0 siblings, 0 replies; 3+ messages in thread
From: Michal Hocko @ 2015-09-11 13:51 UTC (permalink / raw)
To: David Rientjes; +Cc: Tetsuo Handa, gregkh, linux-mm
On Wed 09-09-15 14:55:59, David Rientjes wrote:
> On Sun, 6 Sep 2015, Tetsuo Handa wrote:
>
> > It was observed that setting TIF_MEMDIE before sending SIGKILL at
> > oom_kill_process() allows memory reserves to be depleted by allocations
> > which are not needed for terminating the OOM victim.
> >
>
> I don't understand what you are trying to fix. Sending a SIGKILL first
> does not guarantee that it is handling that signal before accessing memory
> reserves.
Yes it doesn't guarantee that but it kicks the task from userspace so
that it cannot deplete the memory reserves from the _userspace_ under
its controll. It still can consume some amount of memory from the kernel
but that shouldn't be under control of the task.
--
Michal Hocko
SUSE Labs
--
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] 3+ messages in thread
end of thread, other threads:[~2015-09-11 13:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-06 5:25 [PATCH] android, lmk: Send SIGKILL before setting TIF_MEMDIE Tetsuo Handa
2015-09-09 21:55 ` David Rientjes
2015-09-11 13:51 ` Michal Hocko
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.