linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: page_alloc: allowing mTHP compaction to capture the freed page directly
@ 2024-04-12  3:27 Baolin Wang
  2024-04-12 14:06 ` Zi Yan
  2024-04-12 15:11 ` Johannes Weiner
  0 siblings, 2 replies; 3+ messages in thread
From: Baolin Wang @ 2024-04-12  3:27 UTC (permalink / raw)
  To: akpm
  Cc: hannes, mgorman, vbabka, 21cnbao, ryan.roberts, david,
	ying.huang, ziy, baolin.wang, linux-mm, linux-kernel

Currently, compaction_capture() does not allow lower-order allocations to
directly capture the movable free pages, even though lower-order allocations
might also be requesting movable pages, that can lead to more compaction
scanning. And, with the enablement of mTHP, such situations will become more
common.

Thus allowing lower-order (mTHP) allocations of movable page types directly
capture the movable free pages can avoid unnecessary compaction scanning,
meanwhile that won't pollute the movable pageblock. With testing 1M mTHP
compaction, it can be seen that compaction scanning is significantly reduced.

                                   mm-unstable       patched
Ops Compaction pages isolated      116598741.00   120946702.00
Ops Compaction migrate scanned    1764870054.00  1488621550.00
Ops Compaction free scanned       7707879039.00  4986299318.00
Ops Compact scan efficiency               22.90          29.85
Ops Compaction cost                    73797.69       72933.48

Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com>
---
 mm/page_alloc.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index b51becf03d1e..33d4a1be927b 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -595,12 +595,14 @@ compaction_capture(struct capture_control *capc, struct page *page,
 		return false;
 
 	/*
-	 * Do not let lower order allocations pollute a movable pageblock.
+	 * Do not let lower order allocations pollute a movable pageblock
+	 * unless compaction is also requesting movable pages.
 	 * This might let an unmovable request use a reclaimable pageblock
 	 * and vice-versa but no more than normal fallback logic which can
 	 * have trouble finding a high-order free page.
 	 */
-	if (order < pageblock_order && migratetype == MIGRATE_MOVABLE)
+	if (order < pageblock_order && migratetype == MIGRATE_MOVABLE &&
+	    capc->cc->migratetype != MIGRATE_MOVABLE)
 		return false;
 
 	capc->page = page;
-- 
2.39.3



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mm: page_alloc: allowing mTHP compaction to capture the freed page directly
  2024-04-12  3:27 [PATCH] mm: page_alloc: allowing mTHP compaction to capture the freed page directly Baolin Wang
@ 2024-04-12 14:06 ` Zi Yan
  2024-04-12 15:11 ` Johannes Weiner
  1 sibling, 0 replies; 3+ messages in thread
From: Zi Yan @ 2024-04-12 14:06 UTC (permalink / raw)
  To: Baolin Wang
  Cc: akpm, hannes, mgorman, vbabka, 21cnbao, ryan.roberts, david,
	ying.huang, linux-mm, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1295 bytes --]

On 11 Apr 2024, at 23:27, Baolin Wang wrote:

> Currently, compaction_capture() does not allow lower-order allocations to
> directly capture the movable free pages, even though lower-order allocations
> might also be requesting movable pages, that can lead to more compaction
> scanning. And, with the enablement of mTHP, such situations will become more
> common.
>
> Thus allowing lower-order (mTHP) allocations of movable page types directly
> capture the movable free pages can avoid unnecessary compaction scanning,
> meanwhile that won't pollute the movable pageblock. With testing 1M mTHP
> compaction, it can be seen that compaction scanning is significantly reduced.
>
>                                    mm-unstable       patched
> Ops Compaction pages isolated      116598741.00   120946702.00
> Ops Compaction migrate scanned    1764870054.00  1488621550.00
> Ops Compaction free scanned       7707879039.00  4986299318.00
> Ops Compact scan efficiency               22.90          29.85
> Ops Compaction cost                    73797.69       72933.48
>
> Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com>
> ---
>  mm/page_alloc.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
LGTM. Thanks. Reviewed-by: Zi Yan <ziy@nvidia.com>

--
Best Regards,
Yan, Zi

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 854 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mm: page_alloc: allowing mTHP compaction to capture the freed page directly
  2024-04-12  3:27 [PATCH] mm: page_alloc: allowing mTHP compaction to capture the freed page directly Baolin Wang
  2024-04-12 14:06 ` Zi Yan
@ 2024-04-12 15:11 ` Johannes Weiner
  1 sibling, 0 replies; 3+ messages in thread
From: Johannes Weiner @ 2024-04-12 15:11 UTC (permalink / raw)
  To: Baolin Wang
  Cc: akpm, mgorman, vbabka, 21cnbao, ryan.roberts, david, ying.huang,
	ziy, linux-mm, linux-kernel

On Fri, Apr 12, 2024 at 11:27:04AM +0800, Baolin Wang wrote:
> Currently, compaction_capture() does not allow lower-order allocations to
> directly capture the movable free pages, even though lower-order allocations
> might also be requesting movable pages, that can lead to more compaction
> scanning. And, with the enablement of mTHP, such situations will become more
> common.
> 
> Thus allowing lower-order (mTHP) allocations of movable page types directly
> capture the movable free pages can avoid unnecessary compaction scanning,
> meanwhile that won't pollute the movable pageblock. With testing 1M mTHP
> compaction, it can be seen that compaction scanning is significantly reduced.
> 
>                                    mm-unstable       patched
> Ops Compaction pages isolated      116598741.00   120946702.00
> Ops Compaction migrate scanned    1764870054.00  1488621550.00
> Ops Compaction free scanned       7707879039.00  4986299318.00
> Ops Compact scan efficiency               22.90          29.85
> Ops Compaction cost                    73797.69       72933.48
> 
> Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com>

Letting a movable request into a partially compacted movable block
seems reasonable.

The only advantage of not doing so that I could imagine would be to
avoid mixing old with new pages, such that reclaim is more likely to
free blocks due to improved LRU grouping. But that seems
far-fetched. Notably, __compact_finished() will also stop once the
requested MOVABLE order becomes available; so not capturing at that
point likely just results in stolen work and compaction restarts.

Acked-by: Johannes Weiner <hannes@cmpxchg.org>


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-04-12 15:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-12  3:27 [PATCH] mm: page_alloc: allowing mTHP compaction to capture the freed page directly Baolin Wang
2024-04-12 14:06 ` Zi Yan
2024-04-12 15:11 ` Johannes Weiner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox