On Tue, 23 Jul 2019 10:12:18 +0200 Michal Hocko <mhocko@xxxxxxxx> wrote: > On Tue 23-07-19 04:08:15, Yafang Shao wrote: > > This is the follow-up of the > > commit "mm/compaction.c: clear total_{migrate,free}_scanned before scanning a new zone". > > > > These counters are used to track activities during compacting a zone, > > and they will be set to zero before compacting a new zone in all compact > > paths. Move all these common settings into compact_zone() for better > > management. A new helper compact_zone_counters_init() is introduced for > > this purpose. > > The helper seems excessive a bit because we have a single call site but > other than that this is an improvement to the current fragile and > duplicated code. > > I would just get rid of the helper and squash it to your previous patch > which Andrew already took to the mm tree. --- a/mm/compaction.c~mm-compaction-clear-total_migratefree_scanned-before-scanning-a-new-zone-fix-fix +++ a/mm/compaction.c @@ -2068,19 +2068,6 @@ bool compaction_zonelist_suitable(struct return false; } - -/* - * Bellow counters are used to track activities during compacting a zone. - * Before compacting a new zone, we should init these counters first. - */ -static void compact_zone_counters_init(struct compact_control *cc) -{ - cc->total_migrate_scanned = 0; - cc->total_free_scanned = 0; - cc->nr_migratepages = 0; - cc->nr_freepages = 0; -} - static enum compact_result compact_zone(struct compact_control *cc, struct capture_control *capc) { @@ -2091,7 +2078,15 @@ compact_zone(struct compact_control *cc, const bool sync = cc->mode != MIGRATE_ASYNC; bool update_cached; - compact_zone_counters_init(cc); + /* + * These counters track activities during zone compaction. Initialize + * them before compacting a new zone. + */ + cc->total_migrate_scanned = 0; + cc->total_free_scanned = 0; + cc->nr_migratepages = 0; + cc->nr_freepages = 0; + cc->migratetype = gfpflags_to_migratetype(cc->gfp_mask); ret = compaction_suitable(cc->zone, cc->order, cc->alloc_flags, cc->classzone_idx); _