Skip to content

Commit 97a225e

Browse files
JoonsooKimtorvalds
authored andcommitted
mm/page_alloc: integrate classzone_idx and high_zoneidx
classzone_idx is just different name for high_zoneidx now. So, integrate them and add some comment to struct alloc_context in order to reduce future confusion about the meaning of this variable. The accessor, ac_classzone_idx() is also removed since it isn't needed after integration. In addition to integration, this patch also renames high_zoneidx to highest_zoneidx since it represents more precise meaning. Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Reviewed-by: Baoquan He <bhe@redhat.com> Acked-by: Vlastimil Babka <vbabka@suse.cz> Acked-by: David Rientjes <rientjes@google.com> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Mel Gorman <mgorman@techsingularity.net> Cc: Michal Hocko <mhocko@kernel.org> Cc: Minchan Kim <minchan@kernel.org> Cc: Ye Xiaolong <xiaolong.ye@intel.com> Link: http://lkml.kernel.org/r/1587095923-7515-3-git-send-email-iamjoonsoo.kim@lge.com Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 3334a45 commit 97a225e

12 files changed

Lines changed: 175 additions & 150 deletions

File tree

‎include/linux/compaction.h‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ extern enum compact_result try_to_compact_pages(gfp_t gfp_mask,
9797
struct page **page);
9898
extern void reset_isolation_suitable(pg_data_t *pgdat);
9999
extern enum compact_result compaction_suitable(struct zone *zone, int order,
100-
unsigned int alloc_flags, int classzone_idx);
100+
unsigned int alloc_flags, int highest_zoneidx);
101101

102102
extern void defer_compaction(struct zone *zone, int order);
103103
extern bool compaction_deferred(struct zone *zone, int order);
@@ -182,15 +182,15 @@ bool compaction_zonelist_suitable(struct alloc_context *ac, int order,
182182

183183
extern int kcompactd_run(int nid);
184184
extern void kcompactd_stop(int nid);
185-
extern void wakeup_kcompactd(pg_data_t *pgdat, int order, int classzone_idx);
185+
extern void wakeup_kcompactd(pg_data_t *pgdat, int order, int highest_zoneidx);
186186

187187
#else
188188
static inline void reset_isolation_suitable(pg_data_t *pgdat)
189189
{
190190
}
191191

192192
static inline enum compact_result compaction_suitable(struct zone *zone, int order,
193-
int alloc_flags, int classzone_idx)
193+
int alloc_flags, int highest_zoneidx)
194194
{
195195
return COMPACT_SKIPPED;
196196
}
@@ -232,7 +232,8 @@ static inline void kcompactd_stop(int nid)
232232
{
233233
}
234234

235-
static inline void wakeup_kcompactd(pg_data_t *pgdat, int order, int classzone_idx)
235+
static inline void wakeup_kcompactd(pg_data_t *pgdat,
236+
int order, int highest_zoneidx)
236237
{
237238
}
238239

