Commit 382360d2 authored by Liu Shixin's avatar Liu Shixin Committed by Andrew Morton
Browse files

mm/hugetlb: fix nid mismatch in alloc_surplus_hugetlb_folio()

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: 2273dea6 ("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: default avatarLiu Shixin <liushixin2@huawei.com>
Acked-by: default avatarOscar 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: default avatarAndrew Morton <akpm@linux-foundation.org>
parent c5bb27e2
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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.