linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vlastimil Babka <vbabka@suse.cz>
To: David Rientjes <rientjes@google.com>,
	Andrew Morton <akpm@linux-foundation.org>
Cc: Mel Gorman <mgorman@techsingularity.net>,
	Hugh Dickins <hughd@google.com>,
	Joonsoo Kim <iamjoonsoo.kim@lge.com>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	Minchan Kim <minchan@kernel.org>
Subject: Re: [patch] mm, compaction: abort free scanner if split fails
Date: Tue, 21 Jun 2016 13:43:47 +0200	[thread overview]
Message-ID: <5783072b-0341-dccb-8f07-c92230964d83@suse.cz> (raw)
In-Reply-To: <alpine.DEB.2.10.1606201443350.33055@chino.kir.corp.google.com>

On 06/21/2016 12:27 AM, David Rientjes wrote:
> If the memory compaction free scanner cannot successfully split a free
> page (only possible due to per-zone low watermark), terminate the free
> scanner rather than continuing to scan memory needlessly.
>
> If the per-zone watermark is insufficient for a free page of
> order <= cc->order, then terminate the scanner since future splits will
> also likely fail.
>
> This prevents the compaction freeing scanner from scanning all memory on
> very large zones (very noticeable for zones > 128GB, for instance) when
> all splits will likely fail.
>
> Signed-off-by: David Rientjes <rientjes@google.com>

Acked-by: Vlastimil Babka <vbabka@suse.cz>

But some notes below.

