linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH] mm: show mthp_fault_alloc and mthp_fault_fallback of multi-size THPs
@ 2024-03-26  3:01 Barry Song
  2024-03-26  3:24 ` Matthew Wilcox
  0 siblings, 1 reply; 6+ messages in thread
From: Barry Song @ 2024-03-26  3:01 UTC (permalink / raw)
  To: akpm, linux-mm
  Cc: ryan.roberts, david, kasong, yuzhao, yosryahmed,
	cerasuolodomenico, surenb, Barry Song

From: Barry Song <v-songbaohua@oppo.com>

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@oppo.com>
---
 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



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-03-27 12:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-26  3:01 [RFC PATCH] mm: show mthp_fault_alloc and mthp_fault_fallback of multi-size THPs Barry Song
2024-03-26  3:24 ` Matthew Wilcox
2024-03-26  3:40   ` Barry Song
2024-03-26 22:19     ` Barry Song
2024-03-27 11:35       ` David Hildenbrand
2024-03-27 12:17         ` Ryan Roberts

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox