LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
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>,
	Paul Mackerras <paulus@ozlabs.org>,
	"Aneesh Kumar K.V" <aneesh.kumar@kernel.org>,
	Donet Tom <donettom@linux.ibm.com>
Subject: [RFC 7/8] powerpc/book3s64/slb: Add no_slb_preload early cmdline param
Date: Sat, 30 Aug 2025 09:21:46 +0530	[thread overview]
Message-ID: <8a654cb9cc8bfc872df0cff5558c787ec44c8f28.1756522067.git.ritesh.list@gmail.com> (raw)
In-Reply-To: <cover.1756522067.git.ritesh.list@gmail.com>

no_slb_preload cmdline can come useful in quickly disabling and/or
testing the performance impact of userspace slb preloads. Recently there
was a slb multi-hit issue due to slb preload cache which was very
difficult to triage. This cmdline option allows to quickly disable
preloads and verify if the issue exists in preload cache or somewhere
else. This can also be a useful option to see the effect of slb preloads
for any application workload e.g. number of slb faults with or w/o slb
preloads.

For e.g. with the next patch where we added slb_faults counter to /proc/vmstat:

with slb_preload:
slb_faults (minimal initrd boot): 15
slb_faults (full systemd boot): 300

with no_slb_preload:
slb_faults (minimal initrd boot): 33
slb_faults (full systemd boot): 138180

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: Paul Mackerras <paulus@ozlabs.org>
Cc: "Aneesh Kumar K.V" <aneesh.kumar@kernel.org>
Cc: Donet Tom <donettom@linux.ibm.com>
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
---
 Documentation/admin-guide/kernel-parameters.txt |  3 +++
 arch/powerpc/mm/book3s64/hash_utils.c           |  3 +++
 arch/powerpc/mm/book3s64/internal.h             |  7 +++++++
 arch/powerpc/mm/book3s64/slb.c                  | 15 +++++++++++++++
 4 files changed, 28 insertions(+)

diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 747a55abf494..9a66f255b659 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -7135,6 +7135,9 @@
 			them frequently to increase the rate of SLB faults
 			on kernel addresses.

+	no_slb_preload	[PPC,EARLY]
+			Disables slb preloading for userspace.
+
 	sunrpc.min_resvport=
 	sunrpc.max_resvport=
 			[NFS,SUNRPC]
diff --git a/arch/powerpc/mm/book3s64/hash_utils.c b/arch/powerpc/mm/book3s64/hash_utils.c
index 495b6da6f5d4..abf703563ea3 100644
--- a/arch/powerpc/mm/book3s64/hash_utils.c
+++ b/arch/powerpc/mm/book3s64/hash_utils.c
@@ -1319,6 +1319,9 @@ static void __init htab_initialize(void)
 	if (stress_slb_enabled)
 		static_branch_enable(&stress_slb_key);

+	if (no_slb_preload)
+		static_branch_enable(&no_slb_preload_key);
+
 	if (stress_hpt_enabled) {
 		unsigned long tmp;
 		static_branch_enable(&stress_hpt_key);
diff --git a/arch/powerpc/mm/book3s64/internal.h b/arch/powerpc/mm/book3s64/internal.h
index c26a6f0c90fc..cad08d83369c 100644
--- a/arch/powerpc/mm/book3s64/internal.h
+++ b/arch/powerpc/mm/book3s64/internal.h
@@ -22,6 +22,13 @@ static inline bool stress_hpt(void)
 	return static_branch_unlikely(&stress_hpt_key);
 }

+extern bool no_slb_preload;
+DECLARE_STATIC_KEY_FALSE(no_slb_preload_key);
+static inline bool slb_preload_disabled(void)
+{
+	return static_branch_unlikely(&no_slb_preload_key);
+}
+
 void hpt_do_stress(unsigned long ea, unsigned long hpte_group);

 void exit_lazy_flush_tlb(struct mm_struct *mm, bool always_flush);
