From 0457ed368ff5cff62d51b049f480f20a89c247e5 Mon Sep 17 00:00:00 2001 From: Sooyong Suk Date: Tue, 12 Nov 2024 15:09:12 +0900 Subject: [PATCH] ANDROID: mm: add vendor hook to bypass migration target Add a vendor hook to skip certain page block for compaction target. Bug: 378012042 Change-Id: Ibed26c4d8a7ea9eb4d1900a16f15498267867f6b Signed-off-by: Sooyong Suk --- drivers/android/vendor_hooks.c | 1 + include/trace/hooks/mm.h | 3 +++ mm/compaction.c | 11 +++++++++++ 3 files changed, 15 insertions(+) diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index 2d485af5ac73..1994236441c8 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -180,6 +180,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_isolate_freepages); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_oom_check_panic); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_rmqueue_smallest_bypass); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_free_one_page_bypass); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_migration_target_bypass); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_adjust_alloc_flags); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_wait_for_work); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_alloc_oem_binder_struct); diff --git a/include/trace/hooks/mm.h b/include/trace/hooks/mm.h index 15a11e9f75f9..af9d31b36dc1 100644 --- a/include/trace/hooks/mm.h +++ b/include/trace/hooks/mm.h @@ -64,6 +64,9 @@ DECLARE_HOOK(android_vh_free_one_page_bypass, TP_PROTO(struct page *page, struct zone *zone, int order, int migratetype, int fpi_flags, bool *bypass), TP_ARGS(page, zone, order, migratetype, fpi_flags, bypass)); +DECLARE_HOOK(android_vh_migration_target_bypass, + TP_PROTO(struct page *page, bool *bypass), + TP_ARGS(page, bypass)); struct page_vma_mapped_walk; DECLARE_HOOK(android_vh_slab_alloc_node, diff --git a/mm/compaction.c b/mm/compaction.c index f2a4480ad1e9..1a5dc19584e9 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -1417,6 +1417,8 @@ static bool suitable_migration_source(struct compact_control *cc, static bool suitable_migration_target(struct compact_control *cc, struct page *page) { + bool bypass = false; + /* If the page is a large free page, then disallow migration */ if (PageBuddy(page)) { int order = cc->order > 0 ? cc->order : pageblock_order; @@ -1430,6 +1432,10 @@ static bool suitable_migration_target(struct compact_control *cc, return false; } + trace_android_vh_migration_target_bypass(page, &bypass); + if (bypass) + return false; + if (cc->ignore_block_suitable) return true; @@ -1497,6 +1503,7 @@ fast_isolate_around(struct compact_control *cc, unsigned long pfn) { unsigned long start_pfn, end_pfn; struct page *page; + bool bypass = false; /* Do not search around if there are enough pages already */ if (cc->nr_freepages >= cc->nr_migratepages) @@ -1514,6 +1521,10 @@ fast_isolate_around(struct compact_control *cc, unsigned long pfn) if (!page) return; + trace_android_vh_migration_target_bypass(page, &bypass); + if (bypass) + return; + isolate_freepages_block(cc, &start_pfn, end_pfn, cc->freepages, 1, false); /* Skip this pageblock in the future as it's full or nearly full */