From da27500dccbda39e29a4d1959d089fae8d1524e6 Mon Sep 17 00:00:00 2001 From: Sooyong Suk Date: Mon, 15 Jul 2024 19:33:17 +0900 Subject: [PATCH] ANDROID: mm: introduce export symbol compact_node_async This is an exported function to compact all zones within a node with MIGRATE_ASYNC mode. Bug: 351175506 Change-Id: Id98f6b87b586043e2f94f08e1201829274a6bf34 Signed-off-by: Sooyong Suk --- include/linux/compaction.h | 1 + mm/compaction.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/include/linux/compaction.h b/include/linux/compaction.h index e94776496049..d73d7540ee1d 100644 --- a/include/linux/compaction.h +++ b/include/linux/compaction.h @@ -101,6 +101,7 @@ bool compaction_zonelist_suitable(struct alloc_context *ac, int order, extern void __meminit kcompactd_run(int nid); extern void __meminit kcompactd_stop(int nid); extern void wakeup_kcompactd(pg_data_t *pgdat, int order, int highest_zoneidx); +extern void compact_node_async(int nid); #else static inline void reset_isolation_suitable(pg_data_t *pgdat) diff --git a/mm/compaction.c b/mm/compaction.c index af26ed222145..ac7e7838de47 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -2895,6 +2895,36 @@ enum compact_result try_to_compact_pages(gfp_t gfp_mask, unsigned int order, return rc; } +/* Compact all zones within a node with MIGRATE_ASYNC */ +void compact_node_async(int nid) +{ + pg_data_t *pgdat = NODE_DATA(nid); + int zoneid; + struct zone *zone; + struct compact_control cc = { + .order = -1, + .mode = MIGRATE_ASYNC, + .ignore_skip_hint = true, + .whole_zone = true, + .gfp_mask = GFP_KERNEL, + .proactive_compaction = false, + }; + + for (zoneid = 0; zoneid < MAX_NR_ZONES; zoneid++) { + zone = &pgdat->node_zones[zoneid]; + if (!populated_zone(zone)) + continue; + + if (fatal_signal_pending(current)) + break; + + cc.zone = zone; + + compact_zone(&cc, NULL); + } +} +EXPORT_SYMBOL_GPL(compact_node_async); + /* * compact_node() - compact all zones within a node * @pgdat: The node page data