From: "Ritesh Harjani (IBM)" <ritesh.list@gmail.com>
To: linuxppc-dev@lists.ozlabs.org
Cc: "Ritesh Harjani (IBM)" <ritesh.list@gmail.com>,
Madhavan Srinivasan <maddy@linux.ibm.com>,
Michael Ellerman <mpe@ellerman.id.au>,
Nicholas Piggin <npiggin@gmail.com>,
Christophe Leroy <christophe.leroy@csgroup.eu>,
Donet Tom <donettom@linux.ibm.com>,
Andrew Morton <akpm@linux-foundation.org>,
David Hildenbrand <david@redhat.com>,
Lorenzo Stoakes <lorenzo.stoakes@oracle.com>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: [RFC 8/8] powerpc/book3s64/slb: Add slb faults to vmstat
Date: Sat, 30 Aug 2025 09:21:47 +0530 [thread overview]
Message-ID: <e05ac86618d8a52feccf5bac99da44b11871382c.1756522067.git.ritesh.list@gmail.com> (raw)
In-Reply-To: <cover.1756522067.git.ritesh.list@gmail.com>
There were good optimization written in past which reduces the number of
slb faults e.g. during context switches [1]. However if one wants to
measure total number of slb faults then there is no easy way of
measuring one e.g. number of slb faults during bootup.
This adds slb faults as part of vmstat counter to easily measure total
number of slb faults for book3s64.
Note: slb fault handling is defined as raw interrupt handler which says:
* raw interrupt handlers must not enable or disable interrupts, or
* schedule, tracing and instrumentation (ftrace, lockdep, etc) would
* not be advisable either, although may be possible in a pinch, the
* trace will look odd at least.
Hence adding a vmstat counter looks a plausible and safe option, to at-
least measure the number of slb kernel & user faults in the system.
[1]: https://lore.kernel.org/all/20181013131836.26764-4-mpe@ellerman.id.au/
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Donet Tom <donettom@linux.ibm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: David Hildenbrand <david@redhat.com>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: linuxppc-dev@lists.ozlabs.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-mm@kvack.org
Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
---
arch/powerpc/mm/book3s64/slb.c | 3 +++
include/linux/vm_event_item.h | 4 ++++
mm/vmstat.c | 5 +++++
3 files changed, 12 insertions(+)
diff --git a/arch/powerpc/mm/book3s64/slb.c b/arch/powerpc/mm/book3s64/slb.c
index 297ab0e93c1e..064427af63f7 100644
--- a/arch/powerpc/mm/book3s64/slb.c
+++ b/arch/powerpc/mm/book3s64/slb.c
@@ -22,6 +22,7 @@
#include <linux/context_tracking.h>
#include <linux/mm_types.h>
#include <linux/pgtable.h>
+#include <linux/vmstat.h>
#include <asm/udbg.h>
#include <asm/text-patching.h>
@@ -780,6 +781,7 @@ DEFINE_INTERRUPT_HANDLER_RAW(do_slb_fault)
#ifdef CONFIG_DEBUG_VM
local_paca->in_kernel_slb_handler = 0;
#endif
+ count_vm_event(SLB_KERNEL_FAULTS);
return err;
} else {
struct mm_struct *mm = current->mm;
@@ -792,6 +794,7 @@ DEFINE_INTERRUPT_HANDLER_RAW(do_slb_fault)
if (!err)
preload_add(current_thread_info(), ea);
+ count_vm_event(SLB_USER_FAULTS);
return err;
}
}
diff --git a/include/linux/vm_event_item.h b/include/linux/vm_event_item.h
index 9e15a088ba38..8aa34d0eee3b 100644
--- a/include/linux/vm_event_item.h
+++ b/include/linux/vm_event_item.h
@@ -156,6 +156,10 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT,
DIRECT_MAP_LEVEL2_COLLAPSE,
DIRECT_MAP_LEVEL3_COLLAPSE,
#endif
+#ifdef CONFIG_PPC_BOOK3S_64
+ SLB_KERNEL_FAULTS,
+ SLB_USER_FAULTS,
+#endif
#ifdef CONFIG_PER_VMA_LOCK_STATS
VMA_LOCK_SUCCESS,
VMA_LOCK_ABORT,
diff --git a/mm/vmstat.c b/mm/vmstat.c
index 71cd1ceba191..8cd17a5fc72b 100644
--- a/mm/vmstat.c
+++ b/mm/vmstat.c
@@ -1464,6 +1464,11 @@ const char * const vmstat_text[] = {
[I(DIRECT_MAP_LEVEL2_COLLAPSE)] = "direct_map_level2_collapses",
[I(DIRECT_MAP_LEVEL3_COLLAPSE)] = "direct_map_level3_collapses",
#endif
+#ifdef CONFIG_PPC_BOOK3S_64
+ "slb_kernel_faults",
+ "slb_user_faults",
+#endif
+
#ifdef CONFIG_PER_VMA_LOCK_STATS
[I(VMA_LOCK_SUCCESS)] = "vma_lock_success",
[I(VMA_LOCK_ABORT)] = "vma_lock_abort",
--
2.50.1
next parent reply other threads:[~2025-08-30 3:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1756522067.git.ritesh.list@gmail.com>
2025-08-30 3:51 ` Ritesh Harjani (IBM) [this message]
2025-08-30 4:45 ` [RFC 8/8] powerpc/book3s64/slb: Add slb faults to vmstat Stephen Rothwell
2025-08-30 4:56 ` Ritesh Harjani
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=e05ac86618d8a52feccf5bac99da44b11871382c.1756522067.git.ritesh.list@gmail.com \
--to=ritesh.list@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=christophe.leroy@csgroup.eu \
--cc=david@redhat.com \
--cc=donettom@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=lorenzo.stoakes@oracle.com \
--cc=maddy@linux.ibm.com \
--cc=mpe@ellerman.id.au \
--cc=npiggin@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).