Commit f7ec1044 authored by Liu Shixin's avatar Liu Shixin Committed by Linus Torvalds
Browse files

mm/page_alloc: fix counting of managed_pages

commit f6366156 ("mm/page_alloc.c: clear out zone->lowmem_reserve[] if
the zone is empty") clears out zone->lowmem_reserve[] if zone is empty.
But when zone is not empty and sysctl_lowmem_reserve_ratio[i] is set to
zero, zone_managed_pages(zone) is not counted in the managed_pages either.
This is inconsistent with the description of lowmem_reserve, so fix it.

Link: https://lkml.kernel.org/r/20210527125707.3760259-1-liushixin2@huawei.com


Fixes: f6366156 ("mm/page_alloc.c: clear out zone->lowmem_reserve[] if the zone is empty")
Signed-off-by: default avatarLiu Shixin <liushixin2@huawei.com>
Reported-by: default avataryangerkun <yangerkun@huawei.com>
Reviewed-by: default avatarBaoquan He <bhe@redhat.com>
Acked-by: default avatarDavid Hildenbrand <david@redhat.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent e47aa905
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -8240,17 +8240,17 @@ static void setup_per_zone_lowmem_reserve(void)
			unsigned long managed_pages = 0;

			for (j = i + 1; j < MAX_NR_ZONES; j++) {
				if (clear) {
					zone->lowmem_reserve[j] = 0;
				} else {
				struct zone *upper_zone = &pgdat->node_zones[j];

				managed_pages += zone_managed_pages(upper_zone);

				if (clear)
					zone->lowmem_reserve[j] = 0;
				else
					zone->lowmem_reserve[j] = managed_pages / ratio;
			}
		}
	}
	}

	/* update totalreserve_pages */
	calculate_totalreserve_pages();