From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by kanga.kvack.org (Postfix) with ESMTP id 4FA9E6B04DB for ; Wed, 7 Nov 2018 05:08:15 -0500 (EST) Received: by mail-ed1-f70.google.com with SMTP id h24-v6so5237126ede.9 for ; Wed, 07 Nov 2018 02:08:15 -0800 (PST) Received: from mx1.suse.de (mx2.suse.de. [195.135.220.15]) by mx.google.com with ESMTPS id k3-v6si252950ejk.145.2018.11.07.02.08.13 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Nov 2018 02:08:13 -0800 (PST) Date: Wed, 7 Nov 2018 11:08:10 +0100 From: Michal Hocko Subject: Re: [RFC PATCH 2/2] memcg: do not report racy no-eligible OOM tasks Message-ID: <20181107100810.GA27423@dhcp22.suse.cz> References: <20181022071323.9550-1-mhocko@kernel.org> <20181022071323.9550-3-mhocko@kernel.org> <20181026142531.GA27370@cmpxchg.org> <20181026192551.GC18839@dhcp22.suse.cz> <20181026193304.GD18839@dhcp22.suse.cz> <20181106124224.GM27423@dhcp22.suse.cz> <8725e3b3-3752-fa7f-a88f-5ff4f5b6eace@i-love.sakura.ne.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8725e3b3-3752-fa7f-a88f-5ff4f5b6eace@i-love.sakura.ne.jp> Sender: owner-linux-mm@kvack.org List-ID: To: Johannes Weiner , Tetsuo Handa Cc: linux-mm@kvack.org, David Rientjes , Andrew Morton , LKML On Wed 07-11-18 18:45:27, Tetsuo Handa wrote: > On 2018/11/06 21:42, Michal Hocko wrote: > > On Tue 06-11-18 18:44:43, Tetsuo Handa wrote: > > [...] > >> diff --git a/mm/memcontrol.c b/mm/memcontrol.c > >> index 6e1469b..a97648a 100644 > >> --- a/mm/memcontrol.c > >> +++ b/mm/memcontrol.c > >> @@ -1382,8 +1382,13 @@ static bool mem_cgroup_out_of_memory(struct mem_cgroup *memcg, gfp_t gfp_mask, > >> }; > >> bool ret; > >> > >> - mutex_lock(&oom_lock); > >> - ret = out_of_memory(&oc); > >> + if (mutex_lock_killable(&oom_lock)) > >> + return true; > >> + /* > >> + * A few threads which were not waiting at mutex_lock_killable() can > >> + * fail to bail out. Therefore, check again after holding oom_lock. > >> + */ > >> + ret = fatal_signal_pending(current) || out_of_memory(&oc); > >> mutex_unlock(&oom_lock); > >> return ret; > >> } > > > > If we are goging with a memcg specific thingy then I really prefer > > tsk_is_oom_victim approach. Or is there any reason why this is not > > suitable? > > > > Why need to wait for mark_oom_victim() called after slow printk() messages? > > If current thread got Ctrl-C and thus current thread can terminate, what is > nice with waiting for the OOM killer? If there are several OOM events in > multiple memcg domains waiting for completion of printk() messages? I don't > see points with waiting for oom_lock, for try_charge() already allows current > thread to terminate due to fatal_signal_pending() test. mutex_lock_killable would take care of exiting task already. I would then still prefer to check for mark_oom_victim because that is not racy with the exit path clearing signals. I can update my patch to use _killable lock variant if we are really going with the memcg specific fix. Johaness? -- Michal Hocko SUSE Labs