From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756512AbcA2PXO (ORCPT ); Fri, 29 Jan 2016 10:23:14 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:36365 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751825AbcA2PXK (ORCPT ); Fri, 29 Jan 2016 10:23:10 -0500 Date: Fri, 29 Jan 2016 16:23:08 +0100 From: Michal Hocko To: David Rientjes Cc: Johannes Weiner , Andrew Morton , Linus Torvalds , Mel Gorman , Tetsuo Handa , Hillf Danton , KAMEZAWA Hiroyuki , linux-mm@kvack.org, LKML Subject: Re: [PATCH 4/3] mm, oom: drop the last allocation attempt before out_of_memory Message-ID: <20160129152307.GF32174@dhcp22.suse.cz> References: <1450203586-10959-1-git-send-email-mhocko@kernel.org> <1454013603-3682-1-git-send-email-mhocko@kernel.org> <20160128213634.GA4903@cmpxchg.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 28-01-16 15:19:08, David Rientjes wrote: > On Thu, 28 Jan 2016, Johannes Weiner wrote: > > > The check has to happen while holding the OOM lock, otherwise we'll > > end up killing much more than necessary when there are many racing > > allocations. > > > > Right, we need to try with ALLOC_WMARK_HIGH after oom_lock has been > acquired. > > The situation is still somewhat fragile, however, but I think it's > tangential to this patch series. If the ALLOC_WMARK_HIGH allocation fails > because an oom victim hasn't freed its memory yet, and then the TIF_MEMDIE > thread isn't visible during the oom killer's tasklist scan because it has > exited, we still end up killing more than we should. The likelihood of > this happening grows with the length of the tasklist. Yes exactly the point I made in the original thread which brought the question about ALLOC_WMARK_HIGH originally. The race window after the last attempt is much larger than between the last wmark check and the attempt. > Perhaps we should try testing watermarks after a victim has been selected > and immediately before killing? (Aside: we actually carry an internal > patch to test mem_cgroup_margin() in the memcg oom path after selecting a > victim because we have been hit with this before in the memcg path.) > > I would think that retrying with ALLOC_WMARK_HIGH would be enough memory > to deem that we aren't going to immediately reenter an oom condition so > the deferred killing is a waste of time. > > The downside is how sloppy this would be because it's blurring the line > between oom killer and page allocator. We'd need the oom killer to return > the selected victim to the page allocator, try the allocation, and then > call oom_kill_process() if necessary. Yes the layer violation is definitely not nice. -- Michal Hocko SUSE Labs