Skip to content

Commit a921444

Browse files
gormanmtorvalds
authored andcommitted
mm: move zone watermark accesses behind an accessor
This is a preparation patch only, no functional change. Link: http://lkml.kernel.org/r/20181123114528.28802-3-mgorman@techsingularity.net Signed-off-by: Mel Gorman <mgorman@techsingularity.net> Acked-by: Vlastimil Babka <vbabka@suse.cz> Cc: Andrea Arcangeli <aarcange@redhat.com> Cc: David Rientjes <rientjes@google.com> Cc: Michal Hocko <mhocko@kernel.org> Cc: Zi Yan <zi.yan@cs.rutgers.edu> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 6bb1545 commit a921444

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

include/linux/mmzone.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,9 +269,10 @@ enum zone_watermarks {
269269
NR_WMARK
270270
};
271271

272-
#define min_wmark_pages(z) (z->watermark[WMARK_MIN])
273-
#define low_wmark_pages(z) (z->watermark[WMARK_LOW])
274-
#define high_wmark_pages(z) (z->watermark[WMARK_HIGH])
272+
#define min_wmark_pages(z) (z->_watermark[WMARK_MIN])
273+
#define low_wmark_pages(z) (z->_watermark[WMARK_LOW])
274+
#define high_wmark_pages(z) (z->_watermark[WMARK_HIGH])
275+
#define wmark_pages(z, i) (z->_watermark[i])
275276

276277
struct per_cpu_pages {
277278
int count; /* number of pages in the list */
@@ -362,7 +363,7 @@ struct zone {
362363
/* Read-mostly fields */
363364

364365
/* zone watermarks, access with *_wmark_pages(zone) macros */
365-
unsigned long watermark[NR_WMARK];
366+
unsigned long _watermark[NR_WMARK];
366367

367368
unsigned long nr_reserved_highatomic;
368369

mm/compaction.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1431,7 +1431,7 @@ static enum compact_result __compaction_suitable(struct zone *zone, int order,
14311431
if (is_via_compact_memory(order))
14321432
return COMPACT_CONTINUE;
14331433

1434-
watermark = zone->watermark[alloc_flags & ALLOC_WMARK_MASK];
1434+
watermark = wmark_pages(zone, alloc_flags & ALLOC_WMARK_MASK);
14351435
/*
14361436
* If watermarks for high-order allocation are already met, there
14371437
* should be no need for compaction at all.

mm/page_alloc.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3376,7 +3376,7 @@ get_page_from_freelist(gfp_t gfp_mask, unsigned int order, int alloc_flags,
33763376
}
33773377
}
33783378

3379-
mark = zone->watermark[alloc_flags & ALLOC_WMARK_MASK];
3379+
mark = wmark_pages(zone, alloc_flags & ALLOC_WMARK_MASK);
33803380
if (!zone_watermark_fast(zone, order, mark,
33813381
ac_classzone_idx(ac), alloc_flags)) {
33823382
int ret;
@@ -4793,7 +4793,7 @@ long si_mem_available(void)
47934793
pages[lru] = global_node_page_state(NR_LRU_BASE + lru);
47944794

47954795
for_each_zone(zone)
4796-
wmark_low += zone->watermark[WMARK_LOW];
4796+
wmark_low += low_wmark_pages(zone);
47974797

47984798
/*
47994799
* Estimate the amount of memory available for userspace allocations,
@@ -7431,13 +7431,13 @@ static void __setup_per_zone_wmarks(void)
74317431

74327432
min_pages = zone_managed_pages(zone) / 1024;
74337433
min_pages = clamp(min_pages, SWAP_CLUSTER_MAX, 128UL);
7434-
zone->watermark[WMARK_MIN] = min_pages;
7434+
zone->_watermark[WMARK_MIN] = min_pages;
74357435
} else {
74367436
/*
74377437
* If it's a lowmem zone, reserve a number of pages
74387438
* proportionate to the zone's size.
74397439
*/
7440-
zone->watermark[WMARK_MIN] = tmp;
7440+
zone->_watermark[WMARK_MIN] = tmp;
74417441
}
74427442

74437443
/*
@@ -7449,8 +7449,8 @@ static void __setup_per_zone_wmarks(void)
74497449
mult_frac(zone_managed_pages(zone),
74507450
watermark_scale_factor, 10000));
74517451

7452-
zone->watermark[WMARK_LOW] = min_wmark_pages(zone) + tmp;
7453-
zone->watermark[WMARK_HIGH] = min_wmark_pages(zone) + tmp * 2;
7452+
zone->_watermark[WMARK_LOW] = min_wmark_pages(zone) + tmp;
7453+
zone->_watermark[WMARK_HIGH] = min_wmark_pages(zone) + tmp * 2;
74547454

74557455
spin_unlock_irqrestore(&zone->lock, flags);
74567456
}

0 commit comments

Comments
 (0)