mm/hugetlb: add htlb_dissolve vmstat event
Subsystems (3)
PATCH 1/1 mm/hugetlb: add htlb_dissolve vmstat event
Memory offline and memory failure handling dissolve free hugetlb folios and lower nr_hugepages. Nothing records this, so when the pool shrinks it is hard to tell whether that or a write to nr_hugepages caused it.
Add an htlb_dissolve event, counted for each folio that dissolve_free_hugetlb_folio() frees.
--- include/linux/vm_event_item.h | 1 + mm/hugetlb.c | 1 + mm/vmstat.c | 1 + 3 files changed, 3 insertions(+)
include/linux/vm_event_item.h +1 -0
@@ -71,6 +71,7 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT,#endif #ifdef CONFIG_HUGETLB_PAGE HTLB_BUDDY_PGALLOC ,HTLB_BUDDY_PGALLOC_FAIL , +HTLB_DISSOLVE , #endif #ifdef CONFIG_CMA CMA_ALLOC_SUCCESS,
mm/hugetlb.c +1 -0
@@ -2047,6 +2047,7 @@ int dissolve_free_hugetlb_folio(struct folio *folio) }update_and_free_hugetlb_folio (h, folio, false); +count_vm_event (HTLB_DISSOLVE );return rc; } out:
mm/vmstat.c +1 -0
@@ -1397,6 +1397,7 @@ const char * const vmstat_text[] = { #ifdef CONFIG_HUGETLB_PAGE [I(HTLB_BUDDY_PGALLOC)] = "htlb_buddy_alloc_success", [I(HTLB_BUDDY_PGALLOC_FAIL)] = "htlb_buddy_alloc_fail", + [I (HTLB_DISSOLVE )] ="htlb_dissolve" , #endif #ifdef CONFIG_CMA [I(CMA_ALLOC_SUCCESS)] = "cma_alloc_success",
base-commit: 05441d697f7f9a927264f4058cbbc6a03dfcac9d
Signature · 1 line
2.50.1
Quoted 32 lines · Mark Bundschuh
Memory offline and memory failure handling dissolve free hugetlb folios and lower
nr_hugepages. Nothing records this, so when the pool shrinks it is hard to tell whether that or a write tonr_hugepagescaused it.Add an
htlb_dissolveevent, counted for each folio thatdissolve_free_hugetlb_folio()frees.Signed-off-by Mark Bundschuh <[email protected]>--- include/linux/vm_event_item.h | 1 + mm/hugetlb.c | 1 + mm/vmstat.c | 1 + 3 files changed, 3 insertions(+)include/linux/vm_event_item.h +1
-0@@ -71,6 +71,7 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT,#endif #ifdef CONFIG_HUGETLB_PAGE HTLB_BUDDY_PGALLOC ,HTLB_BUDDY_PGALLOC_FAIL , +HTLB_DISSOLVE , #endif #ifdef CONFIG_CMA CMA_ALLOC_SUCCESS,mm/hugetlb.c +0
-0
mm/hugetlb.c int dissolve_free_hugetlb_folio(struct folio *folio) · line 2050
Quoted 4 lines
mm/hugetlb.c +1
-0@@ -2047,6 +2047,7 @@ int dissolve_free_hugetlb_folio(struct folio *folio) }update_and_free_hugetlb_folio (h, folio, false); +count_vm_event (HTLB_DISSOLVE );
What if update_and_free_hugetlb_folio() failed / bailed out?
Quoted 21 lines
mm/hugetlb.c +0
-0return rc; } out:mm/vmstat.c +1
-0@@ -1397,6 +1397,7 @@ const char * const vmstat_text[] = { #ifdef CONFIG_HUGETLB_PAGE [I(HTLB_BUDDY_PGALLOC)] = "htlb_buddy_alloc_success", [I(HTLB_BUDDY_PGALLOC_FAIL)] = "htlb_buddy_alloc_fail", + [I (HTLB_DISSOLVE )] ="htlb_dissolve" , #endif #ifdef CONFIG_CMA [I(CMA_ALLOC_SUCCESS)] = "cma_alloc_success",base-commit:
05441d697f7f9a927264f4058cbbc6a03dfcac9d--
2.50.1
Quoted 4 lines · Jiaqi Yan
Quoted 2 lines
update_and_free_hugetlb_folio(h, folio, false);+
count_vm_event(HTLB_DISSOLVE);What if
update_and_free_hugetlb_folio()failed / bailed out?
dissolve_free_hugetlb_folio() already rejects gigantic folios without runtime support, and restores the vmemmap itself before calling it, so the only bail out left is a folio with unreliable raw hwpoison, which is leaked on purpose. That folio still leaves the pool, so I think it should be counted. "frees" in the commit message is misleading though, I'll fix that in v2.