diff mbox series

[05/14] mm, compaction: Skip pageblocks with reserved pages

Message ID 20181214230310.572-6-mgorman@techsingularity.net (mailing list archive)
State New, archived
Headers show
Series Increase success rates and reduce latency of compaction v1 | expand

Commit Message

Mel Gorman Dec. 14, 2018, 11:03 p.m. UTC
Reserved pages are set at boot time, tend to be clustered and almost
never become unreserved. When isolating pages for migrating, skip
the entire pageblock is one PageReserved page is encountered on the
grounds that it is highly probable the entire pageblock is reserved.

The impact depends on the machine and timing but both thpscale and
thpfioscale when using MADV_HUGEPAGE show a reduction of scanning and
fault latency on a 1-socket machine. The 2-socket results were too
noisy to draw any meaningful conclusion but it's safe to assume less
scanning is useful.

1-socket thpfioscale
                                   4.20.0-rc6             4.20.0-rc6
                               mmotm-20181210        noreserved-v1r4
Amean     fault-base-1     1481.32 (   0.00%)     1443.63 (   2.54%)
Amean     fault-huge-1     1118.17 (   0.00%)      981.30 *  12.24%*
Amean     fault-both-1     1176.43 (   0.00%)     1052.64 *  10.52%*

Compaction migrate scanned     3860713     3294284
Compaction free scanned      613786341   433423502
Kcompactd migrate scanned       408711      291915
Kcompactd free scanned       242509759   217164988

Signed-off-by: Mel Gorman <mgorman@techsingularity.net>
---
 mm/compaction.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Vlastimil Babka Dec. 18, 2018, 8:08 a.m. UTC | #1
On 12/15/18 12:03 AM, Mel Gorman wrote:
> Reserved pages are set at boot time, tend to be clustered and almost
> never become unreserved. When isolating pages for migrating, skip
> the entire pageblock is one PageReserved page is encountered on the
> grounds that it is highly probable the entire pageblock is reserved.

Agreed, but maybe since it's highly probable and not certain, this
skipping should not be done on the highest compaction priority?

> The impact depends on the machine and timing but both thpscale and
> thpfioscale when using MADV_HUGEPAGE show a reduction of scanning and
> fault latency on a 1-socket machine. The 2-socket results were too
> noisy to draw any meaningful conclusion but it's safe to assume less
> scanning is useful.
> 
> 1-socket thpfioscale
>                                    4.20.0-rc6             4.20.0-rc6
>                                mmotm-20181210        noreserved-v1r4
> Amean     fault-base-1     1481.32 (   0.00%)     1443.63 (   2.54%)
> Amean     fault-huge-1     1118.17 (   0.00%)      981.30 *  12.24%*
> Amean     fault-both-1     1176.43 (   0.00%)     1052.64 *  10.52%*
> 
> Compaction migrate scanned     3860713     3294284
> Compaction free scanned      613786341   433423502
> Kcompactd migrate scanned       408711      291915
> Kcompactd free scanned       242509759   217164988
> 
> Signed-off-by: Mel Gorman <mgorman@techsingularity.net>
> ---
>  mm/compaction.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/mm/compaction.c b/mm/compaction.c
> index 3afa4e9188b6..8134dba47584 100644
> --- a/mm/compaction.c
> +++ b/mm/compaction.c
> @@ -827,6 +827,13 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn,
>  					goto isolate_success;
>  			}
>  
> +			/*
> +			 * A reserved page is never freed and tend to be
> +			 * clustered in the same pageblocks. Skip the block.
> +			 */
> +			if (PageReserved(page))
> +				low_pfn = end_pfn;
> +
>  			goto isolate_fail;
>  		}
>  
>
Mel Gorman Dec. 18, 2018, 8:38 a.m. UTC | #2
On Tue, Dec 18, 2018 at 09:08:02AM +0100, Vlastimil Babka wrote:
> On 12/15/18 12:03 AM, Mel Gorman wrote:
> > Reserved pages are set at boot time, tend to be clustered and almost
> > never become unreserved. When isolating pages for migrating, skip
> > the entire pageblock is one PageReserved page is encountered on the
> > grounds that it is highly probable the entire pageblock is reserved.
> 
> Agreed, but maybe since it's highly probable and not certain, this
> skipping should not be done on the highest compaction priority?
> 

I don't think that's necessary at this time. For the most part, you are
talking about one partial pageblock at best given how the early memory
allocator works so it would only ever be useful for a high-order kernel
allocation. Second, one of compactions primary problems is inefficient
scanning where viable pageblocks are easily skipped over or only partially
scanned which is something I'm still looking at. Lastly, maximum priority
compaction is rarely hit in practice as far as I can tell.
diff mbox series

Patch

diff --git a/mm/compaction.c b/mm/compaction.c
index 3afa4e9188b6..8134dba47584 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -827,6 +827,13 @@  isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn,
 					goto isolate_success;
 			}
 
+			/*
+			 * A reserved page is never freed and tend to be
+			 * clustered in the same pageblocks. Skip the block.
+			 */
+			if (PageReserved(page))
+				low_pfn = end_pfn;
+
 			goto isolate_fail;
 		}