[RFC 04/12] powerpc/pseries: Add context annotations for the DTL worker lock

From: Ritesh Harjani (IBM)

Date: Sun Sep 27 2026 - 10:35:47 EST


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@xxxxxxxxx>
---
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