diff mbox series

mm, page_alloc: skip to set lowmem_reserve[] for empty zones

Message ID 20181113031115.18050-1-richard.weiyang@gmail.com (mailing list archive)
State New, archived
Headers show
Series mm, page_alloc: skip to set lowmem_reserve[] for empty zones | expand

Commit Message

Wei Yang Nov. 13, 2018, 3:11 a.m. UTC
lowmem_reserve[] is used to make sure to keep some memory when
allocating memory for a higher zone. In case one zone is empty, no
managed_pages, this zone will never picked up by page allocator. Which
means its lowmem_reserve[] is never used.

Also, since its managed_pages is 0, it will not contribute to lower
zone's lowmem_reserve[] in case there is non empty lower zone.

This patch skip the zones to save some cycles.

Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
---
 mm/page_alloc.c | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series

Patch

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index a919ba5cb3c8..495feff1e5e4 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -7291,6 +7291,9 @@  static void setup_per_zone_lowmem_reserve(void)
 				idx--;
 				lower_zone = pgdat->node_zones + idx;
 
+				if (!lower_zone->managed_pages)
+					continue;
+
 				if (sysctl_lowmem_reserve_ratio[idx] < 1) {
 					sysctl_lowmem_reserve_ratio[idx] = 0;
 					lower_zone->lowmem_reserve[j] = 0;