Skip to content

Commit

Permalink
mm/page_alloc: fix counting of managed_pages
Browse files Browse the repository at this point in the history
commit f636615 ("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/[email protected]
Fixes: f636615 ("mm/page_alloc.c: clear out zone->lowmem_reserve[] if the zone is empty")
Signed-off-by: Liu Shixin <[email protected]>
Reported-by: yangerkun <[email protected]>
Reviewed-by: Baoquan He <[email protected]>
Acked-by: David Hildenbrand <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Liu Shixin authored and torvalds committed Jun 29, 2021
1 parent e47aa90 commit f7ec104
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions mm/page_alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -8240,14 +8240,14 @@ 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];
struct zone *upper_zone = &pgdat->node_zones[j];

managed_pages += zone_managed_pages(upper_zone);

managed_pages += zone_managed_pages(upper_zone);
if (clear)
zone->lowmem_reserve[j] = 0;
else
zone->lowmem_reserve[j] = managed_pages / ratio;
}
}
}
}
Expand Down

0 comments on commit f7ec104

Please sign in to comment.