Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm: hugetlb: convert to account_new_hugetlb_folio()

In order to avoid the wrong nid passed into the account, and we did make
such mistake before, so it's better to move folio_nid() into
account_new_hugetlb_folio().

Link: https://lkml.kernel.org/r/20250910133958.301467-3-wangkefeng.wang@huawei.com
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
Acked-by: Oscar Salvador <osalvador@suse.de>
Reviewed-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>
Reviewed-by: Zi Yan <ziy@nvidia.com>
Cc: Brendan Jackman <jackmanb@google.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Jane Chu <jane.chu@oracle.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Kefeng Wang and committed by
Andrew Morton
4094d343 902020f0

+8 -8
+8 -8
mm/hugetlb.c
··· 1890 1890 /* 1891 1891 * Must be called with the hugetlb lock held 1892 1892 */ 1893 - static void __prep_account_new_huge_page(struct hstate *h, int nid) 1893 + static void account_new_hugetlb_folio(struct hstate *h, struct folio *folio) 1894 1894 { 1895 1895 lockdep_assert_held(&hugetlb_lock); 1896 1896 h->nr_huge_pages++; 1897 - h->nr_huge_pages_node[nid]++; 1897 + h->nr_huge_pages_node[folio_nid(folio)]++; 1898 1898 } 1899 1899 1900 1900 static void init_new_hugetlb_folio(struct hstate *h, struct folio *folio) ··· 2020 2020 /* Add all new pool pages to free lists in one lock cycle */ 2021 2021 spin_lock_irqsave(&hugetlb_lock, flags); 2022 2022 list_for_each_entry_safe(folio, tmp_f, folio_list, lru) { 2023 - __prep_account_new_huge_page(h, folio_nid(folio)); 2023 + account_new_hugetlb_folio(h, folio); 2024 2024 enqueue_hugetlb_folio(h, folio); 2025 2025 } 2026 2026 spin_unlock_irqrestore(&hugetlb_lock, flags); ··· 2232 2232 * as surplus_pages, otherwise it might confuse 2233 2233 * persistent_huge_pages() momentarily. 2234 2234 */ 2235 - __prep_account_new_huge_page(h, folio_nid(folio)); 2235 + account_new_hugetlb_folio(h, folio); 2236 2236 2237 2237 /* 2238 2238 * We could have raced with the pool size change. ··· 2270 2270 return NULL; 2271 2271 2272 2272 spin_lock_irq(&hugetlb_lock); 2273 - __prep_account_new_huge_page(h, folio_nid(folio)); 2273 + account_new_hugetlb_folio(h, folio); 2274 2274 spin_unlock_irq(&hugetlb_lock); 2275 2275 2276 2276 /* fresh huge pages are frozen */ ··· 2829 2829 /* 2830 2830 * Ok, old_folio is still a genuine free hugepage. Remove it from 2831 2831 * the freelist and decrease the counters. These will be 2832 - * incremented again when calling __prep_account_new_huge_page() 2832 + * incremented again when calling account_new_hugetlb_folio() 2833 2833 * and enqueue_hugetlb_folio() for new_folio. The counters will 2834 2834 * remain stable since this happens under the lock. 2835 2835 */ ··· 2839 2839 * Ref count on new_folio is already zero as it was dropped 2840 2840 * earlier. It can be directly added to the pool free list. 2841 2841 */ 2842 - __prep_account_new_huge_page(h, nid); 2842 + account_new_hugetlb_folio(h, new_folio); 2843 2843 enqueue_hugetlb_folio(h, new_folio); 2844 2844 2845 2845 /* ··· 3313 3313 hugetlb_bootmem_init_migratetype(folio, h); 3314 3314 /* Subdivide locks to achieve better parallel performance */ 3315 3315 spin_lock_irqsave(&hugetlb_lock, flags); 3316 - __prep_account_new_huge_page(h, folio_nid(folio)); 3316 + account_new_hugetlb_folio(h, folio); 3317 3317 enqueue_hugetlb_folio(h, folio); 3318 3318 spin_unlock_irqrestore(&hugetlb_lock, flags); 3319 3319 }