Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754572AbcCBPBV (ORCPT ); Wed, 2 Mar 2016 10:01:21 -0500 Received: from LGEAMRELO11.lge.com ([156.147.23.51]:45071 "EHLO lgeamrelo11.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754287AbcCBPBJ (ORCPT ); Wed, 2 Mar 2016 10:01:09 -0500 X-Original-SENDERIP: 156.147.1.121 X-Original-MAILFROM: minchan@kernel.org X-Original-SENDERIP: 165.244.98.76 X-Original-MAILFROM: minchan@kernel.org X-Original-SENDERIP: 10.177.223.161 X-Original-MAILFROM: minchan@kernel.org Date: Thu, 3 Mar 2016 00:01:12 +0900 From: Minchan Kim To: Michal Hocko CC: Joonsoo Kim , Andrew Morton , Hugh Dickins , Linus Torvalds , Johannes Weiner , Mel Gorman , David Rientjes , Tetsuo Handa , Hillf Danton , KAMEZAWA Hiroyuki , linux-mm@kvack.org, LKML , Sergey Senozhatsky Subject: Re: [PATCH 0/3] OOM detection rework v4 Message-ID: <20160302150112.GA18192@bbox> References: <1450203586-10959-1-git-send-email-mhocko@kernel.org> <20160203132718.GI6757@dhcp22.suse.cz> <20160225092315.GD17573@dhcp22.suse.cz> <20160229210213.GX16930@dhcp22.suse.cz> <20160302021954.GA22355@js1304-P5Q-DELUXE> <20160302095056.GB26701@dhcp22.suse.cz> MIME-Version: 1.0 In-Reply-To: <20160302095056.GB26701@dhcp22.suse.cz> User-Agent: Mutt/1.5.21 (2010-09-15) X-MIMETrack: Itemize by SMTP Server on LGEKRMHUB06/LGE/LG Group(Release 8.5.3FP6|November 21, 2013) at 2016/03/03 00:01:05, Serialize by Router on LGEKRMHUB06/LGE/LG Group(Release 8.5.3FP6|November 21, 2013) at 2016/03/03 00:01:05, Serialize complete at 2016/03/03 00:01:05 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3958 Lines: 91 On Wed, Mar 02, 2016 at 10:50:56AM +0100, Michal Hocko wrote: > On Wed 02-03-16 11:19:54, Joonsoo Kim wrote: > > On Mon, Feb 29, 2016 at 10:02:13PM +0100, Michal Hocko wrote: > [...] > > > > + /* > > > > + * OK, so the watermak check has failed. Make sure we do all the > > > > + * retries for !costly high order requests and hope that multiple > > > > + * runs of compaction will generate some high order ones for us. > > > > + * > > > > + * XXX: ideally we should teach the compaction to try _really_ hard > > > > + * if we are in the retry path - something like priority 0 for the > > > > + * reclaim > > > > + */ > > > > + if (order && order <= PAGE_ALLOC_COSTLY_ORDER) > > > > + return true; > > > > + > > > > return false; > > > > This seems not a proper fix. Checking watermark with high order has > > another meaning that there is high order page or not. This isn't > > what we want here. > > Why not? Why should we retry the reclaim if we do not have >=order page > available? Reclaim itself doesn't guarantee any of the freed pages will > form the requested order. The ordering on the LRU lists is pretty much > random wrt. pfn ordering. On the other hand if we have a page available > which is just hidden by watermarks then it makes perfect sense to retry > and free even order-0 pages. > > > So, following fix is needed. > > > 'if (order)' check isn't needed. It is used to clarify the meaning of > > this fix. You can remove it. > > > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > > index 1993894..8c80375 100644 > > --- a/mm/page_alloc.c > > +++ b/mm/page_alloc.c > > @@ -3125,6 +3125,10 @@ should_reclaim_retry(gfp_t gfp_mask, unsigned order, > > if (order > PAGE_ALLOC_COSTLY_ORDER && !(gfp_mask & __GFP_REPEAT)) > > return false; > > > > + /* To check whether compaction is available or not */ > > + if (order) > > + order = 0; > > + > > This would enforce the order 0 wmark check which is IMHO not correct as > per above. > > > /* > > * Keep reclaiming pages while there is a chance this will lead > > * somewhere. If none of the target zones can satisfy our allocation > > > > > > } > > > > > > > > @@ -3281,11 +3293,11 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order, > > > > goto noretry; > > > > > > > > /* > > > > - * Costly allocations might have made a progress but this doesn't mean > > > > - * their order will become available due to high fragmentation so do > > > > - * not reset the no progress counter for them > > > > + * High order allocations might have made a progress but this doesn't > > > > + * mean their order will become available due to high fragmentation so > > > > + * do not reset the no progress counter for them > > > > */ > > > > - if (did_some_progress && order <= PAGE_ALLOC_COSTLY_ORDER) > > > > + if (did_some_progress && !order) > > > > no_progress_loops = 0; > > > > else > > > > no_progress_loops++; > > > > This unconditionally increases no_progress_loops for high order > > allocation, so, after 16 iterations, it will fail. If compaction isn't > > enabled in Kconfig, 16 times reclaim attempt would not be sufficient > > to make high order page. Should we consider this case also? > > How many retries would help? I do not think any number will work > reliably. Configurations without compaction enabled are asking for > problems by definition IMHO. Relying on order-0 reclaim for high order > allocations simply cannot work. I left compaction code for a long time so a super hero might make it perfect now but I don't think the dream come true yet and I believe any algorithm has a drawback so we end up relying on a fallback approach in case of not working compaction correctly. My suggestion is to reintroduce *lumpy reclaim* and kicks in only when compaction gave up by some reasons. It would be better to rely on random number retrial of reclaim.