> ---
>  mm/compaction.c | 49 +++++++++++++++++++++++++++++--------------------
>  1 file changed, 29 insertions(+), 20 deletions(-)
>
> diff --git a/mm/compaction.c b/mm/compaction.c
> --- a/mm/compaction.c
> +++ b/mm/compaction.c
> @@ -494,24 +494,22 @@ static unsigned long isolate_freepages_block(struct compact_control *cc,
>
>  		/* Found a free page, will break it into order-0 pages */
>  		order = page_order(page);
> -		isolated = __isolate_free_page(page, page_order(page));
> +		isolated = __isolate_free_page(page, order);
> +		if (!isolated)
> +			break;

This seems to fix as a side-effect a bug in Joonsoo's mmotm patch 
mm-compaction-split-freepages-without-holding-the-zone-lock.patch, that 
Minchan found: http://marc.info/?l=linux-mm&m=146607176528495&w=2

So it should be noted somewhere so they are merged together. Or Joonsoo 
posts an isolated fix and this patch has to rebase.

>  		set_page_private(page, order);
>  		total_isolated += isolated;
>  		list_add_tail(&page->lru, freelist);
>
> -		/* If a page was split, advance to the end of it */
> -		if (isolated) {
> -			cc->nr_freepages += isolated;
> -			if (!strict &&
> -				cc->nr_migratepages <= cc->nr_freepages) {
> -				blockpfn += isolated;
> -				break;
> -			}
> -
> -			blockpfn += isolated - 1;
> -			cursor += isolated - 1;
> -			continue;
> +		/* Advance to the end of split page */
> +		cc->nr_freepages += isolated;
> +		if (!strict && cc->nr_migratepages <= cc->nr_freepages) {
> +			blockpfn += isolated;
> +			break;
>  		}
> +		blockpfn += isolated - 1;
> +		cursor += isolated - 1;
> +		continue;
>
>  isolate_fail:
>  		if (strict)
> @@ -521,6 +519,9 @@ isolate_fail:
>
>  	}
>
> +	if (locked)
> +		spin_unlock_irqrestore(&cc->zone->lock, flags);
> +
>  	/*
>  	 * There is a tiny chance that we have read bogus compound_order(),
>  	 * so be careful to not go outside of the pageblock.
> @@ -542,9 +543,6 @@ isolate_fail:
>  	if (strict && blockpfn < end_pfn)
>  		total_isolated = 0;
>
> -	if (locked)
> -		spin_unlock_irqrestore(&cc->zone->lock, flags);
> -
>  	/* Update the pageblock-skip if the whole pageblock was scanned */
>  	if (blockpfn == end_pfn)
>  		update_pageblock_skip(cc, valid_page, total_isolated, false);
> @@ -622,7 +620,7 @@ isolate_freepages_range(struct compact_control *cc,
>  		 */
>  	}
>
> -	/* split_free_page does not map the pages */
> +	/* __isolate_free_page() does not map the pages */
>  	map_pages(&freelist);
>
>  	if (pfn < end_pfn) {
> @@ -1071,6 +1069,7 @@ static void isolate_freepages(struct compact_control *cc)
>  				block_end_pfn = block_start_pfn,
>  				block_start_pfn -= pageblock_nr_pages,
>  				isolate_start_pfn = block_start_pfn) {
> +		unsigned long isolated;
>
>  		/*
>  		 * This can iterate a massively long zone without finding any
> @@ -1095,8 +1094,12 @@ static void isolate_freepages(struct compact_control *cc)
>  			continue;
>
>  		/* Found a block suitable for isolating free pages from. */
> -		isolate_freepages_block(cc, &isolate_start_pfn,
> -					block_end_pfn, freelist, false);
> +		isolated = isolate_freepages_block(cc, &isolate_start_pfn,
> +						block_end_pfn, freelist, false);
> +		/* If free page split failed, do not continue needlessly */

More accurately, free page isolation failed?

> +		if (!isolated && isolate_start_pfn < block_end_pfn &&
> +		    cc->nr_freepages <= cc->nr_migratepages)
> +			break;
>
>  		/*
>  		 * If we isolated enough freepages, or aborted due to async
> @@ -1124,7 +1127,7 @@ static void isolate_freepages(struct compact_control *cc)
>  		}
>  	}
>
> -	/* split_free_page does not map the pages */
> +	/* __isolate_free_page() does not map the pages */
>  	map_pages(freelist);
>
>  	/*
> @@ -1703,6 +1706,12 @@ enum compact_result try_to_compact_pages(gfp_t gfp_mask, unsigned int order,
>  			continue;
>  		}
>
> +		/* Don't attempt compaction if splitting free page will fail */
> +		if (!zone_watermark_ok(zone, 0,
> +				       low_wmark_pages(zone) + (1 << order),
> +				       0, 0))
> +			continue;
> +

Please don't add this, compact_zone already checks this via 
compaction_suitable() (and the usual 2 << order gap), so this is adding 
yet another watermark check with a different kind of gap.

Thanks.

>  		status = compact_zone_order(zone, order, gfp_mask, mode,
>  				&zone_contended, alloc_flags,
>  				ac_classzone_idx(ac));
>

  reply	other threads:[~2016-06-21 12:05 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-15 22:34 [patch] mm, compaction: ignore watermarks when isolating free pages David Rientjes
2016-06-16  7:15 ` Vlastimil Babka
2016-06-20 22:27   ` [patch] mm, compaction: abort free scanner if split fails David Rientjes
2016-06-21 11:43     ` Vlastimil Babka [this message]
2016-06-21 20:43       ` David Rientjes
2016-06-21 21:47 [patch -mm 1/2] mm/compaction: split freepages without holding the zone lock fix David Rientjes
2016-06-22  1:22 ` [patch] mm, compaction: abort free scanner if split fails David Rientjes
2016-06-22 11:02   ` Vlastimil Babka
2016-06-22 21:56   ` Andrew Morton
2016-06-22 21:59     ` Andrew Morton
2016-06-22 23:40       ` David Rientjes
2016-06-23 11:21         ` Vlastimil Babka
2016-06-22 22:06     ` David Rientjes
2016-06-22 22:42       ` Andrew Morton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5783072b-0341-dccb-8f07-c92230964d83@suse.cz \
    --to=vbabka@suse.cz \
    --cc=akpm@linux-foundation.org \
    --cc=hughd@google.com \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mgorman@techsingularity.net \
    --cc=minchan@kernel.org \
    --cc=rientjes@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).