All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm/compaction: introduce a helper compact_zone_counters_init()
@ 2019-07-23  8:08 Yafang Shao
  2019-07-23  8:12 ` Michal Hocko
  0 siblings, 1 reply; 8+ messages in thread
From: Yafang Shao @ 2019-07-23  8:08 UTC (permalink / raw)
  To: akpm; +Cc: linux-mm, Yafang Shao, Michal Hocko, Mel Gorman, Yafang Shao

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.

Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Mel Gorman <mgorman@techsingularity.net>
Cc: Yafang Shao <shaoyafang@didiglobal.com>
---
 mm/compaction.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/mm/compaction.c b/mm/compaction.c
index a109b45..356348b 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -2065,6 +2065,19 @@ bool compaction_zonelist_suitable(struct alloc_context *ac, int order,
 	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)
 {
@@ -2075,6 +2088,7 @@ bool compaction_zonelist_suitable(struct alloc_context *ac, int order,
 	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);
@@ -2278,10 +2292,6 @@ static enum compact_result compact_zone_order(struct zone *zone, int order,
 {
 	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,
@@ -2418,10 +2428,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);
@@ -2526,8 +2532,6 @@ static void kcompactd_do_work(pg_data_t *pgdat)
 	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,
@@ -2551,10 +2555,6 @@ static void kcompactd_do_work(pg_data_t *pgdat)
 							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);
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-07-25 11:42 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-23  8:08 [PATCH] mm/compaction: introduce a helper compact_zone_counters_init() Yafang Shao
2019-07-23  8:12 ` Michal Hocko
2019-07-23  8:24   ` Yafang Shao
2019-07-23 21:40   ` Andrew Morton
2019-07-24 13:35     ` Vlastimil Babka
2019-07-25  0:19       ` Andrew Morton
2019-07-25  0:25         ` Andrew Morton
2019-07-25 11:42           ` Vlastimil Babka

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.