On Tue, Apr 25, 2023 at 11:12:28AM +0800, Huang, Ying wrote: > Johannes Weiner <hannes@xxxxxxxxxxx> writes: > > > Kswapd currently bails on higher-order allocations with an open-coded > > check for whether it's reclaimed the compaction gap. > > > > compaction_suitable() is the customary interface to coordinate reclaim > > with compaction. > > > > Signed-off-by: Johannes Weiner <hannes@xxxxxxxxxxx> > > --- > > mm/vmscan.c | 67 ++++++++++++++++++----------------------------------- > > 1 file changed, 23 insertions(+), 44 deletions(-) > > > > diff --git a/mm/vmscan.c b/mm/vmscan.c > > index ee8c8ca2e7b5..723705b9e4d9 100644 > > --- a/mm/vmscan.c > > +++ b/mm/vmscan.c > > @@ -6872,12 +6872,18 @@ static bool pgdat_balanced(pg_data_t *pgdat, int order, int highest_zoneidx) > > if (!managed_zone(zone)) > > continue; > > > > + /* Allocation can succeed in any zone, done */ > > if (sysctl_numa_balancing_mode & NUMA_BALANCING_MEMORY_TIERING) > > mark = wmark_pages(zone, WMARK_PROMO); > > else > > mark = high_wmark_pages(zone); > > if (zone_watermark_ok_safe(zone, order, mark, highest_zoneidx)) > > return true; > > + > > + /* Allocation can't succeed, but enough order-0 to compact */ > > + if (compaction_suitable(zone, order, > > + highest_zoneidx) == COMPACT_CONTINUE) > > + return true; > > Should we check the following first? > > order > 0 && zone_watermark_ok_safe(zone, 0, mark, highest_zoneidx) That's what compaction_suitable() does. It checks whether there are enough migration targets for compaction (COMPACT_CONTINUE) or whether reclaim needs to do some more work (COMPACT_SKIPPED).