* [PATCHv2 01/18] powerpc/mm/book3s64: unlock RCU before returning from mm_iommu_is_devmem()
2026-11-19 3:38 [PATCHv2 00/18] powerpc/mm, pseries, powernv: Enable clang context analysis Ritesh Harjani (IBM)
@ 2026-11-19 3:38 ` Ritesh Harjani (IBM)
2026-11-19 3:38 ` [PATCHv2 02/18] powerpc/mm/book3s64: Rework tlbie() to remove conditional locking Ritesh Harjani (IBM)
` (16 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Ritesh Harjani (IBM) @ 2026-11-19 3:38 UTC (permalink / raw)
To: linuxppc-dev
Cc: Madhavan Srinivasan, Michael Ellerman, Christophe Leroy,
Venkat Rao Bagalkote, Shrikanth Hegde, linux-kernel, Marco Elver,
Ritesh Harjani (IBM),
stable
Clang's context analysis reports:
iommu_api.c:380:1: error: __ctx_lock_RCU 'RCU' is not held on every path through here [-Werror,-Wthread-safety-analysis]
mm_iommu_is_devmem() takes the RCU read lock to walk the preregistered
device-memory list. On a match it returned true from inside the loop and
skipped rcu_read_unlock(). Hence fix it.
Fixes: b5952f8125ae ("powerpc/mm/book3s64/iommu: fix some RCU-list locks")
Cc: stable@vger.kernel.org
Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
---
arch/powerpc/mm/book3s64/iommu_api.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/mm/book3s64/iommu_api.c b/arch/powerpc/mm/book3s64/iommu_api.c
index 60d00c9e7f19..56d9aa6cc8e2 100644
--- a/arch/powerpc/mm/book3s64/iommu_api.c
+++ b/arch/powerpc/mm/book3s64/iommu_api.c
@@ -356,6 +356,7 @@ bool mm_iommu_is_devmem(struct mm_struct *mm, unsigned long hpa,
{
struct mm_iommu_table_group_mem_t *mem;
unsigned long end;
+ bool ret = false;
rcu_read_lock();
list_for_each_entry_rcu(mem, &mm->context.iommu_group_mem_list, next) {
@@ -371,12 +372,13 @@ bool mm_iommu_is_devmem(struct mm_struct *mm, unsigned long hpa,
* and the caller needs to distinguish this situation.
*/
*size = min(1UL << pageshift, end - hpa);
- return true;
+ ret = true;
+ break;
}
}
rcu_read_unlock();
- return false;
+ return ret;
}
EXPORT_SYMBOL_GPL(mm_iommu_is_devmem);
--
2.39.5
^ permalink raw reply [flat|nested] 19+ messages in thread* [PATCHv2 02/18] powerpc/mm/book3s64: Rework tlbie() to remove conditional locking
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 ` Ritesh Harjani (IBM)
2026-11-19 3:38 ` [PATCHv2 03/18] powerpc/mm/book3s64: Rework native_flush_hash_range() " Ritesh Harjani (IBM)
` (15 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Ritesh Harjani (IBM) @ 2026-11-19 3:38 UTC (permalink / raw)
To: linuxppc-dev
Cc: Madhavan Srinivasan, Michael Ellerman, Christophe Leroy,
Venkat Rao Bagalkote, Shrikanth Hegde, linux-kernel, Marco Elver,
Ritesh Harjani (IBM)
Clang's context analysis reports:
hash_native.c:235:2: error: raw_spinlock 'native_tlbie_lock' is not held on every path through here [-Werror,-Wthread-safety-analysis]
hash_native.c:245:3: error: releasing raw_spinlock 'native_tlbie_lock' that was not held [-Werror,-Wthread-safety-analysis]
This patch reworks the tlbie() function to remove the conditional
locking. It fixes the clang context analysis reported errors. However,
this also simplifies the code around tlbie[l] - which is also a win.
No functional change intended.
Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
---
arch/powerpc/mm/book3s64/hash_native.c | 34 ++++++++++++++++++--------
1 file changed, 24 insertions(+), 10 deletions(-)
diff --git a/arch/powerpc/mm/book3s64/hash_native.c b/arch/powerpc/mm/book3s64/hash_native.c
index ab2a80e59011..6bad0545b57a 100644
--- a/arch/powerpc/mm/book3s64/hash_native.c
+++ b/arch/powerpc/mm/book3s64/hash_native.c
@@ -222,6 +222,23 @@ static inline void __tlbiel(unsigned long vpn, int psize, int apsize, int ssize)
}
+static inline void __tlbie_sequence(unsigned long vpn, int psize, int apsize,
+ int ssize)
+{
+ asm volatile("ptesync": : :"memory");
+ __tlbie(vpn, psize, apsize, ssize);
+ fixup_tlbie_vpn(vpn, psize, apsize, ssize);
+ asm volatile("eieio; tlbsync; ptesync": : :"memory");
+}
+
+static inline void __tlbiel_sequence(unsigned long vpn, int psize, int apsize,
+ int ssize)
+{
+ asm volatile("ptesync": : :"memory");
+ __tlbiel(vpn, psize, apsize, ssize);
+ ppc_after_tlbiel_barrier();
+}
+
static inline void tlbie(unsigned long vpn, int psize, int apsize,
int ssize, int local)
{
@@ -230,19 +247,16 @@ static inline void tlbie(unsigned long vpn, int psize, int apsize,
if (use_local)
use_local = mmu_psize_defs[psize].tlbiel;
- if (lock_tlbie && !use_local)
- raw_spin_lock(&native_tlbie_lock);
- asm volatile("ptesync": : :"memory");
+
if (use_local) {
- __tlbiel(vpn, psize, apsize, ssize);
- ppc_after_tlbiel_barrier();
+ __tlbiel_sequence(vpn, psize, apsize, ssize);
+ } else if (lock_tlbie) {
+ raw_spin_lock(&native_tlbie_lock);
+ __tlbie_sequence(vpn, psize, apsize, ssize);
+ raw_spin_unlock(&native_tlbie_lock);
} else {
- __tlbie(vpn, psize, apsize, ssize);
- fixup_tlbie_vpn(vpn, psize, apsize, ssize);
- asm volatile("eieio; tlbsync; ptesync": : :"memory");
+ __tlbie_sequence(vpn, psize, apsize, ssize);
}
- if (lock_tlbie && !use_local)
- raw_spin_unlock(&native_tlbie_lock);
}
static inline void native_lock_hpte(struct hash_pte *hptep)
--
2.39.5
^ permalink raw reply [flat|nested] 19+ messages in thread* [PATCHv2 03/18] powerpc/mm/book3s64: Rework native_flush_hash_range() to remove conditional locking
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)
2026-11-19 3:38 ` [PATCHv2 04/18] powerpc/mm/book3s64: Annotate the subpage-protection PTE lock Ritesh Harjani (IBM)
` (14 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Ritesh Harjani (IBM) @ 2026-11-19 3:38 UTC (permalink / raw)
To: linuxppc-dev
Cc: Madhavan Srinivasan, Michael Ellerman, Christophe Leroy,
Venkat Rao Bagalkote, Shrikanth Hegde, linux-kernel, Marco Elver,
Ritesh Harjani (IBM)
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
^ permalink raw reply [flat|nested] 19+ messages in thread* [PATCHv2 04/18] powerpc/mm/book3s64: Annotate the subpage-protection PTE lock
2026-11-19 3:38 [PATCHv2 00/18] powerpc/mm, pseries, powernv: Enable clang context analysis Ritesh Harjani (IBM)
` (2 preceding siblings ...)
2026-11-19 3:38 ` [PATCHv2 03/18] powerpc/mm/book3s64: Rework native_flush_hash_range() " Ritesh Harjani (IBM)
@ 2026-11-19 3:38 ` Ritesh Harjani (IBM)
2026-11-19 3:39 ` [PATCHv2 05/18] powerpc/mm: Rework nohash TLB broadcast locking Ritesh Harjani (IBM)
` (13 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Ritesh Harjani (IBM) @ 2026-11-19 3:38 UTC (permalink / raw)
To: linuxppc-dev
Cc: Madhavan Srinivasan, Michael Ellerman, Christophe Leroy,
Venkat Rao Bagalkote, Shrikanth Hegde, linux-kernel, Marco Elver,
Ritesh Harjani (IBM)
Clang's context analysis reports:
subpage_prot.c:83:2: error: releasing spinlock 'ptl' that was not held [-Werror,-Wthread-safety-analysis]
pte_offset_map_lock() holds ptl when it returns a PTE and
pte_unmap_unlock() drops it. However since the lock is taken inside the
helper, which is not annotated, so the unlock in hpte_flush_range()
looks unheld.
This patch fixes it in hpte_flush_range() by adding the needed
annotation here. IMO, should ideally be added to pte_offset_map_lock(),
once that happens (since it might need larger enablement), we can remove
it from here.
Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
---
arch/powerpc/mm/book3s64/subpage_prot.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/arch/powerpc/mm/book3s64/subpage_prot.c b/arch/powerpc/mm/book3s64/subpage_prot.c
index 37d47282c368..d641c35c408d 100644
--- a/arch/powerpc/mm/book3s64/subpage_prot.c
+++ b/arch/powerpc/mm/book3s64/subpage_prot.c
@@ -73,6 +73,8 @@ static void hpte_flush_range(struct mm_struct *mm, unsigned long addr,
pte = pte_offset_map_lock(mm, pmd, addr, &ptl);
if (!pte)
return;
+ /* pte_offset_map_lock on success returns with ptl lock held */
+ __acquire(ptl);
lazy_mmu_mode_enable();
for (; npages > 0; --npages) {
pte_update(mm, addr, pte, 0, 0, 0);
--
2.39.5
^ permalink raw reply [flat|nested] 19+ messages in thread* [PATCHv2 05/18] powerpc/mm: Rework nohash TLB broadcast locking
2026-11-19 3:38 [PATCHv2 00/18] powerpc/mm, pseries, powernv: Enable clang context analysis Ritesh Harjani (IBM)
` (3 preceding siblings ...)
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 ` Ritesh Harjani (IBM)
2026-11-19 3:39 ` [PATCHv2 06/18] powerpc/mm: Enable context analysis Ritesh Harjani (IBM)
` (12 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Ritesh Harjani (IBM) @ 2026-11-19 3:39 UTC (permalink / raw)
To: linuxppc-dev
Cc: Madhavan Srinivasan, Michael Ellerman, Christophe Leroy,
Venkat Rao Bagalkote, Shrikanth Hegde, linux-kernel, Marco Elver,
Ritesh Harjani (IBM)
Clang's context analysis reports:
mmu_context.c:141:2: error: releasing raw_spinlock 'context_lock' that was not held [-Werror,-Wthread-safety-analysis]
mmu_context.c:147:1: error: raw_spinlock 'context_lock' is not held on every path through here [-Werror,-Wthread-safety-analysis]
tlb.c:257:4: error: raw_spinlock 'tlbivax_lock' is not held on every path through here [-Werror,-Wthread-safety-analysis]
tlb.c:259:5: error: releasing raw_spinlock 'tlbivax_lock' that was not held [-Werror,-Wthread-safety-analysis]
This reworks the locking in __flush_tlb_page() a bit to satisfy clang
context analyzer requirement.
Also steal_context_smp() drops the context_lock, so it needs to be
annotated with __must_hold to inform the clang analyzer that this
function holds the context_lock.
Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
---
arch/powerpc/mm/nohash/mmu_context.c | 1 +
arch/powerpc/mm/nohash/tlb.c | 8 +++++---
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/arch/powerpc/mm/nohash/mmu_context.c b/arch/powerpc/mm/nohash/mmu_context.c
index 28a96a10c907..bdbe1f55f388 100644
--- a/arch/powerpc/mm/nohash/mmu_context.c
+++ b/arch/powerpc/mm/nohash/mmu_context.c
@@ -95,6 +95,7 @@ static DEFINE_RAW_SPINLOCK(context_lock);
* -- benh
*/
static unsigned int steal_context_smp(unsigned int id)
+ __must_hold(&context_lock)
{
struct mm_struct *mm;
unsigned int cpu, max, i;
diff --git a/arch/powerpc/mm/nohash/tlb.c b/arch/powerpc/mm/nohash/tlb.c
index 07a2db16c2b1..9297549aef41 100644
--- a/arch/powerpc/mm/nohash/tlb.c
+++ b/arch/powerpc/mm/nohash/tlb.c
@@ -252,11 +252,13 @@ void __flush_tlb_page(struct mm_struct *mm, unsigned long vmaddr,
/* If broadcast tlbivax is supported, use it */
if (mmu_has_feature(MMU_FTR_USE_TLBIVAX_BCAST)) {
int lock = mmu_has_feature(MMU_FTR_LOCK_BCAST_INVAL);
- if (lock)
+ if (lock) {
raw_spin_lock(&tlbivax_lock);
- _tlbivax_bcast(vmaddr, pid, tsize, ind);
- if (lock)
+ _tlbivax_bcast(vmaddr, pid, tsize, ind);
raw_spin_unlock(&tlbivax_lock);
+ } else {
+ _tlbivax_bcast(vmaddr, pid, tsize, ind);
+ }
goto bail;
} else {
struct tlb_flush_param p = {
--
2.39.5
^ permalink raw reply [flat|nested] 19+ messages in thread* [PATCHv2 06/18] powerpc/mm: Enable context analysis
2026-11-19 3:38 [PATCHv2 00/18] powerpc/mm, pseries, powernv: Enable clang context analysis Ritesh Harjani (IBM)
` (4 preceding siblings ...)
2026-11-19 3:39 ` [PATCHv2 05/18] powerpc/mm: Rework nohash TLB broadcast locking Ritesh Harjani (IBM)
@ 2026-11-19 3:39 ` Ritesh Harjani (IBM)
2026-11-19 3:39 ` [PATCHv2 07/18] powerpc/pseries: Drop inline from hugepage invalidate Ritesh Harjani (IBM)
` (11 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Ritesh Harjani (IBM) @ 2026-11-19 3:39 UTC (permalink / raw)
To: linuxppc-dev
Cc: Madhavan Srinivasan, Michael Ellerman, Christophe Leroy,
Venkat Rao Bagalkote, Shrikanth Hegde, linux-kernel, Marco Elver,
Ritesh Harjani (IBM)
powerpc/mm/ objects now build with Clang context analysis enabled.
Turn it on for book3s32, book3s64 and nohash mmu.
Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
---
arch/powerpc/mm/Makefile | 2 ++
arch/powerpc/mm/book3s32/Makefile | 2 ++
arch/powerpc/mm/book3s64/Makefile | 2 ++
arch/powerpc/mm/nohash/Makefile | 2 ++
4 files changed, 8 insertions(+)
diff --git a/arch/powerpc/mm/Makefile b/arch/powerpc/mm/Makefile
index 8c1582b2987d..33e51abb5aac 100644
--- a/arch/powerpc/mm/Makefile
+++ b/arch/powerpc/mm/Makefile
@@ -3,6 +3,8 @@
# Makefile for the linux ppc-specific parts of the memory manager.
#
+CONTEXT_ANALYSIS := y
+
obj-y := fault.o mem.o pgtable.o maccess.o pageattr.o \
init_$(BITS).o pgtable_$(BITS).o \
pgtable-frag.o ioremap.o ioremap_$(BITS).o \
diff --git a/arch/powerpc/mm/book3s32/Makefile b/arch/powerpc/mm/book3s32/Makefile
index 50dd8f6bdf46..d5069a586c7b 100644
--- a/arch/powerpc/mm/book3s32/Makefile
+++ b/arch/powerpc/mm/book3s32/Makefile
@@ -1,5 +1,7 @@
# SPDX-License-Identifier: GPL-2.0
+CONTEXT_ANALYSIS := y
+
KASAN_SANITIZE_mmu.o := n
ifdef CONFIG_KASAN
diff --git a/arch/powerpc/mm/book3s64/Makefile b/arch/powerpc/mm/book3s64/Makefile
index 33af5795856a..c5d8d2ef72ac 100644
--- a/arch/powerpc/mm/book3s64/Makefile
+++ b/arch/powerpc/mm/book3s64/Makefile
@@ -1,5 +1,7 @@
# SPDX-License-Identifier: GPL-2.0
+CONTEXT_ANALYSIS := y
+
obj-y += mmu_context.o pgtable.o trace.o
ifdef CONFIG_PPC_64S_HASH_MMU
CFLAGS_REMOVE_slb.o = $(CC_FLAGS_FTRACE)
diff --git a/arch/powerpc/mm/nohash/Makefile b/arch/powerpc/mm/nohash/Makefile
index cf60c776c883..7d7409d2cf97 100644
--- a/arch/powerpc/mm/nohash/Makefile
+++ b/arch/powerpc/mm/nohash/Makefile
@@ -1,5 +1,7 @@
# SPDX-License-Identifier: GPL-2.0
+CONTEXT_ANALYSIS := y
+
obj-y += mmu_context.o tlb.o tlb_low.o kup.o
obj-$(CONFIG_PPC_BOOK3E_64) += tlb_64e.o tlb_low_64e.o book3e_pgtable.o
obj-$(CONFIG_44x) += 44x.o
--
2.39.5
^ permalink raw reply [flat|nested] 19+ messages in thread* [PATCHv2 07/18] powerpc/pseries: Drop inline from hugepage invalidate
2026-11-19 3:38 [PATCHv2 00/18] powerpc/mm, pseries, powernv: Enable clang context analysis Ritesh Harjani (IBM)
` (5 preceding siblings ...)
2026-11-19 3:39 ` [PATCHv2 06/18] powerpc/mm: Enable context analysis Ritesh Harjani (IBM)
@ 2026-11-19 3:39 ` Ritesh Harjani (IBM)
2026-11-19 3:39 ` [PATCHv2 08/18] powerpc/pseries: Rework hugepage invalidate to remove conditional locking Ritesh Harjani (IBM)
` (10 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Ritesh Harjani (IBM) @ 2026-11-19 3:39 UTC (permalink / raw)
To: linuxppc-dev
Cc: Madhavan Srinivasan, Michael Ellerman, Christophe Leroy,
Venkat Rao Bagalkote, Shrikanth Hegde, linux-kernel, Marco Elver,
Ritesh Harjani (IBM)
Leave __pSeries_lpar_hugepage_invalidate() static and let the
compiler decide whether to inline it.
Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
---
arch/powerpc/platforms/pseries/lpar.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/powerpc/platforms/pseries/lpar.c b/arch/powerpc/platforms/pseries/lpar.c
index 6a415febc53b..94cd30e9f6e1 100644
--- a/arch/powerpc/platforms/pseries/lpar.c
+++ b/arch/powerpc/platforms/pseries/lpar.c
@@ -1225,7 +1225,7 @@ static void hugepage_bulk_invalidate(unsigned long *slot, unsigned long *vpn,
}
}
-static inline void __pSeries_lpar_hugepage_invalidate(unsigned long *slot,
+static void __pSeries_lpar_hugepage_invalidate(unsigned long *slot,
unsigned long *vpn,
int count, int psize,
int ssize)
--
2.39.5
^ permalink raw reply [flat|nested] 19+ messages in thread* [PATCHv2 08/18] powerpc/pseries: Rework hugepage invalidate to remove conditional locking
2026-11-19 3:38 [PATCHv2 00/18] powerpc/mm, pseries, powernv: Enable clang context analysis Ritesh Harjani (IBM)
` (6 preceding siblings ...)
2026-11-19 3:39 ` [PATCHv2 07/18] powerpc/pseries: Drop inline from hugepage invalidate Ritesh Harjani (IBM)
@ 2026-11-19 3:39 ` Ritesh Harjani (IBM)
2026-11-19 3:39 ` [PATCHv2 09/18] powerpc/pseries: Rework hash flush " Ritesh Harjani (IBM)
` (9 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Ritesh Harjani (IBM) @ 2026-11-19 3:39 UTC (permalink / raw)
To: linuxppc-dev
Cc: Madhavan Srinivasan, Michael Ellerman, Christophe Leroy,
Venkat Rao Bagalkote, Shrikanth Hegde, linux-kernel, Marco Elver,
Ritesh Harjani (IBM)
Clang's compiler based static context analysis does not work with locks
that are conditionally taken like in __pSeries_lpar_hugepage_invalidate().
lpar.c:1240:6: error: spinlock 'pSeries_lpar_tlbie_lock' is not held on every path through here [-Werror,-Wthread-safety-analysis]
But this also simplifies the function definition in my opinion - so this
is also a win.
No functional change intended.
Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
---
arch/powerpc/platforms/pseries/lpar.c | 25 ++++++++++++++++---------
1 file changed, 16 insertions(+), 9 deletions(-)
diff --git a/arch/powerpc/platforms/pseries/lpar.c b/arch/powerpc/platforms/pseries/lpar.c
index 94cd30e9f6e1..abd77c45cbf4 100644
--- a/arch/powerpc/platforms/pseries/lpar.c
+++ b/arch/powerpc/platforms/pseries/lpar.c
@@ -1224,26 +1224,33 @@ static void hugepage_bulk_invalidate(unsigned long *slot, unsigned long *vpn,
BUG_ON(rc != H_SUCCESS);
}
}
-
-static void __pSeries_lpar_hugepage_invalidate(unsigned long *slot,
+static void __pSeries_lpar_hugepage_invalidate_unlocked(unsigned long *slot,
unsigned long *vpn,
int count, int psize,
int ssize)
{
- unsigned long flags = 0;
- int lock_tlbie = !mmu_has_feature(MMU_FTR_LOCKLESS_TLBIE);
-
- if (lock_tlbie)
- spin_lock_irqsave(&pSeries_lpar_tlbie_lock, flags);
-
/* Assuming THP size is 16M */
if (is_supported_hlbkrm(psize, MMU_PAGE_16M))
hugepage_block_invalidate(slot, vpn, count, psize, ssize);
else
hugepage_bulk_invalidate(slot, vpn, count, psize, ssize);
+}
- if (lock_tlbie)
+static void __pSeries_lpar_hugepage_invalidate(unsigned long *slot,
+ unsigned long *vpn,
+ int count, int psize,
+ int ssize)
+{
+ unsigned long flags = 0;
+
+ if (!mmu_has_feature(MMU_FTR_LOCKLESS_TLBIE)) {
+ spin_lock_irqsave(&pSeries_lpar_tlbie_lock, flags);
+ __pSeries_lpar_hugepage_invalidate_unlocked(slot, vpn, count, psize, ssize);
spin_unlock_irqrestore(&pSeries_lpar_tlbie_lock, flags);
+ return;
+ }
+
+ __pSeries_lpar_hugepage_invalidate_unlocked(slot, vpn, count, psize, ssize);
}
static void pSeries_lpar_hugepage_invalidate(unsigned long vsid,
--
2.39.5
^ permalink raw reply [flat|nested] 19+ messages in thread* [PATCHv2 09/18] powerpc/pseries: Rework hash flush to remove conditional locking
2026-11-19 3:38 [PATCHv2 00/18] powerpc/mm, pseries, powernv: Enable clang context analysis Ritesh Harjani (IBM)
` (7 preceding siblings ...)
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 ` Ritesh Harjani (IBM)
2026-11-19 3:39 ` [PATCHv2 10/18] powerpc/pseries: Add context annotations for the DTL worker lock Ritesh Harjani (IBM)
` (8 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Ritesh Harjani (IBM) @ 2026-11-19 3:39 UTC (permalink / raw)
To: linuxppc-dev
Cc: Madhavan Srinivasan, Michael Ellerman, Christophe Leroy,
Venkat Rao Bagalkote, Shrikanth Hegde, linux-kernel, Marco Elver,
Ritesh Harjani (IBM)
Clang's compiler based static context analysis does not work with locks
that are conditionally taken like in pSeries_lpar_flush_hash_range().
This also simplifies the function definition in my opinion - so this
is also a win.
No functional change intended.
Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
---
arch/powerpc/platforms/pseries/lpar.c | 31 ++++++++++++++++-----------
1 file changed, 18 insertions(+), 13 deletions(-)
diff --git a/arch/powerpc/platforms/pseries/lpar.c b/arch/powerpc/platforms/pseries/lpar.c
index abd77c45cbf4..5dbf447d3a83 100644
--- a/arch/powerpc/platforms/pseries/lpar.c
+++ b/arch/powerpc/platforms/pseries/lpar.c
@@ -1526,28 +1526,19 @@ void __init pseries_lpar_read_hblkrm_characteristics(void)
bpsize, idx, hblkrm_size[bpsize][idx]);
}
-/*
- * Take a spinlock around flushes to avoid bouncing the hypervisor tlbie
- * lock.
- */
-static void pSeries_lpar_flush_hash_range(unsigned long number, int local)
+static void pSeries_lpar_flush_hash_range_unlocked(unsigned long number, int local)
{
unsigned long vpn;
unsigned long i, pix, rc;
- unsigned long flags = 0;
struct ppc64_tlb_batch *batch = this_cpu_ptr(&ppc64_tlb_batch);
- int lock_tlbie = !mmu_has_feature(MMU_FTR_LOCKLESS_TLBIE);
unsigned long param[PLPAR_HCALL9_BUFSIZE];
unsigned long index, shift, slot;
real_pte_t pte;
int psize, ssize;
- if (lock_tlbie)
- spin_lock_irqsave(&pSeries_lpar_tlbie_lock, flags);
-
if (is_supported_hlbkrm(batch->psize, batch->psize)) {
do_block_remove(number, batch, param);
- goto out;
+ return;
}
psize = batch->psize;
@@ -1587,10 +1578,24 @@ static void pSeries_lpar_flush_hash_range(unsigned long number, int local)
param[6], param[7]);
BUG_ON(rc != H_SUCCESS);
}
+}
-out:
- if (lock_tlbie)
+/*
+ * Take a spinlock around flushes to avoid bouncing the hypervisor tlbie
+ * lock. Firmware with MMU_FTR_LOCKLESS_TLBIE does not need it.
+ */
+static void pSeries_lpar_flush_hash_range(unsigned long number, int local)
+{
+ unsigned long flags;
+
+ if (!mmu_has_feature(MMU_FTR_LOCKLESS_TLBIE)) {
+ spin_lock_irqsave(&pSeries_lpar_tlbie_lock, flags);
+ pSeries_lpar_flush_hash_range_unlocked(number, local);
spin_unlock_irqrestore(&pSeries_lpar_tlbie_lock, flags);
+ return;
+ }
+
+ pSeries_lpar_flush_hash_range_unlocked(number, local);
}
static int __init disable_bulk_remove(char *str)
--
2.39.5
^ permalink raw reply [flat|nested] 19+ messages in thread* [PATCHv2 10/18] powerpc/pseries: Add context annotations for the DTL worker lock
2026-11-19 3:38 [PATCHv2 00/18] powerpc/mm, pseries, powernv: Enable clang context analysis Ritesh Harjani (IBM)
` (8 preceding siblings ...)
2026-11-19 3:39 ` [PATCHv2 09/18] powerpc/pseries: Rework hash flush " Ritesh Harjani (IBM)
@ 2026-11-19 3:39 ` Ritesh Harjani (IBM)
2026-11-19 3:39 ` [PATCHv2 11/18] powerpc/pseries: Annotate the VPD sequence lock context Ritesh Harjani (IBM)
` (7 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Ritesh Harjani (IBM) @ 2026-11-19 3:39 UTC (permalink / raw)
To: linuxppc-dev
Cc: Madhavan Srinivasan, Michael Ellerman, Christophe Leroy,
Venkat Rao Bagalkote, Shrikanth Hegde, linux-kernel, Marco Elver,
Ritesh Harjani (IBM)
dtl_worker_{enable,disable}() needs annotations since they acquire and
release locks. So this adds conditional annotation based on return value.
Let's also disable context analysis for vcpudispatch_stats_write(),
since based on received input, it can leave the lock held until a later
write of 0 unlocks it. So we need to mark it with __context_unsafe().
Otherwise we get following error on enabling CONTEXT_ANALYSIS on this
file:
lpar.c:490:9: error: rw_semaphore 'dtl_access_lock' is not held on every path through here [-Werror,-Wthread-safety-analysis]
lpar.c:498:2: error: releasing rw_semaphore 'dtl_access_lock' that was not held [-Werror,-Wthread-safety-analysis]
Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
---
arch/powerpc/platforms/pseries/lpar.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/arch/powerpc/platforms/pseries/lpar.c b/arch/powerpc/platforms/pseries/lpar.c
index 5dbf447d3a83..9965ead1e93c 100644
--- a/arch/powerpc/platforms/pseries/lpar.c
+++ b/arch/powerpc/platforms/pseries/lpar.c
@@ -461,6 +461,7 @@ static void reset_global_dtl_mask(void)
}
static int dtl_worker_enable(unsigned long *time_limit)
+ __cond_acquires(0, &dtl_access_lock)
{
int rc = 0, state;
@@ -491,6 +492,7 @@ static int dtl_worker_enable(unsigned long *time_limit)
}
static void dtl_worker_disable(unsigned long *time_limit)
+ __releases(&dtl_access_lock)
{
cpuhp_remove_state(dtl_worker_state);
free_dtl_buffers(time_limit);
@@ -500,6 +502,7 @@ static void dtl_worker_disable(unsigned long *time_limit)
static ssize_t vcpudispatch_stats_write(struct file *file, const char __user *p,
size_t count, loff_t *ppos)
+ __context_unsafe(/* dtl_access_lock is held from enable write until disable write */)
{
unsigned long time_limit = jiffies + HZ;
struct vcpu_dispatch_data *disp;
--
2.39.5
^ permalink raw reply [flat|nested] 19+ messages in thread* [PATCHv2 11/18] powerpc/pseries: Annotate the VPD sequence lock context
2026-11-19 3:38 [PATCHv2 00/18] powerpc/mm, pseries, powernv: Enable clang context analysis Ritesh Harjani (IBM)
` (9 preceding siblings ...)
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 ` Ritesh Harjani (IBM)
2026-11-19 3:39 ` [PATCHv2 12/18] powerpc/pseries: Annotate the RTAS indices " Ritesh Harjani (IBM)
` (6 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Ritesh Harjani (IBM) @ 2026-11-19 3:39 UTC (permalink / raw)
To: linuxppc-dev
Cc: Madhavan Srinivasan, Michael Ellerman, Christophe Leroy,
Venkat Rao Bagalkote, Shrikanth Hegde, linux-kernel, Marco Elver,
Ritesh Harjani (IBM)
Clang's context analysis reports:
papr-vpd.c:151:1: error: mutex 'rtas_ibm_get_vpd_lock' is still held at the end of function [-Werror,-Wthread-safety-analysis]
papr-vpd.c:165:2: error: releasing mutex 'rtas_ibm_get_vpd_lock' that was not held [-Werror,-Wthread-safety-analysis]
Add the necessary annotations to in vpd_sequence_{begin|end}(),
to fix these errors for enabling Clang context analysis.
Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
---
arch/powerpc/platforms/pseries/papr-vpd.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/arch/powerpc/platforms/pseries/papr-vpd.c b/arch/powerpc/platforms/pseries/papr-vpd.c
index f38c188fc4a1..8d210454cff1 100644
--- a/arch/powerpc/platforms/pseries/papr-vpd.c
+++ b/arch/powerpc/platforms/pseries/papr-vpd.c
@@ -123,8 +123,10 @@ static int rtas_ibm_get_vpd(struct rtas_ibm_get_vpd_params *params)
* @seq: vpd call parameters from sequence struct
*
* Context: May sleep.
+ * Returns with rtas_ibm_get_vpd_lock held. vpd_sequence_end() releases it.
*/
static void vpd_sequence_begin(struct papr_rtas_sequence *seq)
+ __acquires(&rtas_ibm_get_vpd_lock)
{
struct rtas_ibm_get_vpd_params *vpd_params;
/*
@@ -157,6 +159,7 @@ static void vpd_sequence_begin(struct papr_rtas_sequence *seq)
* Releases resources obtained by vpd_sequence_begin().
*/
static void vpd_sequence_end(struct papr_rtas_sequence *seq)
+ __releases(&rtas_ibm_get_vpd_lock)
{
struct rtas_ibm_get_vpd_params *vpd_params;
--
2.39.5
^ permalink raw reply [flat|nested] 19+ messages in thread* [PATCHv2 12/18] powerpc/pseries: Annotate the RTAS indices sequence lock context
2026-11-19 3:38 [PATCHv2 00/18] powerpc/mm, pseries, powernv: Enable clang context analysis Ritesh Harjani (IBM)
` (10 preceding siblings ...)
2026-11-19 3:39 ` [PATCHv2 11/18] powerpc/pseries: Annotate the VPD sequence lock context Ritesh Harjani (IBM)
@ 2026-11-19 3:39 ` Ritesh Harjani (IBM)
2026-11-19 3:39 ` [PATCHv2 13/18] powerpc/pseries: Annotate the RTAS physical-attestation " Ritesh Harjani (IBM)
` (5 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Ritesh Harjani (IBM) @ 2026-11-19 3:39 UTC (permalink / raw)
To: linuxppc-dev
Cc: Madhavan Srinivasan, Michael Ellerman, Christophe Leroy,
Venkat Rao Bagalkote, Shrikanth Hegde, linux-kernel, Marco Elver,
Ritesh Harjani (IBM)
Clang's context analysis reports:
papr-indices.c:145:1: error: mutex 'rtas_ibm_get_indices_lock' is still held at the end of function [-Werror,-Wthread-safety-analysis]
papr-indices.c:158:2: error: releasing mutex 'rtas_ibm_get_indices_lock' that was not held [-Werror,-Wthread-safety-analysis]
Add the necessary annotations to indices_sequence_{begin|end}(),
to fix these errors for enabling Clang context analysis.
Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
---
arch/powerpc/platforms/pseries/papr-indices.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/arch/powerpc/platforms/pseries/papr-indices.c b/arch/powerpc/platforms/pseries/papr-indices.c
index 3c7545591c45..3f3b88f708a3 100644
--- a/arch/powerpc/platforms/pseries/papr-indices.c
+++ b/arch/powerpc/platforms/pseries/papr-indices.c
@@ -126,8 +126,10 @@ static int rtas_ibm_get_indices(struct rtas_get_indices_params *params)
* indices_sequence_begin() - Begin a indices retrieval sequence.
*
* Context: May sleep.
+ * Returns with rtas_ibm_get_indices_lock held. indices_sequence_end() releases it.
*/
static void indices_sequence_begin(struct papr_rtas_sequence *seq)
+ __acquires(&rtas_ibm_get_indices_lock)
{
struct rtas_get_indices_params *param;
@@ -150,6 +152,7 @@ static void indices_sequence_begin(struct papr_rtas_sequence *seq)
* Releases resources obtained by indices_sequence_begin().
*/
static void indices_sequence_end(struct papr_rtas_sequence *seq)
+ __releases(&rtas_ibm_get_indices_lock)
{
struct rtas_get_indices_params *param;
--
2.39.5
^ permalink raw reply [flat|nested] 19+ messages in thread* [PATCHv2 13/18] powerpc/pseries: Annotate the RTAS physical-attestation sequence lock context
2026-11-19 3:38 [PATCHv2 00/18] powerpc/mm, pseries, powernv: Enable clang context analysis Ritesh Harjani (IBM)
` (11 preceding siblings ...)
2026-11-19 3:39 ` [PATCHv2 12/18] powerpc/pseries: Annotate the RTAS indices " Ritesh Harjani (IBM)
@ 2026-11-19 3:39 ` Ritesh Harjani (IBM)
2026-11-19 3:39 ` [PATCHv2 14/18] powerpc/pseries: Annotate the DTL debugfs read " Ritesh Harjani (IBM)
` (4 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Ritesh Harjani (IBM) @ 2026-11-19 3:39 UTC (permalink / raw)
To: linuxppc-dev
Cc: Madhavan Srinivasan, Michael Ellerman, Christophe Leroy,
Venkat Rao Bagalkote, Shrikanth Hegde, linux-kernel, Marco Elver,
Ritesh Harjani (IBM)
Clang's context analysis reports:
papr-phy-attest.c:154:1: error: mutex 'rtas_ibm_physical_attestation_lock' is still held at the end of function [-Werror,-Wthread-safety-analysis]
papr-phy-attest.c:169:2: error: releasing mutex 'rtas_ibm_physical_attestation_lock' that was not held [-Werror,-Wthread-safety-analysis]
Add the necessary annotations to phy_attest_sequence_{begin|end}(),
to fix these errors for enabling Clang context analysis.
Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
---
arch/powerpc/platforms/pseries/papr-phy-attest.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/arch/powerpc/platforms/pseries/papr-phy-attest.c b/arch/powerpc/platforms/pseries/papr-phy-attest.c
index 350ba26e5962..d2bc5c0da422 100644
--- a/arch/powerpc/platforms/pseries/papr-phy-attest.c
+++ b/arch/powerpc/platforms/pseries/papr-phy-attest.c
@@ -133,8 +133,11 @@ static int rtas_physical_attestation(struct rtas_phy_attest_params *params)
* @seq: user specified parameters for RTAS call from seq struct.
*
* Context: May sleep.
+ * Returns with rtas_ibm_physical_attestation_lock held.
+ * phy_attest_sequence_end() releases it.
*/
static void phy_attest_sequence_begin(struct papr_rtas_sequence *seq)
+ __acquires(&rtas_ibm_physical_attestation_lock)
{
struct rtas_phy_attest_params *param;
@@ -161,6 +164,7 @@ static void phy_attest_sequence_begin(struct papr_rtas_sequence *seq)
* Releases resources obtained by phy_attest_sequence_begin().
*/
static void phy_attest_sequence_end(struct papr_rtas_sequence *seq)
+ __releases(&rtas_ibm_physical_attestation_lock)
{
struct rtas_phy_attest_params *param;
--
2.39.5
^ permalink raw reply [flat|nested] 19+ messages in thread* [PATCHv2 14/18] powerpc/pseries: Annotate the DTL debugfs read lock context
2026-11-19 3:38 [PATCHv2 00/18] powerpc/mm, pseries, powernv: Enable clang context analysis Ritesh Harjani (IBM)
` (12 preceding siblings ...)
2026-11-19 3:39 ` [PATCHv2 13/18] powerpc/pseries: Annotate the RTAS physical-attestation " Ritesh Harjani (IBM)
@ 2026-11-19 3:39 ` Ritesh Harjani (IBM)
2026-11-19 3:39 ` [PATCHv2 15/18] powerpc/pseries: Disable context analysis for the CMM hotplug notifier Ritesh Harjani (IBM)
` (3 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Ritesh Harjani (IBM) @ 2026-11-19 3:39 UTC (permalink / raw)
To: linuxppc-dev
Cc: Madhavan Srinivasan, Michael Ellerman, Christophe Leroy,
Venkat Rao Bagalkote, Shrikanth Hegde, linux-kernel, Marco Elver,
Ritesh Harjani (IBM)
Clang's context analysis reports:
dtl.c: error: rw_semaphore 'dtl_access_lock' is still held at the end of function [-Werror,-Wthread-safety-analysis]
dtl.c: error: releasing rw_semaphore 'dtl_access_lock' that was not held [-Werror,-Wthread-safety-analysis]
Add the necessary annotations to
dtl_{enable|disable}(), dtl_file{open|release}(),
to fix these errors for enabling Clang context analysis.
Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
---
arch/powerpc/platforms/pseries/dtl.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/arch/powerpc/platforms/pseries/dtl.c b/arch/powerpc/platforms/pseries/dtl.c
index f293588b8c7b..18c597210103 100644
--- a/arch/powerpc/platforms/pseries/dtl.c
+++ b/arch/powerpc/platforms/pseries/dtl.c
@@ -177,7 +177,12 @@ static u64 dtl_current_index(struct dtl *dtl)
}
#endif /* CONFIG_VIRT_CPU_ACCOUNTING_NATIVE */
+/*
+ * On success the read lock stays held until dtl_disable(). That covers
+ * the whole time the debugfs file is open.
+ */
static int dtl_enable(struct dtl *dtl)
+ __cond_acquires_shared(0, &dtl_access_lock)
{
long int n_entries;
long int rc;
@@ -225,6 +230,7 @@ static int dtl_enable(struct dtl *dtl)
}
static void dtl_disable(struct dtl *dtl)
+ __releases_shared(&dtl_access_lock)
{
spin_lock(&dtl->lock);
dtl_stop(dtl);
@@ -238,6 +244,7 @@ static void dtl_disable(struct dtl *dtl)
/* file interface */
static int dtl_file_open(struct inode *inode, struct file *filp)
+ __cond_acquires_shared(0, &dtl_access_lock)
{
struct dtl *dtl = inode->i_private;
int rc;
@@ -251,6 +258,7 @@ static int dtl_file_open(struct inode *inode, struct file *filp)
}
static int dtl_file_release(struct inode *inode, struct file *filp)
+ __releases_shared(&dtl_access_lock)
{
struct dtl *dtl = inode->i_private;
dtl_disable(dtl);
--
2.39.5
^ permalink raw reply [flat|nested] 19+ messages in thread* [PATCHv2 15/18] powerpc/pseries: Disable context analysis for the CMM hotplug notifier
2026-11-19 3:38 [PATCHv2 00/18] powerpc/mm, pseries, powernv: Enable clang context analysis Ritesh Harjani (IBM)
` (13 preceding siblings ...)
2026-11-19 3:39 ` [PATCHv2 14/18] powerpc/pseries: Annotate the DTL debugfs read " Ritesh Harjani (IBM)
@ 2026-11-19 3:39 ` Ritesh Harjani (IBM)
2026-11-19 3:39 ` [PATCHv2 16/18] powerpc/pseries: Enable context analysis Ritesh Harjani (IBM)
` (2 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Ritesh Harjani (IBM) @ 2026-11-19 3:39 UTC (permalink / raw)
To: linuxppc-dev
Cc: Madhavan Srinivasan, Michael Ellerman, Christophe Leroy,
Venkat Rao Bagalkote, Shrikanth Hegde, linux-kernel, Marco Elver,
Ritesh Harjani (IBM)
Clang's context analysis reports:
cmm.c: error: mutex 'hotplug_mutex' is still held at the end of function [-Werror,-Wthread-safety-analysis]
cmm.c: error: releasing mutex 'hotplug_mutex' that was not held [-Werror,-Wthread-safety-analysis]
cmm_memory_cb() takes hotplug_mutex on MEM_GOING_OFFLINE and drops it
on a later MEM_OFFLINE or MEM_CANCEL_OFFLINE call.
Add __context_unsafe() annotation for cmm_memory_cb() callback to avoid
the reported build error in order to enable Clang context analysis.
Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
---
arch/powerpc/platforms/pseries/cmm.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/powerpc/platforms/pseries/cmm.c b/arch/powerpc/platforms/pseries/cmm.c
index 38e22125b96f..159efe734785 100644
--- a/arch/powerpc/platforms/pseries/cmm.c
+++ b/arch/powerpc/platforms/pseries/cmm.c
@@ -470,6 +470,7 @@ static struct notifier_block cmm_reboot_nb = {
**/
static int cmm_memory_cb(struct notifier_block *self,
unsigned long action, void *arg)
+ __context_unsafe(/* Conditional locking */)
{
switch (action) {
case MEM_GOING_OFFLINE:
--
2.39.5
^ permalink raw reply [flat|nested] 19+ messages in thread* [PATCHv2 16/18] powerpc/pseries: Enable context analysis
2026-11-19 3:38 [PATCHv2 00/18] powerpc/mm, pseries, powernv: Enable clang context analysis Ritesh Harjani (IBM)
` (14 preceding siblings ...)
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 ` 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)
17 siblings, 0 replies; 19+ messages in thread
From: Ritesh Harjani (IBM) @ 2026-11-19 3:39 UTC (permalink / raw)
To: linuxppc-dev
Cc: Madhavan Srinivasan, Michael Ellerman, Christophe Leroy,
Venkat Rao Bagalkote, Shrikanth Hegde, linux-kernel, Marco Elver,
Ritesh Harjani (IBM)
pseries objects now build with Clang context analysis enabled.
Turn it on for the directory.
This checks that each lock taken in this code is dropped on every path.
Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
---
arch/powerpc/platforms/pseries/Makefile | 3 +++
1 file changed, 3 insertions(+)
diff --git a/arch/powerpc/platforms/pseries/Makefile b/arch/powerpc/platforms/pseries/Makefile
index 3ced289a675b..d5f9beec33cc 100644
--- a/arch/powerpc/platforms/pseries/Makefile
+++ b/arch/powerpc/platforms/pseries/Makefile
@@ -1,4 +1,7 @@
# SPDX-License-Identifier: GPL-2.0
+
+CONTEXT_ANALYSIS := y
+
ccflags-$(CONFIG_PPC_PSERIES_DEBUG) += -DDEBUG
obj-y := lpar.o hvCall.o nvram.o reconfig.o \
--
2.39.5
^ permalink raw reply [flat|nested] 19+ messages in thread* [PATCHv2 17/18] powerpc/powernv: Rework OPAL console write to remove conditional locking
2026-11-19 3:38 [PATCHv2 00/18] powerpc/mm, pseries, powernv: Enable clang context analysis Ritesh Harjani (IBM)
` (15 preceding siblings ...)
2026-11-19 3:39 ` [PATCHv2 16/18] powerpc/pseries: Enable context analysis Ritesh Harjani (IBM)
@ 2026-11-19 3:39 ` Ritesh Harjani (IBM)
2026-11-19 3:39 ` [PATCHv2 18/18] powerpc/powernv: Enable context analysis Ritesh Harjani (IBM)
17 siblings, 0 replies; 19+ messages in thread
From: Ritesh Harjani (IBM) @ 2026-11-19 3:39 UTC (permalink / raw)
To: linuxppc-dev
Cc: Madhavan Srinivasan, Michael Ellerman, Christophe Leroy,
Venkat Rao Bagalkote, Shrikanth Hegde, linux-kernel, Marco Elver,
Ritesh Harjani (IBM)
Clang's context analysis reports:
opal.c:454:7: error: spinlock 'opal_write_lock' is not held on every path through here [-Werror,-Wthread-safety-analysis]
opal.c:493:3: error: releasing spinlock 'opal_write_lock' that was not held [-Werror,-Wthread-safety-analysis]
This patch rework the OPAL console write function to remove this
conditional locking to fix the reported build errors while enabling
Clang context analysis. We could have marked __context_unsafe(),
but this anyways simplifies the locking a bit.
Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
---
arch/powerpc/platforms/powernv/opal.c | 30 ++++++++++++++++++---------
1 file changed, 20 insertions(+), 10 deletions(-)
diff --git a/arch/powerpc/platforms/powernv/opal.c b/arch/powerpc/platforms/powernv/opal.c
index 1946dbdc9fa1..aea83c4be76d 100644
--- a/arch/powerpc/platforms/powernv/opal.c
+++ b/arch/powerpc/platforms/powernv/opal.c
@@ -438,19 +438,13 @@ ssize_t opal_get_chars(uint32_t vtermno, u8 *buf, size_t count)
return 0;
}
-static ssize_t __opal_put_chars(uint32_t vtermno, const u8 *data,
- size_t total_len, bool atomic)
+static ssize_t __opal_put_chars_unlocked(uint32_t vtermno, const u8 *data,
+ size_t total_len, bool atomic)
{
- unsigned long flags = 0 /* shut up gcc */;
ssize_t written;
__be64 olen;
s64 rc;
- if (!opal.entry)
- return -ENODEV;
-
- if (atomic)
- spin_lock_irqsave(&opal_write_lock, flags);
rc = opal_console_write_buffer_space(vtermno, &olen);
if (rc || be64_to_cpu(olen) < total_len) {
/* Closed -> drop characters */
@@ -489,10 +483,26 @@ static ssize_t __opal_put_chars(uint32_t vtermno, const u8 *data,
}
out:
- if (atomic)
+ return written;
+}
+
+static ssize_t __opal_put_chars(uint32_t vtermno, const u8 *data,
+ size_t total_len, bool atomic)
+{
+ unsigned long flags = 0;
+ ssize_t written;
+
+ if (!opal.entry)
+ return -ENODEV;
+
+ if (atomic) {
+ spin_lock_irqsave(&opal_write_lock, flags);
+ written = __opal_put_chars_unlocked(vtermno, data, total_len, true);
spin_unlock_irqrestore(&opal_write_lock, flags);
+ return written;
+ }
- return written;
+ return __opal_put_chars_unlocked(vtermno, data, total_len, false);
}
ssize_t opal_put_chars(uint32_t vtermno, const u8 *data, size_t total_len)
--
2.39.5
^ permalink raw reply [flat|nested] 19+ messages in thread* [PATCHv2 18/18] powerpc/powernv: Enable context analysis
2026-11-19 3:38 [PATCHv2 00/18] powerpc/mm, pseries, powernv: Enable clang context analysis Ritesh Harjani (IBM)
` (16 preceding siblings ...)
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 ` Ritesh Harjani (IBM)
17 siblings, 0 replies; 19+ messages in thread
From: Ritesh Harjani (IBM) @ 2026-11-19 3:39 UTC (permalink / raw)
To: linuxppc-dev
Cc: Madhavan Srinivasan, Michael Ellerman, Christophe Leroy,
Venkat Rao Bagalkote, Shrikanth Hegde, linux-kernel, Marco Elver,
Ritesh Harjani (IBM)
powernv objects now build with Clang context analysis enabled.
Turn it on for the directory.
This checks that each lock taken in this code is dropped on every path.
Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
---
arch/powerpc/platforms/powernv/Makefile | 2 ++
1 file changed, 2 insertions(+)
diff --git a/arch/powerpc/platforms/powernv/Makefile b/arch/powerpc/platforms/powernv/Makefile
index 9e5d0c847ee2..834a56122aaa 100644
--- a/arch/powerpc/platforms/powernv/Makefile
+++ b/arch/powerpc/platforms/powernv/Makefile
@@ -1,5 +1,7 @@
# SPDX-License-Identifier: GPL-2.0
+CONTEXT_ANALYSIS := y
+
# nothing that deals with real mode is safe to KASAN
# in particular, idle code runs a bunch of things in real mode
KASAN_SANITIZE_idle.o := n
--
2.39.5
^ permalink raw reply [flat|nested] 19+ messages in thread