Re: [PATCH] mm/compaction: introduce a helper compact_zone_counters_init()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 7/23/19 11:40 PM, Andrew Morton wrote:
> 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.

I have squashed everything locally, and for the result:

Reviewed-by: Vlastimil Babka <vbabka@xxxxxxx>

Also, why not squash some more?

----8<----
diff --git a/mm/compaction.c b/mm/compaction.c
index dcbe95fa8e28..cfe1457352f9 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -2083,6 +2083,8 @@ compact_zone(struct compact_control *cc, struct capture_control *capc)
 	cc->total_free_scanned = 0;
 	cc->nr_migratepages = 0;
 	cc->nr_freepages = 0;
+	INIT_LIST_HEAD(&cc->freepages);
+	INIT_LIST_HEAD(&cc->migratepages);
 
 	cc->migratetype = gfpflags_to_migratetype(cc->gfp_mask);
 	ret = compaction_suitable(cc->zone, cc->order, cc->alloc_flags,
@@ -2307,8 +2309,6 @@ static enum compact_result compact_zone_order(struct zone *zone, int order,
 
 	if (capture)
 		current->capture_control = &capc;
-	INIT_LIST_HEAD(&cc.freepages);
-	INIT_LIST_HEAD(&cc.migratepages);
 
 	ret = compact_zone(&cc, &capc);
 
@@ -2424,8 +2424,6 @@ static void compact_node(int nid)
 			continue;
 
 		cc.zone = zone;
-		INIT_LIST_HEAD(&cc.freepages);
-		INIT_LIST_HEAD(&cc.migratepages);
 
 		compact_zone(&cc, NULL);
 
@@ -2551,8 +2549,6 @@ static void kcompactd_do_work(pg_data_t *pgdat)
 			continue;
 
 		cc.zone = zone;
-		INIT_LIST_HEAD(&cc.freepages);
-		INIT_LIST_HEAD(&cc.migratepages);
 
 		if (kthread_should_stop())
 			return;




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux