mm/hugetlb: fix nid mismatch in alloc_surplus_hugetlb_folio()
authorLiu Shixin <liushixin2@huawei.com>
Thu, 3 Apr 2025 06:41:38 +0000 (14:41 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Sat, 12 Apr 2025 00:32:36 +0000 (17:32 -0700)
It's wrong to use nid directly since the nid may be changed in allocation.
Use folio_nid() to obtain the nid of folio instead.

Fix: 2273dea6b1e1 ("mm/hugetlb: update nr_huge_pages and surplus_huge_pages together")
Link: https://lkml.kernel.org/r/20250403064138.2867929-1-liushixin2@huawei.com
Signed-off-by: Liu Shixin <liushixin2@huawei.com>
Acked-by: Oscar Salvador <osalvador@suse.de>
Cc: David Hildenbrand <david@redhat.com>
Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Nanyong Sun <sunnanyong@huawei.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/hugetlb.c

index 39f92aad7bd1e112a6a12e28f7108e0dd9dd5ce2..6670f9b9e07ae90d3badbc77614b50727fc1b230 100644 (file)
@@ -2271,7 +2271,7 @@ static struct folio *alloc_surplus_hugetlb_folio(struct hstate *h,
         * as surplus_pages, otherwise it might confuse
         * persistent_huge_pages() momentarily.
         */
-       __prep_account_new_huge_page(h, nid);
+       __prep_account_new_huge_page(h, folio_nid(folio));
 
        /*
         * We could have raced with the pool size change.