lkml.org 
[lkml]   [2022]   [Jul]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH v3 12/16] mm/huge_memory: minor cleanup for split_huge_pages_all
    Date
    There is nothing to do if a zone doesn't have any pages managed by the
    buddy allocator. So we should check managed_zone instead. Also if a thp
    is found, there's no need to traverse the subpages again.

    Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
    ---
    mm/huge_memory.c | 7 ++++++-
    1 file changed, 6 insertions(+), 1 deletion(-)

    diff --git a/mm/huge_memory.c b/mm/huge_memory.c
    index 6d95751ebfc9..77be7dec1420 100644
    --- a/mm/huge_memory.c
    +++ b/mm/huge_memory.c
    @@ -2961,9 +2961,12 @@ static void split_huge_pages_all(void)
    unsigned long total = 0, split = 0;

    pr_debug("Split all THPs\n");
    - for_each_populated_zone(zone) {
    + for_each_zone(zone) {
    + if (!managed_zone(zone))
    + continue;
    max_zone_pfn = zone_end_pfn(zone);
    for (pfn = zone->zone_start_pfn; pfn < max_zone_pfn; pfn++) {
    + int nr_pages;
    if (!pfn_valid(pfn))
    continue;

    @@ -2979,8 +2982,10 @@ static void split_huge_pages_all(void)

    total++;
    lock_page(page);
    + nr_pages = thp_nr_pages(page);
    if (!split_huge_page(page))
    split++;
    + pfn += nr_pages - 1;
    unlock_page(page);
    next:
    put_page(page);
    --
    2.23.0
    \
     
     \ /
      Last update: 2022-07-04 15:25    [W:4.132 / U:0.140 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site