Skip to contentSkip to conversation

mm/hugetlb: use account_new_hugetlb_folio() in add_hugetlb_folio()

PATCH New Enze Li 1 participant 1 message Nov 28

Subsystems (2)
lore
Share & tools
lore

Enze Li

author
#0 lore raw

PATCH v2 1/1 mm/hugetlb: use account_new_hugetlb_folio() in add_hugetlb_folio()

From: Enze Li <[email protected]>

Every other place that accounts a new huge page already calls account_new_hugetlb_folio(), and add_hugetlb_folio() was the odd one out, still open-coding the same two increments. Swap it over.

The helper is defined further down the file, so add a forward declaration for it.

No functional change intended.

---
v2:
Resend now that David's fix (commit 51154a62373b, "mm/hugetlb:account temporary folios separately") has landed, as discussed in v1 [1]. Rebased on top of mm-new.

[1] https://lore.kernel.org/linux-mm/[email protected]/

 mm/hugetlb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
mm/hugetlb.c +2 -2
index 4386425b5ce5..92cfcd469813 100644
@@ -142,6 +142,7 @@ static void hugetlb_unmap_range(struct mmu_gather *tlb,
 				unsigned long end, struct folio *folio,
 				zap_flags_t zap_flags);
 static struct resv_map *vma_resv_map(struct vm_area_struct *vma);
+static void account_new_hugetlb_folio(struct hstate *h, struct folio *folio);
 
 static inline bool subpool_is_free(struct hugepage_subpool *spool)
 {
@@ -1489,8 +1490,7 @@ void add_hugetlb_folio(struct hstate *h, struct folio *folio,
 				BIT(HPG_cma)), folio);
 
 	INIT_LIST_HEAD(&folio->lru);
-	h->nr_huge_pages++;
-	h->nr_huge_pages_node[nid]++;
+	account_new_hugetlb_folio(h, folio);
 
 	if (adjust_surplus) {
 		h->surplus_huge_pages++;
Signature · 1 line
2.53.0