From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932572AbcJLIhB (ORCPT ); Wed, 12 Oct 2016 04:37:01 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:35417 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932201AbcJLIgz (ORCPT ); Wed, 12 Oct 2016 04:36:55 -0400 Date: Wed, 12 Oct 2016 10:36:53 +0200 From: Michal Hocko To: Minchan Kim Cc: Andrew Morton , Mel Gorman , Vlastimil Babka , Joonsoo Kim , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Sangseok Lee Subject: Re: [PATCH v3 4/4] mm: make unreserve highatomic functions reliable Message-ID: <20161012083652.GE17128@dhcp22.suse.cz> References: <1476259429-18279-1-git-send-email-minchan@kernel.org> <1476259429-18279-5-git-send-email-minchan@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1476259429-18279-5-git-send-email-minchan@kernel.org> User-Agent: Mutt/1.6.0 (2016-04-01) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed 12-10-16 17:03:49, Minchan Kim wrote: > Currently, unreserve_highatomic_pageblock bails out if it found > highatomic pageblock regardless of really moving free pages > from the one so that it could mitigate unreserve logic's goal > which saves OOM of a process. > > This patch makes unreserve functions bail out only if it moves > some pages out of !highatomic free list to avoid such false > positive. > > Another potential problem is that by race between page freeing and > reserve highatomic function, pages could be in highatomic free list > even though the pageblock is !high atomic migratetype. In that case, > unreserve_highatomic_pageblock can be void if count of highatomic > reserve is less than pageblock_nr_pages. We could solve it simply > via draining all of reserved pages before the OOM. It would have > a safeguard role to exhuast reserved pages before converging to OOM. > > Signed-off-by: Minchan Kim > Signed-off-by: Michal Hocko > Acked-by: Vlastimil Babka Looks good to me as well. If the previous one is agreed to go to stable this one should go with it IMHO. Thanks! > --- > mm/page_alloc.c | 24 +++++++++++++++++------- > 1 file changed, 17 insertions(+), 7 deletions(-) > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index fd2f0e1bffc4..163d7fa759a2 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -2079,8 +2079,12 @@ static void reserve_highatomic_pageblock(struct page *page, struct zone *zone, > * potentially hurts the reliability of high-order allocations when under > * intense memory pressure but failed atomic allocations should be easier > * to recover from than an OOM. > + * > + * If @force is true, try to unreserve a pageblock even though highatomic > + * pageblock is exhausted. > */ > -static bool unreserve_highatomic_pageblock(const struct alloc_context *ac) > +static bool unreserve_highatomic_pageblock(const struct alloc_context *ac, > + bool force) > { > struct zonelist *zonelist = ac->zonelist; > unsigned long flags; > @@ -2092,8 +2096,12 @@ static bool unreserve_highatomic_pageblock(const struct alloc_context *ac) > > for_each_zone_zonelist_nodemask(zone, z, zonelist, ac->high_zoneidx, > ac->nodemask) { > - /* Preserve at least one pageblock */ > - if (zone->nr_reserved_highatomic <= pageblock_nr_pages) > + /* > + * Preserve at least one pageblock unless memory pressure > + * is really high. > + */ > + if (!force && zone->nr_reserved_highatomic <= > + pageblock_nr_pages) > continue; > > spin_lock_irqsave(&zone->lock, flags); > @@ -2138,8 +2146,10 @@ static bool unreserve_highatomic_pageblock(const struct alloc_context *ac) > */ > set_pageblock_migratetype(page, ac->migratetype); > ret = move_freepages_block(zone, page, ac->migratetype); > - spin_unlock_irqrestore(&zone->lock, flags); > - return ret; > + if (ret) { > + spin_unlock_irqrestore(&zone->lock, flags); > + return ret; > + } > } > spin_unlock_irqrestore(&zone->lock, flags); > } > @@ -3343,7 +3353,7 @@ __alloc_pages_direct_reclaim(gfp_t gfp_mask, unsigned int order, > * Shrink them them and try again > */ > if (!page && !drained) { > - unreserve_highatomic_pageblock(ac); > + unreserve_highatomic_pageblock(ac, false); > drain_all_pages(NULL); > drained = true; > goto retry; > @@ -3462,7 +3472,7 @@ should_reclaim_retry(gfp_t gfp_mask, unsigned order, > */ > if (*no_progress_loops > MAX_RECLAIM_RETRIES) { > /* Before OOM, exhaust highatomic_reserve */ > - return unreserve_highatomic_pageblock(ac); > + return unreserve_highatomic_pageblock(ac, true); > } > > /* > -- > 2.7.4 > -- Michal Hocko SUSE Labs