[PATCH] mm/hugetlb: fix nid mismatch in alloc_surplus_hugetlb_folio()

Liu Shixin posted 1 patch 10 months, 1 week ago
mm/hugetlb.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] mm/hugetlb: fix nid mismatch in alloc_surplus_hugetlb_folio()
Posted by Liu Shixin 10 months, 1 week ago
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")
Signed-off-by: Liu Shixin <liushixin2@huawei.com>
---
 mm/hugetlb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 6fccfe6d046c6..d538f8aa8203c 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -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.
-- 
2.34.1
Re: [PATCH] mm/hugetlb: fix nid mismatch in alloc_surplus_hugetlb_folio()
Posted by Oscar Salvador 10 months, 1 week ago
On Thu, Apr 03, 2025 at 02:41:38PM +0800, Liu Shixin wrote:
> 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")
> Signed-off-by: Liu Shixin <liushixin2@huawei.com>

Acked-by: Oscar Salvador <osalvador@suse.de>


-- 
Oscar Salvador
SUSE Labs