‎include/linux/mmzone.h‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -699,13 +699,13 @@ typedef struct pglist_data {
699699
struct task_struct *kswapd; /* Protected by
700700
mem_hotplug_begin/end() */
701701
int kswapd_order;
702-
enum zone_type kswapd_classzone_idx;
702+
enum zone_type kswapd_highest_zoneidx;
703703

704704
int kswapd_failures; /* Number of 'reclaimed == 0' runs */
705705

706706
#ifdef CONFIG_COMPACTION
707707
int kcompactd_max_order;
708-
enum zone_type kcompactd_classzone_idx;
708+
enum zone_type kcompactd_highest_zoneidx;
709709
wait_queue_head_t kcompactd_wait;
710710
struct task_struct *kcompactd;
711711
#endif
@@ -783,15 +783,15 @@ static inline bool pgdat_is_empty(pg_data_t *pgdat)
783783

784784
void build_all_zonelists(pg_data_t *pgdat);
785785
void wakeup_kswapd(struct zone *zone, gfp_t gfp_mask, int order,
786-
enum zone_type classzone_idx);
786+
enum zone_type highest_zoneidx);
787787
bool __zone_watermark_ok(struct zone *z, unsigned int order, unsigned long mark,
788-
int classzone_idx, unsigned int alloc_flags,
788+
int highest_zoneidx, unsigned int alloc_flags,
789789
long free_pages);
790790
bool zone_watermark_ok(struct zone *z, unsigned int order,
791-
unsigned long mark, int classzone_idx,
791+
unsigned long mark, int highest_zoneidx,
792792
unsigned int alloc_flags);
793793
bool zone_watermark_ok_safe(struct zone *z, unsigned int order,
794-
unsigned long mark, int classzone_idx);
794+
unsigned long mark, int highest_zoneidx);
795795
enum memmap_context {
796796
MEMMAP_EARLY,
797797
MEMMAP_HOTPLUG,

‎include/trace/events/compaction.h‎

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -314,40 +314,44 @@ TRACE_EVENT(mm_compaction_kcompactd_sleep,
314314

315315
DECLARE_EVENT_CLASS(kcompactd_wake_template,
316316

317-
TP_PROTO(int nid, int order, enum zone_type classzone_idx),
317+
TP_PROTO(int nid, int order, enum zone_type highest_zoneidx),
318318

319-
TP_ARGS(nid, order, classzone_idx),
319+
TP_ARGS(nid, order, highest_zoneidx),
320320

321321
TP_STRUCT__entry(
322322
__field(int, nid)
323323
__field(int, order)
324-
__field(enum zone_type, classzone_idx)
324+
__field(enum zone_type, highest_zoneidx)
325325
),
326326

327327
TP_fast_assign(
328328
__entry->nid = nid;
329329
__entry->order = order;
330-
__entry->classzone_idx = classzone_idx;
330+
__entry->highest_zoneidx = highest_zoneidx;
331331
),
332332

333+
/*
334+
* classzone_idx is previous name of the highest_zoneidx.
335+
* Reason not to change it is the ABI requirement of the tracepoint.
336+
*/
333337
TP_printk("nid=%d order=%d classzone_idx=%-8s",
334338
__entry->nid,
335339
__entry->order,
336-
__print_symbolic(__entry->classzone_idx, ZONE_TYPE))
340+
__print_symbolic(__entry->highest_zoneidx, ZONE_TYPE))
337341
);
338342

339343
DEFINE_EVENT(kcompactd_wake_template, mm_compaction_wakeup_kcompactd,
340344

341-
TP_PROTO(int nid, int order, enum zone_type classzone_idx),
345+
TP_PROTO(int nid, int order, enum zone_type highest_zoneidx),
342346

343-
TP_ARGS(nid, order, classzone_idx)
347+
TP_ARGS(nid, order, highest_zoneidx)
344348
);
345349

346350
DEFINE_EVENT(kcompactd_wake_template, mm_compaction_kcompactd_wake,
347351

348-
TP_PROTO(int nid, int order, enum zone_type classzone_idx),
352+
TP_PROTO(int nid, int order, enum zone_type highest_zoneidx),
349353

350-
TP_ARGS(nid, order, classzone_idx)
354+
TP_ARGS(nid, order, highest_zoneidx)
351355
);
352356
#endif
353357

‎include/trace/events/vmscan.h‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ TRACE_EVENT(mm_shrink_slab_end,
265265
);
266266

267267
TRACE_EVENT(mm_vmscan_lru_isolate,
268-
TP_PROTO(int classzone_idx,
268+
TP_PROTO(int highest_zoneidx,
269269
int order,
270270
unsigned long nr_requested,
271271
unsigned long nr_scanned,
@@ -274,10 +274,10 @@ TRACE_EVENT(mm_vmscan_lru_isolate,
274274
isolate_mode_t isolate_mode,
275275
int lru),
276276

277-
TP_ARGS(classzone_idx, order, nr_requested, nr_scanned, nr_skipped, nr_taken, isolate_mode, lru),
277+
TP_ARGS(highest_zoneidx, order, nr_requested, nr_scanned, nr_skipped, nr_taken, isolate_mode, lru),
278278

279279
TP_STRUCT__entry(
280-
__field(int, classzone_idx)
280+
__field(int, highest_zoneidx)
281281
__field(int, order)
282282
__field(unsigned long, nr_requested)
283283
__field(unsigned long, nr_scanned)
@@ -288,7 +288,7 @@ TRACE_EVENT(mm_vmscan_lru_isolate,
288288
),
289289

290290
TP_fast_assign(
291-
__entry->classzone_idx = classzone_idx;
291+
__entry->highest_zoneidx = highest_zoneidx;
292292
__entry->order = order;
293293
__entry->nr_requested = nr_requested;
294294
__entry->nr_scanned = nr_scanned;
@@ -298,9 +298,13 @@ TRACE_EVENT(mm_vmscan_lru_isolate,
298298
__entry->lru = lru;
299299
),
300300

301+
/*
302+
* classzone is previous name of the highest_zoneidx.
303+
* Reason not to change it is the ABI requirement of the tracepoint.
304+
*/
301305
TP_printk("isolate_mode=%d classzone=%d order=%d nr_requested=%lu nr_scanned=%lu nr_skipped=%lu nr_taken=%lu lru=%s",
302306
__entry->isolate_mode,
303-
__entry->classzone_idx,
307+
__entry->highest_zoneidx,
304308
__entry->order,
305309
__entry->nr_requested,
306310
__entry->nr_scanned,

‎mm/compaction.c‎

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1968,7 +1968,7 @@ static enum compact_result compact_finished(struct compact_control *cc)
19681968
*/
19691969
static enum compact_result __compaction_suitable(struct zone *zone, int order,
19701970
unsigned int alloc_flags,
1971-
int classzone_idx,
1971+
int highest_zoneidx,
19721972
unsigned long wmark_target)
19731973
{
19741974
unsigned long watermark;
@@ -1981,7 +1981,7 @@ static enum compact_result __compaction_suitable(struct zone *zone, int order,
19811981
* If watermarks for high-order allocation are already met, there
19821982
* should be no need for compaction at all.
19831983
*/
1984-
if (zone_watermark_ok(zone, order, watermark, classzone_idx,
1984+
if (zone_watermark_ok(zone, order, watermark, highest_zoneidx,
19851985
alloc_flags))
19861986
return COMPACT_SUCCESS;
19871987

@@ -1991,9 +1991,9 @@ static enum compact_result __compaction_suitable(struct zone *zone, int order,
19911991
* watermark and alloc_flags have to match, or be more pessimistic than
19921992
* the check in __isolate_free_page(). We don't use the direct
19931993
* compactor's alloc_flags, as they are not relevant for freepage
1994-
* isolation. We however do use the direct compactor's classzone_idx to
1995-
* skip over zones where lowmem reserves would prevent allocation even
1996-
* if compaction succeeds.
1994+
* isolation. We however do use the direct compactor's highest_zoneidx
1995+
* to skip over zones where lowmem reserves would prevent allocation
1996+
* even if compaction succeeds.
19971997
* For costly orders, we require low watermark instead of min for
19981998
* compaction to proceed to increase its chances.
19991999
* ALLOC_CMA is used, as pages in CMA pageblocks are considered
@@ -2002,7 +2002,7 @@ static enum compact_result __compaction_suitable(struct zone *zone, int order,
20022002
watermark = (order > PAGE_ALLOC_COSTLY_ORDER) ?
20032003
low_wmark_pages(zone) : min_wmark_pages(zone);
20042004
watermark += compact_gap(order);
2005-
if (!__zone_watermark_ok(zone, 0, watermark, classzone_idx,
2005+
if (!__zone_watermark_ok(zone, 0, watermark, highest_zoneidx,
20062006
ALLOC_CMA, wmark_target))
20072007
return COMPACT_SKIPPED;
20082008

@@ -2011,12 +2011,12 @@ static enum compact_result __compaction_suitable(struct zone *zone, int order,
20112011

20122012
enum compact_result compaction_suitable(struct zone *zone, int order,
20132013
unsigned int alloc_flags,
2014-
int classzone_idx)
2014+
int highest_zoneidx)
20152015
{
20162016
enum compact_result ret;
20172017
int fragindex;
20182018

2019-
ret = __compaction_suitable(zone, order, alloc_flags, classzone_idx,
2019+
ret = __compaction_suitable(zone, order, alloc_flags, highest_zoneidx,
20202020
zone_page_state(zone, NR_FREE_PAGES));
20212021
/*
20222022
* fragmentation index determines if allocation failures are due to
@@ -2057,8 +2057,8 @@ bool compaction_zonelist_suitable(struct alloc_context *ac, int order,
20572057
* Make sure at least one zone would pass __compaction_suitable if we continue
20582058
* retrying the reclaim.
20592059
*/
2060-
for_each_zone_zonelist_nodemask(zone, z, ac->zonelist, ac->high_zoneidx,
2061-
ac->nodemask) {
2060+
for_each_zone_zonelist_nodemask(zone, z, ac->zonelist,
2061+
ac->highest_zoneidx, ac->nodemask) {
20622062
unsigned long available;
20632063
enum compact_result compact_result;
20642064

@@ -2071,7 +2071,7 @@ bool compaction_zonelist_suitable(struct alloc_context *ac, int order,
20712071
available = zone_reclaimable_pages(zone) / order;
20722072
available += zone_page_state_snapshot(zone, NR_FREE_PAGES);
20732073
compact_result = __compaction_suitable(zone, order, alloc_flags,
2074-
ac_classzone_idx(ac), available);
2074+
ac->highest_zoneidx, available);
20752075
if (compact_result != COMPACT_SKIPPED)
20762076
return true;
20772077
}
@@ -2102,7 +2102,7 @@ compact_zone(struct compact_control *cc, struct capture_control *capc)
21022102

21032103
cc->migratetype = gfpflags_to_migratetype(cc->gfp_mask);
21042104
ret = compaction_suitable(cc->zone, cc->order, cc->alloc_flags,
2105-
cc->classzone_idx);
2105+
cc->highest_zoneidx);
21062106
/* Compaction is likely to fail */
21072107
if (ret == COMPACT_SUCCESS || ret == COMPACT_SKIPPED)
21082108
return ret;
@@ -2293,7 +2293,7 @@ compact_zone(struct compact_control *cc, struct capture_control *capc)
22932293

22942294
static enum compact_result compact_zone_order(struct zone *zone, int order,
22952295
gfp_t gfp_mask, enum compact_priority prio,
2296-
unsigned int alloc_flags, int classzone_idx,
2296+
unsigned int alloc_flags, int highest_zoneidx,
22972297
struct page **capture)
22982298
{
22992299
enum compact_result ret;
@@ -2305,7 +2305,7 @@ static enum compact_result compact_zone_order(struct zone *zone, int order,
23052305
.mode = (prio == COMPACT_PRIO_ASYNC) ?
23062306
MIGRATE_ASYNC : MIGRATE_SYNC_LIGHT,
23072307
.alloc_flags = alloc_flags,
2308-
.classzone_idx = classzone_idx,
2308+
.highest_zoneidx = highest_zoneidx,
23092309
.direct_compaction = true,
23102310
.whole_zone = (prio == MIN_COMPACT_PRIORITY),
23112311
.ignore_skip_hint = (prio == MIN_COMPACT_PRIORITY),
@@ -2361,8 +2361,8 @@ enum compact_result try_to_compact_pages(gfp_t gfp_mask, unsigned int order,
23612361
trace_mm_compaction_try_to_compact_pages(order, gfp_mask, prio);
23622362

23632363
/* Compact each zone in the list */
2364-
for_each_zone_zonelist_nodemask(zone, z, ac->zonelist, ac->high_zoneidx,
2365-
ac->nodemask) {
2364+
for_each_zone_zonelist_nodemask(zone, z, ac->zonelist,
2365+
ac->highest_zoneidx, ac->nodemask) {
23662366
enum compact_result status;
23672367

23682368
if (prio > MIN_COMPACT_PRIORITY
@@ -2372,7 +2372,7 @@ enum compact_result try_to_compact_pages(gfp_t gfp_mask, unsigned int order,
23722372
}
23732373

23742374
status = compact_zone_order(zone, order, gfp_mask, prio,
2375-
alloc_flags, ac_classzone_idx(ac), capture);
2375+
alloc_flags, ac->highest_zoneidx, capture);
23762376
rc = max(status, rc);
23772377

23782378
/* The allocation should succeed, stop compacting */
@@ -2507,16 +2507,16 @@ static bool kcompactd_node_suitable(pg_data_t *pgdat)
25072507
{
25082508
int zoneid;
25092509
struct zone *zone;
2510-
enum zone_type classzone_idx = pgdat->kcompactd_classzone_idx;
2510+
enum zone_type highest_zoneidx = pgdat->kcompactd_highest_zoneidx;
25112511

2512-
for (zoneid = 0; zoneid <= classzone_idx; zoneid++) {
2512+
for (zoneid = 0; zoneid <= highest_zoneidx; zoneid++) {
25132513
zone = &pgdat->node_zones[zoneid];
25142514

25152515
if (!populated_zone(zone))
25162516
continue;
25172517

25182518
if (compaction_suitable(zone, pgdat->kcompactd_max_order, 0,
2519-
classzone_idx) == COMPACT_CONTINUE)
2519+
highest_zoneidx) == COMPACT_CONTINUE)
25202520
return true;
25212521
}
25222522

@@ -2534,16 +2534,16 @@ static void kcompactd_do_work(pg_data_t *pgdat)
25342534
struct compact_control cc = {
25352535
.order = pgdat->kcompactd_max_order,
25362536
.search_order = pgdat->kcompactd_max_order,
2537-
.classzone_idx = pgdat->kcompactd_classzone_idx,
2537+
.highest_zoneidx = pgdat->kcompactd_highest_zoneidx,
25382538
.mode = MIGRATE_SYNC_LIGHT,
25392539
.ignore_skip_hint = false,
25402540
.gfp_mask = GFP_KERNEL,
25412541
};
25422542
trace_mm_compaction_kcompactd_wake(pgdat->node_id, cc.order,
2543-
cc.classzone_idx);
2543+
cc.highest_zoneidx);
25442544
count_compact_event(KCOMPACTD_WAKE);
25452545

2546-
for (zoneid = 0; zoneid <= cc.classzone_idx; zoneid++) {
2546+
for (zoneid = 0; zoneid <= cc.highest_zoneidx; zoneid++) {
25472547
int status;
25482548

25492549
zone = &pgdat->node_zones[zoneid];
@@ -2592,25 +2592,25 @@ static void kcompactd_do_work(pg_data_t *pgdat)
25922592

25932593
/*
25942594
* Regardless of success, we are done until woken up next. But remember
2595-
* the requested order/classzone_idx in case it was higher/tighter than
2596-
* our current ones
2595+
* the requested order/highest_zoneidx in case it was higher/tighter
2596+
* than our current ones
25972597
*/
25982598
if (pgdat->kcompactd_max_order <= cc.order)
25992599
pgdat->kcompactd_max_order = 0;
2600-
if (pgdat->kcompactd_classzone_idx >= cc.classzone_idx)
2601-
pgdat->kcompactd_classzone_idx = pgdat->nr_zones - 1;
2600+
if (pgdat->kcompactd_highest_zoneidx >= cc.highest_zoneidx)
2601+
pgdat->kcompactd_highest_zoneidx = pgdat->nr_zones - 1;
26022602
}
26032603

2604-
void wakeup_kcompactd(pg_data_t *pgdat, int order, int classzone_idx)
2604+
void wakeup_kcompactd(pg_data_t *pgdat, int order, int highest_zoneidx)
26052605
{
26062606
if (!order)
26072607
return;
26082608

26092609
if (pgdat->kcompactd_max_order < order)
26102610
pgdat->kcompactd_max_order = order;
26112611

2612-
if (pgdat->kcompactd_classzone_idx > classzone_idx)
2613-
pgdat->kcompactd_classzone_idx = classzone_idx;
2612+
if (pgdat->kcompactd_highest_zoneidx > highest_zoneidx)
2613+
pgdat->kcompactd_highest_zoneidx = highest_zoneidx;
26142614

26152615
/*
26162616
* Pairs with implicit barrier in wait_event_freezable()
@@ -2623,7 +2623,7 @@ void wakeup_kcompactd(pg_data_t *pgdat, int order, int classzone_idx)
26232623
return;
26242624

26252625
trace_mm_compaction_wakeup_kcompactd(pgdat->node_id, order,
2626-
classzone_idx);
2626+
highest_zoneidx);
26272627
wake_up_interruptible(&pgdat->kcompactd_wait);
26282628
}
26292629

@@ -2644,7 +2644,7 @@ static int kcompactd(void *p)
26442644
set_freezable();
26452645

26462646
pgdat->kcompactd_max_order = 0;
2647-
pgdat->kcompactd_classzone_idx = pgdat->nr_zones - 1;
2647+
pgdat->kcompactd_highest_zoneidx = pgdat->nr_zones - 1;
26482648

26492649
while (!kthread_should_stop()) {
26502650
unsigned long pflags;

0 commit comments

Comments
 (0)