The patch titled Subject: mm/compaction: introduce a helper compact_zone_counters_init() has been added to the -mm tree. Its filename is mm-compaction-clear-total_migratefree_scanned-before-scanning-a-new-zone-fix.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/mm-compaction-clear-total_migratefree_scanned-before-scanning-a-new-zone-fix.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/mm-compaction-clear-total_migratefree_scanned-before-scanning-a-new-zone-fix.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Yafang Shao <laoar.shao@xxxxxxxxx> Subject: mm/compaction: introduce a helper compact_zone_counters_init() 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 to a single site. Link: http://lkml.kernel.org/r/1563869295-25748-1-git-send-email-laoar.shao@xxxxxxxxx Signed-off-by: Yafang Shao <laoar.shao@xxxxxxxxx> Cc: Michal Hocko <mhocko@xxxxxxxx> Cc: Mel Gorman <mgorman@xxxxxxxxxxxxxxxxxxx> Cc: Yafang Shao <shaoyafang@xxxxxxxxxxxxxx> Cc: David Rientjes <rientjes@xxxxxxxxxx> Cc: Vlastimil Babka <vbabka@xxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/compaction.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) --- a/mm/compaction.c~mm-compaction-clear-total_migratefree_scanned-before-scanning-a-new-zone-fix +++ a/mm/compaction.c @@ -2068,6 +2068,19 @@ 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) { @@ -2078,6 +2091,7 @@ compact_zone(struct compact_control *cc, const bool sync = cc->mode != MIGRATE_ASYNC; bool update_cached; + compact_zone_counters_init(cc); cc->migratetype = gfpflags_to_migratetype(cc->gfp_mask); ret = compaction_suitable(cc->zone, cc->order, cc->alloc_flags, cc->classzone_idx); @@ -2281,10 +2295,6 @@ static enum compact_result compact_zone_ { enum compact_result ret; struct compact_control cc = { - .nr_freepages = 0, - .nr_migratepages = 0, - .total_migrate_scanned = 0, - .total_free_scanned = 0, .order = order, .search_order = order, .gfp_mask = gfp_mask, @@ -2421,10 +2431,6 @@ static void compact_node(int nid) if (!populated_zone(zone)) continue; - cc.nr_freepages = 0; - cc.nr_migratepages = 0; - cc.total_migrate_scanned = 0; - cc.total_free_scanned = 0; cc.zone = zone; INIT_LIST_HEAD(&cc.freepages); INIT_LIST_HEAD(&cc.migratepages); @@ -2529,8 +2535,6 @@ static void kcompactd_do_work(pg_data_t struct compact_control cc = { .order = pgdat->kcompactd_max_order, .search_order = pgdat->kcompactd_max_order, - .total_migrate_scanned = 0, - .total_free_scanned = 0, .classzone_idx = pgdat->kcompactd_classzone_idx, .mode = MIGRATE_SYNC_LIGHT, .ignore_skip_hint = false, @@ -2554,10 +2558,6 @@ static void kcompactd_do_work(pg_data_t COMPACT_CONTINUE) continue; - cc.nr_freepages = 0; - cc.nr_migratepages = 0; - cc.total_migrate_scanned = 0; - cc.total_free_scanned = 0; cc.zone = zone; INIT_LIST_HEAD(&cc.freepages); INIT_LIST_HEAD(&cc.migratepages); _ Patches currently in -mm which might be from laoar.shao@xxxxxxxxx are mm-vmscan-expose-cgroup_ino-for-memcg-reclaim-tracepoints.patch mm-compaction-clear-total_migratefree_scanned-before-scanning-a-new-zone.patch mm-compaction-clear-total_migratefree_scanned-before-scanning-a-new-zone-fix.patch