diff --git a/arch/powerpc/mm/book3s64/slb.c b/arch/powerpc/mm/book3s64/slb.c
index 780792b9a1e5..297ab0e93c1e 100644
--- a/arch/powerpc/mm/book3s64/slb.c
+++ b/arch/powerpc/mm/book3s64/slb.c
@@ -42,6 +42,15 @@ early_param("stress_slb", parse_stress_slb);

 __ro_after_init DEFINE_STATIC_KEY_FALSE(stress_slb_key);

+bool no_slb_preload __initdata;
+static int __init parse_no_slb_preload(char *p)
+{
+	no_slb_preload = true;
+	return 0;
+}
+early_param("no_slb_preload", parse_no_slb_preload);
+__ro_after_init DEFINE_STATIC_KEY_FALSE(no_slb_preload_key);
+
 static void assert_slb_presence(bool present, unsigned long ea)
 {
 #ifdef CONFIG_DEBUG_VM
@@ -299,6 +308,9 @@ static void preload_add(struct thread_info *ti, unsigned long ea)
 	unsigned char idx;
 	unsigned long esid;

+	if (slb_preload_disabled())
+		return;
+
 	if (mmu_has_feature(MMU_FTR_1T_SEGMENT)) {
 		/* EAs are stored >> 28 so 256MB segments don't need clearing */
 		if (ea & ESID_MASK_1T)
@@ -414,6 +426,9 @@ void switch_slb(struct task_struct *tsk, struct mm_struct *mm)

 	copy_mm_to_paca(mm);

+	if (slb_preload_disabled())
+		return;
+
 	/*
 	 * We gradually age out SLBs after a number of context switches to
 	 * reduce reload overhead of unused entries (like we do with FP/VEC
--
2.50.1



  parent reply	other threads:[~2025-08-30  3:54 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-30  3:51 [PATCH 0/8] powerpc/book3s64: Hash / SLB fixes & improvements Ritesh Harjani (IBM)
2025-08-30  3:51 ` [RFC 1/8] powerpc/mm: Fix SLB multihit issue during SLB preload Ritesh Harjani (IBM)
2025-08-30  3:51 ` [RFC 2/8] book3s64/hash: Restrict stress_hpt_struct memblock region to within RMA limit Ritesh Harjani (IBM)
2025-08-30  3:51 ` [RFC 3/8] book3s64/hash: Fix phys_addr_t printf format in htab_initialize() Ritesh Harjani (IBM)
2025-08-30  6:26   ` Christophe Leroy
2025-08-30  7:30     ` Ritesh Harjani
2025-08-30  3:51 ` [RFC 4/8] powerpc/ptdump/64: Fix kernel_hash_pagetable dump for ISA v3.00 HPTE format Ritesh Harjani (IBM)
2025-08-30  3:51 ` [RFC 5/8] powerpc/ptdump: Dump PXX level info for kernel_page_tables Ritesh Harjani (IBM)
2025-08-30  6:31   ` Christophe Leroy
2025-08-30  7:25     ` Ritesh Harjani
2025-08-30  3:51 ` [RFC 6/8] powerpc/book3s64/slb: Make preload_add return type as void Ritesh Harjani (IBM)
2025-08-30  6:36   ` Christophe Leroy
2025-08-30  7:27     ` Ritesh Harjani
2025-08-30  3:51 ` Ritesh Harjani (IBM) [this message]
2025-08-30  6:42   ` [RFC 7/8] powerpc/book3s64/slb: Add no_slb_preload early cmdline param Christophe Leroy
2025-08-30 10:11     ` Ritesh Harjani
2025-08-30  3:51 ` [RFC 8/8] powerpc/book3s64/slb: Add slb faults to vmstat Ritesh Harjani (IBM)
2025-08-30  4:45   ` 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=8a654cb9cc8bfc872df0cff5558c787ec44c8f28.1756522067.git.ritesh.list@gmail.com \
    --to=ritesh.list@gmail.com \
    --cc=aneesh.kumar@kernel.org \
    --cc=christophe.leroy@csgroup.eu \
    --cc=donettom@linux.ibm.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=maddy@linux.ibm.com \
    --cc=mpe@ellerman.id.au \
    --cc=npiggin@gmail.com \
    --cc=paulus@ozlabs.org \
    /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