Skip to content

Commit f7ec104

Browse files
Liu Shixintorvalds
authored andcommitted
mm/page_alloc: fix counting of managed_pages
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/20210527125707.3760259-1-liushixin2@huawei.com Fixes: f636615 ("mm/page_alloc.c: clear out zone->lowmem_reserve[] if the zone is empty") Signed-off-by: Liu Shixin <liushixin2@huawei.com> Reported-by: yangerkun <yangerkun@huawei.com> Reviewed-by: Baoquan He <bhe@redhat.com> Acked-by: David Hildenbrand <david@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent e47aa90 commit f7ec104

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

mm/page_alloc.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8240,14 +8240,14 @@ static void setup_per_zone_lowmem_reserve(void)
82408240
unsigned long managed_pages = 0;
82418241

82428242
for (j = i + 1; j < MAX_NR_ZONES; j++) {
8243-
if (clear) {
8244-
zone->lowmem_reserve[j] = 0;
8245-
} else {
8246-
struct zone *upper_zone = &pgdat->node_zones[j];
8243+
struct zone *upper_zone = &pgdat->node_zones[j];
8244+
8245+
managed_pages += zone_managed_pages(upper_zone);
82478246

8248-
managed_pages += zone_managed_pages(upper_zone);
8247+
if (clear)
8248+
zone->lowmem_reserve[j] = 0;
8249+
else
82498250
zone->lowmem_reserve[j] = managed_pages / ratio;
8250-
}
82518251
}
82528252
}
82538253
}

0 commit comments

Comments
 (0)