Commit a9214443 authored by Mel Gorman's avatar Mel Gorman Committed by Linus Torvalds

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.netSigned-off-by: default avatarMel Gorman <mgorman@techsingularity.net>
Acked-by: default avatarVlastimil 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: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 6bb15450
...@@ -269,9 +269,10 @@ enum zone_watermarks { ...@@ -269,9 +269,10 @@ enum zone_watermarks {
NR_WMARK NR_WMARK
}; };
#define min_wmark_pages(z) (z->watermark[WMARK_MIN]) #define min_wmark_pages(z) (z->_watermark[WMARK_MIN])
#define low_wmark_pages(z) (z->watermark[WMARK_LOW]) #define low_wmark_pages(z) (z->_watermark[WMARK_LOW])
#define high_wmark_pages(z) (z->watermark[WMARK_HIGH]) #define high_wmark_pages(z) (z->_watermark[WMARK_HIGH])
#define wmark_pages(z, i) (z->_watermark[i])
struct per_cpu_pages { struct per_cpu_pages {
int count; /* number of pages in the list */ int count; /* number of pages in the list */
...@@ -362,7 +363,7 @@ struct zone { ...@@ -362,7 +363,7 @@ struct zone {
/* Read-mostly fields */ /* Read-mostly fields */
/* zone watermarks, access with *_wmark_pages(zone) macros */ /* zone watermarks, access with *_wmark_pages(zone) macros */
unsigned long watermark[NR_WMARK]; unsigned long _watermark[NR_WMARK];
unsigned long nr_reserved_highatomic; unsigned long nr_reserved_highatomic;
......
...@@ -1431,7 +1431,7 @@ static enum compact_result __compaction_suitable(struct zone *zone, int order, ...@@ -1431,7 +1431,7 @@ static enum compact_result __compaction_suitable(struct zone *zone, int order,
if (is_via_compact_memory(order)) if (is_via_compact_memory(order))
return COMPACT_CONTINUE; return COMPACT_CONTINUE;
watermark = zone->watermark[alloc_flags & ALLOC_WMARK_MASK]; watermark = wmark_pages(zone, alloc_flags & ALLOC_WMARK_MASK);
/* /*
* If watermarks for high-order allocation are already met, there * If watermarks for high-order allocation are already met, there
* should be no need for compaction at all. * should be no need for compaction at all.
......
...@@ -3376,7 +3376,7 @@ get_page_from_freelist(gfp_t gfp_mask, unsigned int order, int alloc_flags, ...@@ -3376,7 +3376,7 @@ get_page_from_freelist(gfp_t gfp_mask, unsigned int order, int alloc_flags,
} }
} }
mark = zone->watermark[alloc_flags & ALLOC_WMARK_MASK]; mark = wmark_pages(zone, alloc_flags & ALLOC_WMARK_MASK);
if (!zone_watermark_fast(zone, order, mark, if (!zone_watermark_fast(zone, order, mark,
ac_classzone_idx(ac), alloc_flags)) { ac_classzone_idx(ac), alloc_flags)) {
int ret; int ret;
...@@ -4793,7 +4793,7 @@ long si_mem_available(void) ...@@ -4793,7 +4793,7 @@ long si_mem_available(void)
pages[lru] = global_node_page_state(NR_LRU_BASE + lru); pages[lru] = global_node_page_state(NR_LRU_BASE + lru);
for_each_zone(zone) for_each_zone(zone)
wmark_low += zone->watermark[WMARK_LOW]; wmark_low += low_wmark_pages(zone);
/* /*
* Estimate the amount of memory available for userspace allocations, * Estimate the amount of memory available for userspace allocations,
...@@ -7431,13 +7431,13 @@ static void __setup_per_zone_wmarks(void) ...@@ -7431,13 +7431,13 @@ static void __setup_per_zone_wmarks(void)
min_pages = zone_managed_pages(zone) / 1024; min_pages = zone_managed_pages(zone) / 1024;
min_pages = clamp(min_pages, SWAP_CLUSTER_MAX, 128UL); min_pages = clamp(min_pages, SWAP_CLUSTER_MAX, 128UL);
zone->watermark[WMARK_MIN] = min_pages; zone->_watermark[WMARK_MIN] = min_pages;
} else { } else {
/* /*
* If it's a lowmem zone, reserve a number of pages * If it's a lowmem zone, reserve a number of pages
* proportionate to the zone's size. * proportionate to the zone's size.
*/ */
zone->watermark[WMARK_MIN] = tmp; zone->_watermark[WMARK_MIN] = tmp;
} }
/* /*
...@@ -7449,8 +7449,8 @@ static void __setup_per_zone_wmarks(void) ...@@ -7449,8 +7449,8 @@ static void __setup_per_zone_wmarks(void)
mult_frac(zone_managed_pages(zone), mult_frac(zone_managed_pages(zone),
watermark_scale_factor, 10000)); watermark_scale_factor, 10000));
zone->watermark[WMARK_LOW] = min_wmark_pages(zone) + tmp; zone->_watermark[WMARK_LOW] = min_wmark_pages(zone) + tmp;
zone->watermark[WMARK_HIGH] = min_wmark_pages(zone) + tmp * 2; zone->_watermark[WMARK_HIGH] = min_wmark_pages(zone) + tmp * 2;
spin_unlock_irqrestore(&zone->lock, flags); spin_unlock_irqrestore(&zone->lock, flags);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment