Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753723AbcDKOst (ORCPT ); Mon, 11 Apr 2016 10:48:49 -0400 Received: from mx2.suse.de ([195.135.220.15]:44340 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752940AbcDKOss (ORCPT ); Mon, 11 Apr 2016 10:48:48 -0400 Subject: Re: [PATCH 10/11] mm, oom: protect !costly allocations some more To: Michal Hocko , Andrew Morton References: <1459855533-4600-1-git-send-email-mhocko@kernel.org> <1459855533-4600-11-git-send-email-mhocko@kernel.org> Cc: Linus Torvalds , Johannes Weiner , Mel Gorman , David Rientjes , Tetsuo Handa , Joonsoo Kim , Hillf Danton , linux-mm@kvack.org, LKML , Michal Hocko From: Vlastimil Babka Message-ID: <570BB948.6000900@suse.cz> Date: Mon, 11 Apr 2016 16:48:40 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.0 MIME-Version: 1.0 In-Reply-To: <1459855533-4600-11-git-send-email-mhocko@kernel.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2712 Lines: 52 On 04/05/2016 01:25 PM, Michal Hocko wrote: > From: Michal Hocko > > should_reclaim_retry will give up retries for higher order allocations > if none of the eligible zones has any requested or higher order pages > available even if we pass the watermak check for order-0. This is done > because there is no guarantee that the reclaimable and currently free > pages will form the required order. > > This can, however, lead to situations were the high-order request (e.g. > order-2 required for the stack allocation during fork) will trigger > OOM too early - e.g. after the first reclaim/compaction round. Such a > system would have to be highly fragmented and there is no guarantee > further reclaim/compaction attempts would help but at least make sure > that the compaction was active before we go OOM and keep retrying even > if should_reclaim_retry tells us to oom if > - the last compaction round backed off or > - we haven't completed at least MAX_COMPACT_RETRIES active > compaction rounds. > > The first rule ensures that the very last attempt for compaction > was not ignored while the second guarantees that the compaction has done > some work. Multiple retries might be needed to prevent occasional > pigggy packing of other contexts to steal the compacted pages before > the current context manages to retry to allocate them. > > compaction_failed() is taken as a final word from the compaction that > the retry doesn't make much sense. We have to be careful though because > the first compaction round is MIGRATE_ASYNC which is rather weak as it > ignores pages under writeback and gives up too easily in other > situations. We therefore have to make sure that MIGRATE_SYNC_LIGHT mode > has been used before we give up. With this logic in place we do not have > to increase the migration mode unconditionally and rather do it only if > the compaction failed for the weaker mode. A nice side effect is that > the stronger migration mode is used only when really needed so this has > a potential of smaller latencies in some cases. > > Please note that the compaction doesn't tell us much about how > successful it was when returning compaction_made_progress so we just > have to blindly trust that another retry is worthwhile and cap the > number to something reasonable to guarantee a convergence. > > If the given number of successful retries is not sufficient for a > reasonable workloads we should focus on the collected compaction > tracepoints data and try to address the issue in the compaction code. > If this is not feasible we can increase the retries limit. > > Signed-off-by: Michal Hocko Looks good. Acked-by: Vlastimil Babka