All of lore.kernel.org
 help / color / mirror / Atom feed
From: Barry Song <21cnbao@gmail.com>
To: akpm@linux-foundation.org, linux-mm@kvack.org
Cc: ryan.roberts@arm.com, david@redhat.com, kasong@tencent.com,
	yuzhao@google.com, yosryahmed@google.com,
	cerasuolodomenico@gmail.com, surenb@google.com,
	Barry Song <v-songbaohua@oppo.com>
Subject: [RFC PATCH] mm: show mthp_fault_alloc and mthp_fault_fallback of multi-size THPs
Date: Tue, 26 Mar 2024 16:01:03 +1300	[thread overview]
Message-ID: <20240326030103.50678-1-21cnbao@gmail.com> (raw)

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



             reply	other threads:[~2024-03-26  3:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-26  3:01 Barry Song [this message]
2024-03-26  3:24 ` [RFC PATCH] mm: show mthp_fault_alloc and mthp_fault_fallback of multi-size THPs 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240326030103.50678-1-21cnbao@gmail.com \
    --to=21cnbao@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=cerasuolodomenico@gmail.com \
    --cc=david@redhat.com \
    --cc=kasong@tencent.com \
    --cc=linux-mm@kvack.org \
    --cc=ryan.roberts@arm.com \
    --cc=surenb@google.com \
    --cc=v-songbaohua@oppo.com \
    --cc=yosryahmed@google.com \
    --cc=yuzhao@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.