From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753441AbcAGO6p (ORCPT ); Thu, 7 Jan 2016 09:58:45 -0500 Received: from mail-wm0-f54.google.com ([74.125.82.54]:33623 "EHLO mail-wm0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752221AbcAGO6o (ORCPT ); Thu, 7 Jan 2016 09:58:44 -0500 Date: Thu, 7 Jan 2016 15:58:41 +0100 From: Michal Hocko To: Tetsuo Handa Cc: rientjes@google.com, akpm@linux-foundation.org, mgorman@suse.de, torvalds@linux-foundation.org, oleg@redhat.com, hughd@google.com, andrea@kernel.org, riel@redhat.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm,oom: Exclude TIF_MEMDIE processes from candidates. Message-ID: <20160107145841.GN27868@dhcp22.suse.cz> References: <201512292258.ABF87505.OFOSJLHMFVOQFt@I-love.SAKURA.ne.jp> <20160107091512.GB27868@dhcp22.suse.cz> <201601072231.DGG78695.OOFVLHJFFQOStM@I-love.SAKURA.ne.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201601072231.DGG78695.OOFVLHJFFQOStM@I-love.SAKURA.ne.jp> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 07-01-16 22:31:32, Tetsuo Handa wrote: [...] > I think we need to filter at select_bad_process() and oom_kill_process(). > > When P has no children, P is chosen and TIF_MEMDIE is set on P. But P can > be chosen forever due to P->signal->oom_score_adj == OOM_SCORE_ADJ_MAX > even if the OOM reaper reclaimed P's mm. We need to ensure that > oom_kill_process() is not called with P if P already has TIF_MEMDIE. Hmm. Any task is allowed to set its oom_score_adj that way and I guess we should really make sure that at least sysrq+f will make some progress. This is what I would do. Again I think this is worth a separate patch. Unless there are any objections I will roll out what I have and post 3 separate patches. --- diff --git a/mm/oom_kill.c b/mm/oom_kill.c index 45e51ad2f7cf..ee34a51bd65a 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c @@ -333,6 +333,14 @@ static struct task_struct *select_bad_process(struct oom_control *oc, if (points == chosen_points && thread_group_leader(chosen)) continue; + /* + * If the current major task is already ooom killed and this + * is sysrq+f request then we rather choose somebody else + * because the current oom victim might be stuck. + */ + if (is_sysrq_oom(sc) && test_tsk_thread_flag(p, TIF_MEMDIE)) + continue; + chosen = p; chosen_points = points; } -- Michal Hocko SUSE Labs