From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932113AbcEZMlH (ORCPT ); Thu, 26 May 2016 08:41:07 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:34035 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753262AbcEZMk2 (ORCPT ); Thu, 26 May 2016 08:40:28 -0400 From: Michal Hocko To: Cc: Tetsuo Handa , David Rientjes , Oleg Nesterov , Vladimir Davydov , Andrew Morton , LKML , Michal Hocko Subject: [PATCH 4/6] mm, oom: skip over vforked tasks Date: Thu, 26 May 2016 14:40:13 +0200 Message-Id: <1464266415-15558-5-git-send-email-mhocko@kernel.org> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1464266415-15558-1-git-send-email-mhocko@kernel.org> References: <1464266415-15558-1-git-send-email-mhocko@kernel.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Michal Hocko vforked tasks are not really sitting on memory so it doesn't matter much to kill them. Parents are waiting for vforked task killable so it is better to chose parent which is the real mm owner. Teach oom_badness to ignore all tasks which haven't passed mm_release. oom_kill_process should ignore them as well because they will drop the mm soon and they will not block oom_reaper because they cannot touch any memory. Signed-off-by: Michal Hocko --- mm/oom_kill.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/mm/oom_kill.c b/mm/oom_kill.c index eeccb4d7e7f5..d1cbaaa1a666 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c @@ -176,11 +176,13 @@ unsigned long oom_badness(struct task_struct *p, struct mem_cgroup *memcg, /* * Do not even consider tasks which are explicitly marked oom - * unkillable or have been already oom reaped. + * unkillable or have been already oom reaped or they are in + * the middle of vfork */ adj = (long)p->signal->oom_score_adj; if (adj == OOM_SCORE_ADJ_MIN || - test_bit(MMF_OOM_REAPED, &p->mm->flags)) { + test_bit(MMF_OOM_REAPED, &p->mm->flags) || + p->vfork_done) { task_unlock(p); return 0; } @@ -839,6 +841,13 @@ void oom_kill_process(struct oom_control *oc, struct task_struct *p, for_each_process(p) { if (!process_shares_mm(p, mm)) continue; + /* + * vforked tasks are ignored because they will drop the mm soon + * hopefully and even if not they will not mind being oom + * reaped because they cannot touch any memory. + */ + if (p->vfork_done) + continue; if (same_thread_group(p, victim)) continue; if (unlikely(p->flags & PF_KTHREAD) || is_global_init(p) || -- 2.8.1