lkml.org 
[lkml]   [2021]   [Jul]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.13 387/800] mm/page_alloc: fix counting of managed_pages
    Date
    From: Liu Shixin <liushixin2@huawei.com>

    [ Upstream commit f7ec104458e00d27a190348ac3a513f3df3699a4 ]

    commit f63661566fad ("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: f63661566fad ("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>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    mm/page_alloc.c | 12 ++++++------
    1 file changed, 6 insertions(+), 6 deletions(-)

    diff --git a/mm/page_alloc.c b/mm/page_alloc.c
    index 2bf03c76504b..fc5beebf6988 100644
    --- a/mm/page_alloc.c
    +++ b/mm/page_alloc.c
    @@ -8087,14 +8087,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;
    - }
    }
    }
    }
    --
    2.30.2


    \
     
     \ /
      Last update: 2021-07-12 10:40    [W:4.094 / U:0.336 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site