To wakeup kswapd, we need to iterate pgdat->node_zones and get the proper zone. While this work has already been done in migrate_balanced_pgdat(). Let's return the valid zone directly instead of do the iteration again. Signed-off-by: Wei Yang <richard.weiyang@xxxxxxxxx> --- mm/migrate.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index 5adc55b5347c..b086bd781956 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1973,7 +1973,7 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages, * Returns true if this is a safe migration target node for misplaced NUMA * pages. Currently it only checks the watermarks which is crude. */ -static bool migrate_balanced_pgdat(struct pglist_data *pgdat, +static struct zone *migrate_balanced_pgdat(struct pglist_data *pgdat, unsigned long nr_migrate_pages) { int z; @@ -1985,14 +1985,13 @@ static bool migrate_balanced_pgdat(struct pglist_data *pgdat, continue; /* Avoid waking kswapd by allocating pages_to_migrate pages. */ - if (!zone_watermark_ok(zone, 0, + if (zone_watermark_ok(zone, 0, high_wmark_pages(zone) + nr_migrate_pages, ZONE_MOVABLE, 0)) - continue; - return true; + return zone; } - return false; + return NULL; } static struct page *alloc_misplaced_dst_page(struct page *page, @@ -2032,6 +2031,7 @@ static int numamigrate_isolate_page(pg_data_t *pgdat, struct page *page) int page_lru; int nr_pages = thp_nr_pages(page); int order = compound_order(page); + struct zone *zone; VM_BUG_ON_PAGE(order && !PageTransHuge(page), page); @@ -2040,16 +2040,11 @@ static int numamigrate_isolate_page(pg_data_t *pgdat, struct page *page) return 0; /* Avoid migrating to a node that is nearly full */ - if (!migrate_balanced_pgdat(pgdat, nr_pages)) { - int z; - + if ((zone = migrate_balanced_pgdat(pgdat, nr_pages))) { if (!(sysctl_numa_balancing_mode & NUMA_BALANCING_MEMORY_TIERING)) return 0; - for (z = pgdat->nr_zones - 1; z >= 0; z--) { - if (managed_zone(pgdat->node_zones + z)) - break; - } - wakeup_kswapd(pgdat->node_zones + z, 0, order, ZONE_MOVABLE); + + wakeup_kswapd(zone, 0, order, ZONE_MOVABLE); return 0; } -- 2.33.1 >Best Regards, >Huang, Ying -- Wei Yang Help you, Help me