@@ -2078,6 +2078,17 @@ compact_zone(struct compact_control *cc, struct capture_control *capc)
2078
2078
const bool sync = cc -> mode != MIGRATE_ASYNC ;
2079
2079
bool update_cached ;
2080
2080
2081
+ /*
2082
+ * These counters track activities during zone compaction. Initialize
2083
+ * them before compacting a new zone.
2084
+ */
2085
+ cc -> total_migrate_scanned = 0 ;
2086
+ cc -> total_free_scanned = 0 ;
2087
+ cc -> nr_migratepages = 0 ;
2088
+ cc -> nr_freepages = 0 ;
2089
+ INIT_LIST_HEAD (& cc -> freepages );
2090
+ INIT_LIST_HEAD (& cc -> migratepages );
2091
+
2081
2092
cc -> migratetype = gfpflags_to_migratetype (cc -> gfp_mask );
2082
2093
ret = compaction_suitable (cc -> zone , cc -> order , cc -> alloc_flags ,
2083
2094
cc -> classzone_idx );
@@ -2281,10 +2292,6 @@ static enum compact_result compact_zone_order(struct zone *zone, int order,
2281
2292
{
2282
2293
enum compact_result ret ;
2283
2294
struct compact_control cc = {
2284
- .nr_freepages = 0 ,
2285
- .nr_migratepages = 0 ,
2286
- .total_migrate_scanned = 0 ,
2287
- .total_free_scanned = 0 ,
2288
2295
.order = order ,
2289
2296
.search_order = order ,
2290
2297
.gfp_mask = gfp_mask ,
@@ -2305,8 +2312,6 @@ static enum compact_result compact_zone_order(struct zone *zone, int order,
2305
2312
2306
2313
if (capture )
2307
2314
current -> capture_control = & capc ;
2308
- INIT_LIST_HEAD (& cc .freepages );
2309
- INIT_LIST_HEAD (& cc .migratepages );
2310
2315
2311
2316
ret = compact_zone (& cc , & capc );
2312
2317
@@ -2408,8 +2413,6 @@ static void compact_node(int nid)
2408
2413
struct zone * zone ;
2409
2414
struct compact_control cc = {
2410
2415
.order = -1 ,
2411
- .total_migrate_scanned = 0 ,
2412
- .total_free_scanned = 0 ,
2413
2416
.mode = MIGRATE_SYNC ,
2414
2417
.ignore_skip_hint = true,
2415
2418
.whole_zone = true,
@@ -2423,11 +2426,7 @@ static void compact_node(int nid)
2423
2426
if (!populated_zone (zone ))
2424
2427
continue ;
2425
2428
2426
- cc .nr_freepages = 0 ;
2427
- cc .nr_migratepages = 0 ;
2428
2429
cc .zone = zone ;
2429
- INIT_LIST_HEAD (& cc .freepages );
2430
- INIT_LIST_HEAD (& cc .migratepages );
2431
2430
2432
2431
compact_zone (& cc , NULL );
2433
2432
@@ -2529,8 +2528,6 @@ static void kcompactd_do_work(pg_data_t *pgdat)
2529
2528
struct compact_control cc = {
2530
2529
.order = pgdat -> kcompactd_max_order ,
2531
2530
.search_order = pgdat -> kcompactd_max_order ,
2532
- .total_migrate_scanned = 0 ,
2533
- .total_free_scanned = 0 ,
2534
2531
.classzone_idx = pgdat -> kcompactd_classzone_idx ,
2535
2532
.mode = MIGRATE_SYNC_LIGHT ,
2536
2533
.ignore_skip_hint = false,
@@ -2554,16 +2551,10 @@ static void kcompactd_do_work(pg_data_t *pgdat)
2554
2551
COMPACT_CONTINUE )
2555
2552
continue ;
2556
2553
2557
- cc .nr_freepages = 0 ;
2558
- cc .nr_migratepages = 0 ;
2559
- cc .total_migrate_scanned = 0 ;
2560
- cc .total_free_scanned = 0 ;
2561
- cc .zone = zone ;
2562
- INIT_LIST_HEAD (& cc .freepages );
2563
- INIT_LIST_HEAD (& cc .migratepages );
2564
-
2565
2554
if (kthread_should_stop ())
2566
2555
return ;
2556
+
2557
+ cc .zone = zone ;
2567
2558
status = compact_zone (& cc , NULL );
2568
2559
2569
2560
if (status == COMPACT_SUCCESS ) {
0 commit comments