From: "Ritesh Harjani (IBM)" <ritesh.list@gmail.com>
To: linuxppc-dev@lists.ozlabs.org
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>,
Michael Ellerman <mpe@ellerman.id.au>,
Christophe Leroy <chleroy@kernel.org>,
Venkat Rao Bagalkote <venkat88@linux.ibm.com>,
Shrikanth Hegde <sshegde@linux.ibm.com>,
linux-kernel@vger.kernel.org, Marco Elver <elver@google.com>,
"Ritesh Harjani (IBM)" <ritesh.list@gmail.com>
Subject: [PATCHv2 03/18] powerpc/mm/book3s64: Rework native_flush_hash_range() to remove conditional locking
Date: Thu, 19 Nov 2026 09:08:58 +0530 [thread overview]
Message-ID: <0822917ce1c1f58fa3f5d398e3df8d876dcb7c10.1795058683.git.ritesh.list@gmail.com> (raw)
In-Reply-To: <cover.1795058683.git.ritesh.list@gmail.com>
Clang's context analysis reports:
hash_native.c:851:2: error: raw_spinlock 'native_tlbie_lock' is not held on every path through here [-Werror,-Wthread-safety-analysis]
hash_native.c:868:3: error: releasing raw_spinlock 'native_tlbie_lock' that was not held [-Werror,-Wthread-safety-analysis]
This patch reworks the native_flush_hash_range() function to remove the
conditional locking. It fixes the clang context analysis reported
errors. However, this also simplifies the code in native_flush_hash_range()
due to various if conditions.
No functional change intended.
Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
---
arch/powerpc/mm/book3s64/hash_native.c | 88 ++++++++++++++++----------
1 file changed, 54 insertions(+), 34 deletions(-)
diff --git a/arch/powerpc/mm/book3s64/hash_native.c b/arch/powerpc/mm/book3s64/hash_native.c
index 6bad0545b57a..2a852dd5049f 100644
--- a/arch/powerpc/mm/book3s64/hash_native.c
+++ b/arch/powerpc/mm/book3s64/hash_native.c
@@ -792,6 +792,54 @@ static notrace void native_hpte_clear(void)
asm volatile("eieio; tlbsync; ptesync":::"memory");
}
+static void native_flush_hash_range_tlbiel(struct ppc64_tlb_batch *batch,
+ unsigned long number)
+{
+ unsigned long vpn = 0, index, shift;
+ real_pte_t pte;
+ unsigned long psize = batch->psize;
+ int ssize = batch->ssize;
+ int i;
+
+ asm volatile("ptesync":::"memory");
+ for (i = 0; i < number; i++) {
+ vpn = batch->vpn[i];
+ pte = batch->pte[i];
+
+ pte_iterate_hashed_subpages(pte, psize,
+ vpn, index, shift) {
+ __tlbiel(vpn, psize, psize, ssize);
+ } pte_iterate_hashed_end();
+ }
+ ppc_after_tlbiel_barrier();
+}
+
+static void native_flush_hash_range_tlbie(struct ppc64_tlb_batch *batch,
+ unsigned long number)
+{
+ unsigned long vpn = 0, index, shift;
+ real_pte_t pte;
+ unsigned long psize = batch->psize;
+ int ssize = batch->ssize;
+ int i;
+
+ asm volatile("ptesync":::"memory");
+ for (i = 0; i < number; i++) {
+ vpn = batch->vpn[i];
+ pte = batch->pte[i];
+
+ pte_iterate_hashed_subpages(pte, psize,
+ vpn, index, shift) {
+ __tlbie(vpn, psize, psize, ssize);
+ } pte_iterate_hashed_end();
+ }
+ /*
+ * Just do one more with the last used values.
+ */
+ fixup_tlbie_vpn(vpn, psize, psize, ssize);
+ asm volatile("eieio; tlbsync; ptesync":::"memory");
+}
+
/*
* Batched hash table flush, we batch the tlbie's to avoid taking/releasing
* the lock all the time
@@ -845,41 +893,13 @@ static void native_flush_hash_range(unsigned long number, int local)
if (mmu_has_feature(MMU_FTR_TLBIEL) &&
mmu_psize_defs[psize].tlbiel && local) {
- asm volatile("ptesync":::"memory");
- for (i = 0; i < number; i++) {
- vpn = batch->vpn[i];
- pte = batch->pte[i];
-
- pte_iterate_hashed_subpages(pte, psize,
- vpn, index, shift) {
- __tlbiel(vpn, psize, psize, ssize);
- } pte_iterate_hashed_end();
- }
- ppc_after_tlbiel_barrier();
+ native_flush_hash_range_tlbiel(batch, number);
+ } else if (!mmu_has_feature(MMU_FTR_LOCKLESS_TLBIE)) {
+ raw_spin_lock(&native_tlbie_lock);
+ native_flush_hash_range_tlbie(batch, number);
+ raw_spin_unlock(&native_tlbie_lock);
} else {
- int lock_tlbie = !mmu_has_feature(MMU_FTR_LOCKLESS_TLBIE);
-
- if (lock_tlbie)
- raw_spin_lock(&native_tlbie_lock);
-
- asm volatile("ptesync":::"memory");
- for (i = 0; i < number; i++) {
- vpn = batch->vpn[i];
- pte = batch->pte[i];
-
- pte_iterate_hashed_subpages(pte, psize,
- vpn, index, shift) {
- __tlbie(vpn, psize, psize, ssize);
- } pte_iterate_hashed_end();
- }
- /*
- * Just do one more with the last used values.
- */
- fixup_tlbie_vpn(vpn, psize, psize, ssize);
- asm volatile("eieio; tlbsync; ptesync":::"memory");
-
- if (lock_tlbie)
- raw_spin_unlock(&native_tlbie_lock);
+ native_flush_hash_range_tlbie(batch, number);
}
local_irq_restore(flags);
--
2.39.5
next prev parent reply other threads:[~2026-11-19 3:39 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 3:38 [PATCHv2 00/18] powerpc/mm, pseries, powernv: Enable clang context analysis Ritesh Harjani (IBM)
2026-11-19 3:38 ` [PATCHv2 01/18] powerpc/mm/book3s64: unlock RCU before returning from mm_iommu_is_devmem() Ritesh Harjani (IBM)
2026-11-19 3:38 ` [PATCHv2 02/18] powerpc/mm/book3s64: Rework tlbie() to remove conditional locking Ritesh Harjani (IBM)
2026-11-19 3:38 ` Ritesh Harjani (IBM) [this message]
2026-11-19 3:38 ` [PATCHv2 04/18] powerpc/mm/book3s64: Annotate the subpage-protection PTE lock Ritesh Harjani (IBM)
2026-11-19 3:39 ` [PATCHv2 05/18] powerpc/mm: Rework nohash TLB broadcast locking Ritesh Harjani (IBM)
2026-11-19 3:39 ` [PATCHv2 06/18] powerpc/mm: Enable context analysis Ritesh Harjani (IBM)
2026-11-19 3:39 ` [PATCHv2 07/18] powerpc/pseries: Drop inline from hugepage invalidate Ritesh Harjani (IBM)
2026-11-19 3:39 ` [PATCHv2 08/18] powerpc/pseries: Rework hugepage invalidate to remove conditional locking Ritesh Harjani (IBM)
2026-11-19 3:39 ` [PATCHv2 09/18] powerpc/pseries: Rework hash flush " Ritesh Harjani (IBM)
2026-11-19 3:39 ` [PATCHv2 10/18] powerpc/pseries: Add context annotations for the DTL worker lock Ritesh Harjani (IBM)
2026-11-19 3:39 ` [PATCHv2 11/18] powerpc/pseries: Annotate the VPD sequence lock context Ritesh Harjani (IBM)
2026-11-19 3:39 ` [PATCHv2 12/18] powerpc/pseries: Annotate the RTAS indices " Ritesh Harjani (IBM)
2026-11-19 3:39 ` [PATCHv2 13/18] powerpc/pseries: Annotate the RTAS physical-attestation " Ritesh Harjani (IBM)
2026-11-19 3:39 ` [PATCHv2 14/18] powerpc/pseries: Annotate the DTL debugfs read " Ritesh Harjani (IBM)
2026-11-19 3:39 ` [PATCHv2 15/18] powerpc/pseries: Disable context analysis for the CMM hotplug notifier Ritesh Harjani (IBM)
2026-11-19 3:39 ` [PATCHv2 16/18] powerpc/pseries: Enable context analysis Ritesh Harjani (IBM)
2026-11-19 3:39 ` [PATCHv2 17/18] powerpc/powernv: Rework OPAL console write to remove conditional locking Ritesh Harjani (IBM)
2026-11-19 3:39 ` [PATCHv2 18/18] powerpc/powernv: Enable context analysis Ritesh Harjani (IBM)
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=0822917ce1c1f58fa3f5d398e3df8d876dcb7c10.1795058683.git.ritesh.list@gmail.com \
--to=ritesh.list@gmail.com \
--cc=chleroy@kernel.org \
--cc=elver@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=maddy@linux.ibm.com \
--cc=mpe@ellerman.id.au \
--cc=sshegde@linux.ibm.com \
--cc=venkat88@linux.ibm.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
all inboxes | Powered by JetHome®