From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753447Ab0DBSem (ORCPT ); Fri, 2 Apr 2010 14:34:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38718 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752614Ab0DBSe1 (ORCPT ); Fri, 2 Apr 2010 14:34:27 -0400 Date: Fri, 2 Apr 2010 20:32:16 +0200 From: Oleg Nesterov To: David Rientjes , Andrew Morton Cc: anfei , KOSAKI Motohiro , nishimura@mxp.nes.nec.co.jp, KAMEZAWA Hiroyuki , Mel Gorman , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH -mm 2/4] oom: select_bad_process: PF_EXITING check should take ->mm into account Message-ID: <20100402183216.GC31723@redhat.com> References: <20100330154659.GA12416@redhat.com> <20100331175836.GA11635@redhat.com> <20100331204718.GD11635@redhat.com> <20100401135927.GA12460@redhat.com> <20100402111406.GA4432@redhat.com> <20100402183057.GA31723@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20100402183057.GA31723@redhat.com> User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org select_bad_process() checks PF_EXITING to detect the task which is going to release its memory, but the logic is very wrong. - a single process P with the dead group leader disables select_bad_process() completely, it will always return ERR_PTR() while P can live forever - if the PF_EXITING task has already released its ->mm it doesn't make sense to expect it is goiing to free more memory (except task_struct/etc) Change the code to ignore the PF_EXITING tasks without ->mm. Signed-off-by: Oleg Nesterov --- mm/oom_kill.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- MM/mm/oom_kill.c~2_FIX_PF_EXITING 2010-04-02 18:51:05.000000000 +0200 +++ MM/mm/oom_kill.c 2010-04-02 18:58:37.000000000 +0200 @@ -322,7 +322,7 @@ static struct task_struct *select_bad_pr * the process of exiting and releasing its resources. * Otherwise we could get an easy OOM deadlock. */ - if (p->flags & PF_EXITING) { + if ((p->flags & PF_EXITING) && p->mm) { if (p != current) return ERR_PTR(-1UL); From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail137.messagelabs.com (mail137.messagelabs.com [216.82.249.19]) by kanga.kvack.org (Postfix) with SMTP id CE5526B01F2 for ; Fri, 2 Apr 2010 14:34:19 -0400 (EDT) Date: Fri, 2 Apr 2010 20:32:16 +0200 From: Oleg Nesterov Subject: [PATCH -mm 2/4] oom: select_bad_process: PF_EXITING check should take ->mm into account Message-ID: <20100402183216.GC31723@redhat.com> References: <20100330154659.GA12416@redhat.com> <20100331175836.GA11635@redhat.com> <20100331204718.GD11635@redhat.com> <20100401135927.GA12460@redhat.com> <20100402111406.GA4432@redhat.com> <20100402183057.GA31723@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20100402183057.GA31723@redhat.com> Sender: owner-linux-mm@kvack.org To: David Rientjes , Andrew Morton Cc: anfei , KOSAKI Motohiro , nishimura@mxp.nes.nec.co.jp, KAMEZAWA Hiroyuki , Mel Gorman , linux-mm@kvack.org, linux-kernel@vger.kernel.org List-ID: select_bad_process() checks PF_EXITING to detect the task which is going to release its memory, but the logic is very wrong. - a single process P with the dead group leader disables select_bad_process() completely, it will always return ERR_PTR() while P can live forever - if the PF_EXITING task has already released its ->mm it doesn't make sense to expect it is goiing to free more memory (except task_struct/etc) Change the code to ignore the PF_EXITING tasks without ->mm. Signed-off-by: Oleg Nesterov --- mm/oom_kill.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- MM/mm/oom_kill.c~2_FIX_PF_EXITING 2010-04-02 18:51:05.000000000 +0200 +++ MM/mm/oom_kill.c 2010-04-02 18:58:37.000000000 +0200 @@ -322,7 +322,7 @@ static struct task_struct *select_bad_pr * the process of exiting and releasing its resources. * Otherwise we could get an easy OOM deadlock. */ - if (p->flags & PF_EXITING) { + if ((p->flags & PF_EXITING) && p->mm) { if (p != current) return ERR_PTR(-1UL); -- 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: email@kvack.org