From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161410AbcE3NGR (ORCPT ); Mon, 30 May 2016 09:06:17 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:36146 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161330AbcE3NGK (ORCPT ); Mon, 30 May 2016 09:06:10 -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 vforked tasks from being selected Date: Mon, 30 May 2016 15:05:54 +0200 Message-Id: <1464613556-16708-5-git-send-email-mhocko@kernel.org> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1464613556-16708-1-git-send-email-mhocko@kernel.org> References: <1464613556-16708-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 any memory. They are sharing the mm with parent until they exec into a new code. Until then it is just pinning the address space. OOM killer will kill the vforked task along with its parent but we still can end up selecting vforked task when the parent wouldn't be selected. E.g. init doing vfork to launch a task or vforked being a child of oom unkillable task with an updated oom_score_adj to be killable. Make sure to not select vforked task as an oom victim by checking vfork_done in oom_badness. Signed-off-by: Michal Hocko --- mm/oom_kill.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mm/oom_kill.c b/mm/oom_kill.c index 6bb322577fc6..92bc8c3ec97b 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 the 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; } -- 2.8.1