mm, compaction: extend pageblock_skip_persistent() to all compound pages
Subsystems (3)
PATCH 1/3 mm, compaction: extend pageblock_skip_persistent() to all compound pages
The pageblock_skip_persistent() function checks for HugeTLB pages of pageblock order. When clearing pageblock skip bits for compaction, the bits are not cleared for such pageblocks, because they cannot contain base pages suitable for migration, nor free pages to use as migration targets.
This optimization can be simply extended to all compound pages of order equal or larger than pageblock order, because migrating such pages (if they support it) cannot help sub-pageblock fragmentation. This includes THP's and also gigantic HugeTLB pages, which the current implementation doesn't persistently skip due to a strict pageblock_order equality check and not recognizing tail pages.
While THP pages are generally less "persistent" than HugeTLB, we can still expect that if a THP exists at the point of __reset_isolation_suitable(), it will exist also during the subsequent compaction run. The time difference here could be actually smaller than between a compaction run that sets a (non-persistent) skip bit on a THP, and the next compaction run that observes it.
--- mm/compaction.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-)
mm/compaction.c +14 -11
@@ -218,17 +218,21 @@ static void reset_cached_positions(struct zone *zone) }/* -* Hugetlbfs pages should consistenly be skipped until updated by the hugetlb -* subsystem. It is always pointless to compact pages of pageblock_order and -* the free scanner can reconsider when no longer huge. +* Compound pages of >= pageblock_order should consistenly be skipped until +* released. It is always pointless to compact pages of such order (if they are +* migratable), and the pageblocks they occupy cannot contain any free pages. */ -static bool pageblock_skip_persistent (struct page *page,unsigned int order) +static bool pageblock_skip_persistent (struct page *page) { -if (!PageHuge (page)) +if (!PageCompound (page))return false; -if (order != pageblock_order) -return false; -return true; + + page =compound_head (page); + +if (compound_order (page) >= pageblock_order) +return true; + +return false; }/*
@@ -255,7 +259,7 @@ static void __reset_isolation_suitable(struct zone *zone)continue ;if (zone !=page_zone (page))continue ; -if (pageblock_skip_persistent (page,compound_order (page))) +if (pageblock_skip_persistent (page))continue ;clear_pageblock_skip (page);
@@ -322,8 +326,7 @@ static inline bool isolation_suitable(struct compact_control *cc,return true; } -static inline bool pageblock_skip_persistent (struct page *page, -unsigned int order) +static inline bool pageblock_skip_persistent (struct page *page) {return false; }
Signature · 7 lines
2.14.3 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 2/3 mm, compaction: split off flag for not updating skip hints
Pageblock skip hints were added as a heuristic for compaction, which shares core code with CMA. Since CMA reliability would suffer from the heuristics, compact_control flag ignore_skip_hint was added for the CMA use case. Since commit 6815bf3f233e ("mm/compaction: respect ignore_skip_hint in update_pageblock_skip") the flag also means that CMA won't *update* the skip hints in addition to ignoring them.
Today, direct compaction can also ignore the skip hints in the last resort attempt, but there's no reason not to set them when isolation fails in such case. Thus, this patch splits off a new no_set_skip_hint flag to avoid the updating, which only CMA sets. This should improve the heuristics a bit, and allow us to simplify the persistent skip bit handling as the next step.
--- mm/compaction.c | 2 +- mm/internal.h | 1 + mm/page_alloc.c | 1 + 3 files changed, 3 insertions(+), 1 deletion(-)
mm/compaction.c +1 -1
@@ -294,7 +294,7 @@ static void update_pageblock_skip(struct compact_control *cc,struct zone *zone = cc->zone;unsigned long pfn; -if (cc->ignore_skip_hint) +if (cc->no_set_skip_hint)return ;if (!page)
mm/internal.h +1 -0
@@ -201,6 +201,7 @@ struct compact_control {const int classzone_idx;/* zone index of a direct compactor */ enum migrate_mode mode;/* Async or sync migration mode */ bool ignore_skip_hint;/* Scan blocks even if marked skip */ +bool no_set_skip_hint;/* Don't mark blocks for skipping */ bool ignore_block_suitable;/* Scan blocks considered unsuitable */ bool direct_compaction;/* False from kcompactd or /proc/... */ bool whole_zone;/* Whole zone should/has been scanned */
mm/page_alloc.c +1 -0
@@ -7577,6 +7577,7 @@ int alloc_contig_range(unsigned long start, unsigned long end, .zone = page_zone(pfn_to_page(start)), .mode = MIGRATE_SYNC, .ignore_skip_hint = true, + .no_set_skip_hint = true, .gfp_mask = current_gfp_context(gfp_mask), };INIT_LIST_HEAD (&cc.migratepages);
Signature · 7 lines
2.14.3 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 2/3] mm, compaction: split off flag for not updating skip hints
Quoted 7 lines · Vlastimil Babka
Pageblock skip hints were added as a heuristic for compaction, which shares core code with CMA. Since CMA reliability would suffer from the heuristics,
compact_controlflagignore_skip_hintwas added for the CMA use case. Since commit6815bf3f233e("mm/compaction: respectignore_skip_hintinupdate_pageblock_skip") the flag also means that CMA won't *update* the skip hints in addition to ignoring them.
Quoted 7 lines
Today, direct compaction can also ignore the skip hints in the last resort attempt, but there's no reason not to set them when isolation fails in such case. Thus, this patch splits off a new
no_set_skip_hintflag to avoid the updating, which only CMA sets. This should improve the heuristics a bit, and allow us to simplify the persistent skip bit handling as the next step.Signed-off-by Vlastimil Babka <[email protected]>
Signature · 8 lines
Mel Gorman SUSE Labs -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 3/3 mm, compaction: remove unneeded pageblock_skip_persistent() checks
In reply to Vlastimil BabkaCommit f3c931633a59 ("mm, compaction: persistently skip hugetlbfs pageblocks") has introduced pageblock_skip_persistent() checks into migration and free scanners, to make sure pageblocks that should be persistently skipped are marked as such, regardless of the ignore_skip_hint flag.
Since the previous patch introduced a new no_set_skip_hint flag, the ignore flag no longer prevents marking pageblocks as skipped. Therefore we can remove the special cases. The relevant pageblocks will be marked as skipped by the common logic which marks each pageblock where no page could be isolated. This makes the code simpler.
--- mm/compaction.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-)
mm/compaction.c +3 -15
@@ -475,10 +475,7 @@ static unsigned long isolate_freepages_block(struct compact_control *cc,if (PageCompound (page)) {const unsigned int order =compound_order (page); -if (pageblock_skip_persistent (page, order)) { -set_pageblock_skip (page); - blockpfn = end_pfn; - }else if (likely (order <MAX_ORDER )) { +if (likely (order <MAX_ORDER )) { blockpfn += (1UL << order) -1 ; cursor += (1UL << order) -1 ; }
@@ -800,10 +797,7 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn,if (PageCompound (page)) {const unsigned int order =compound_order (page); -if (pageblock_skip_persistent (page, order)) { -set_pageblock_skip (page); - low_pfn = end_pfn; - }else if (likely (order <MAX_ORDER )) +if (likely (order <MAX_ORDER )) low_pfn += (1UL << order) -1 ; goto isolate_fail; }
@@ -866,13 +860,7 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn,* is safe to read and it's 0 for tail pages. */ if (unlikely (PageCompound (page))) { -const unsigned int order =compound_order (page); - -if (pageblock_skip_persistent (page, order)) { -set_pageblock_skip (page); - low_pfn = end_pfn; - }else - low_pfn += (1UL << order) -1 ; + low_pfn += (1UL <<compound_order (page)) -1 ; goto isolate_fail; } }
Signature · 7 lines
2.14.3 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 12 lines · Vlastimil Babka
The
pageblock_skip_persistent()function checks for HugeTLB pages of pageblock order. When clearing pageblock skip bits for compaction, the bits are not cleared for such pageblocks, because they cannot contain base pages suitable for migration, nor free pages to use as migration targets.This optimization can be simply extended to all compound pages of order equal or larger than pageblock order, because migrating such pages (if they support it) cannot help sub-pageblock fragmentation. This includes THP's and also gigantic HugeTLB pages, which the current implementation doesn't persistently skip due to a strict
pageblock_orderequality check and not recognizing tail pages.
Quoted 8 lines
While THP pages are generally less "persistent" than HugeTLB, we can still expect that if a THP exists at the point of
__reset_isolation_suitable(), it will exist also during the subsequent compaction run. The time difference here could be actually smaller than between a compaction run that sets a (non-persistent) skip bit on a THP, and the next compaction run that observes it.Signed-off-by Vlastimil Babka <[email protected]>
Signature · 8 lines
Mel Gorman SUSE Labs -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 12 lines · Vlastimil Babka
The
pageblock_skip_persistent()function checks for HugeTLB pages of pageblock order. When clearing pageblock skip bits for compaction, the bits are not cleared for such pageblocks, because they cannot contain base pages suitable for migration, nor free pages to use as migration targets.This optimization can be simply extended to all compound pages of order equal or larger than pageblock order, because migrating such pages (if they support it) cannot help sub-pageblock fragmentation. This includes THP's and also gigantic HugeTLB pages, which the current implementation doesn't persistently skip due to a strict
pageblock_orderequality check and not recognizing tail pages.
Quoted 8 lines
While THP pages are generally less "persistent" than HugeTLB, we can still expect that if a THP exists at the point of
__reset_isolation_suitable(), it will exist also during the subsequent compaction run. The time difference here could be actually smaller than between a compaction run that sets a (non-persistent) skip bit on a THP, and the next compaction run that observes it.Signed-off-by Vlastimil Babka <[email protected]>
This was originally done only for hugetlb because it was considered to be more persistent than thp, but with the presence of the deferred split shrinker I think this is fine. It might be helpful to mention that the compound page is not synchronously split like it was prior to the thp refcounting patchset, however.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>