From: Barry Song <v-songbaohua@xxxxxxxx> Profiling a system blindly with mTHP has become challenging due to the lack of visibility into its operations. While displaying additional statistics such as partial map/unmap actions may spark debate, presenting the success rate of mTHP allocations appears to be a straightforward and pressing need. Recently, I've been experiencing significant difficulty debugging performance improvements and regressions without these figures. It's crucial for us to understand the true effectiveness of mTHP in real-world scenarios, especially in systems with fragmented memory. Signed-off-by: Barry Song <v-songbaohua@xxxxxxxx> --- include/linux/vm_event_item.h | 2 ++ mm/memory.c | 2 ++ mm/vmstat.c | 2 ++ 3 files changed, 6 insertions(+) diff --git a/include/linux/vm_event_item.h b/include/linux/vm_event_item.h index 747943bc8cc2..3233b39bdb38 100644 --- a/include/linux/vm_event_item.h +++ b/include/linux/vm_event_item.h @@ -95,6 +95,8 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT, THP_FAULT_ALLOC, THP_FAULT_FALLBACK, THP_FAULT_FALLBACK_CHARGE, + MTHP_FAULT_ALLOC, + MTHP_FAULT_FALLBACK, THP_COLLAPSE_ALLOC, THP_COLLAPSE_ALLOC_FAILED, THP_FILE_ALLOC, diff --git a/mm/memory.c b/mm/memory.c index 62ee4a15092a..803f00a07d54 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -4364,12 +4364,14 @@ static struct folio *alloc_anon_folio(struct vm_fault *vmf) } folio_throttle_swaprate(folio, gfp); clear_huge_page(&folio->page, vmf->address, 1 << order); + count_vm_event(MTHP_FAULT_ALLOC); return folio; } next: order = next_order(&orders, order); } + count_vm_event(MTHP_FAULT_FALLBACK); fallback: #endif return folio_prealloc(vma->vm_mm, vma, vmf->address, true); diff --git a/mm/vmstat.c b/mm/vmstat.c index db79935e4a54..0cc86c73ecdc 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -1353,6 +1353,8 @@ const char * const vmstat_text[] = { "thp_fault_alloc", "thp_fault_fallback", "thp_fault_fallback_charge", + "mthp_fault_alloc", + "mthp_fault_fallback", "thp_collapse_alloc", "thp_collapse_alloc_failed", "thp_file_alloc", -- 2.34.1