linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/hugetlb: fix nid mismatch in alloc_surplus_hugetlb_folio()
@ 2025-04-03  6:41 Liu Shixin
  2025-04-03  7:24 ` Oscar Salvador
  0 siblings, 1 reply; 2+ messages in thread
From: Liu Shixin @ 2025-04-03  6:41 UTC (permalink / raw)
  To: Andrew Morton, Muchun Song, Kefeng Wang, David Hildenbrand, Nanyong Sun
  Cc: linux-mm, linux-kernel, Liu Shixin

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



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] mm/hugetlb: fix nid mismatch in alloc_surplus_hugetlb_folio()
  2025-04-03  6:41 [PATCH] mm/hugetlb: fix nid mismatch in alloc_surplus_hugetlb_folio() Liu Shixin
@ 2025-04-03  7:24 ` Oscar Salvador
  0 siblings, 0 replies; 2+ messages in thread
From: Oscar Salvador @ 2025-04-03  7:24 UTC (permalink / raw)
  To: Liu Shixin
  Cc: Andrew Morton, Muchun Song, Kefeng Wang, David Hildenbrand,
	Nanyong Sun, linux-mm, linux-kernel

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-04-03  7:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-03  6:41 [PATCH] mm/hugetlb: fix nid mismatch in alloc_surplus_hugetlb_folio() Liu Shixin
2025-04-03  7:24 ` Oscar Salvador

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox