Skip to contentSkip to conversation

mm/hugetlb: add htlb_dissolve vmstat event

PATCH In review Mark Bundschuh 3 participants 4 messages Nov 5 – Nov 10

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 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 free folio that dissolve_free_hugetlb_folio() takes out of the pool.

---
v2: say "takes out of the pool" instead of "frees" (Jiaqi)

v1: https://lore.kernel.org/all/[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
index 2628ccda076a..822fe862e5b3 100644
@@ -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
index da5d04edf7c1..7c79523b2a3c 100644
@@ -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
index a3e809c57f29..6282eef7074a 100644
@@ -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
maintainer
#1 lore raw
Quoted 3 lines · On Thu, 5 Nov 2026 19:15:08 +0000 Mark Bundschuh <[email protected]> wrote:

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.

Can we please have a much more detailed explanation of the motivation for this? I assume it's for the benefit of ops people, but why do they want this and how will it be used, etc? y'know, that old use-case thing.

Quoted 2 lines

Add an htlb_dissolve event, counted for each free folio that dissolve_free_hugetlb_folio() takes out of the pool.

I'm wondering why it doesn't account offline and memory-failure separately but without the above info I'm at a loss!

Thanks.

maintainer
#2 lore raw
In reply to Mark Bundschuh
Quoted 7 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 to nr_hugepages caused it.

Hi Mark,

I want to know why you need to distinguish these cases. Is it because, in your scenario, there is a possibility that unexpected nr_hugepages operations may modify things? You are not aware of such operational actions, so you want to know whether you have experienced this kind of operational action, is that right? Since this risk exists, why not use auditctl to perform audit logging?

Thanks,
Muchun

Quoted 56 lines

Add an htlb_dissolve event, counted for each free folio that dissolve_free_hugetlb_folio() takes out of the pool.

---
v2: say "takes out of the pool" instead of "frees" (Jiaqi)

v1: https://lore.kernel.org/all/[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
index 2628ccda076a..822fe862e5b3 100644
@@ -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
index da5d04edf7c1..7c79523b2a3c 100644
@@ -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
index a3e809c57f29..6282eef7074a 100644
@@ -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
#3 lore raw

Hi Andrew and Muchun,

Thanks, fair questions. Some context: a management agent offlined memory blocks on a host using huge pages. Each offline dissolved the free huge pages in the block and lowered nr_hugepages, and later the workload failed to get its pages. It took me a while to work out that the offlines, not another process writing to nr_hugepages, were what had shrunk the pool. The counter was meant to make that visible.

Thinking about it more, the offline itself is already visible (a successful offline sends a uevent, and auditctl can log who started it). So I don't think this needs a counter. Please drop it.

Thanks,
Mark