From nobody Sat Feb 7 07:26:04 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 27D2616FF5F for ; Mon, 12 Aug 2024 10:42:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723459330; cv=none; b=oMShiJG1SxdlPeyimwly9gbt4PcZpKbsQtiRobCvNAtiE51K5Zz54n4AekEPh4II5+tRes3MJ+Dku8PHvxP1lojBcysnO18j8VSMj6PVa1LRf52JiKHQc0/sy3l8N/X2EAeJuE6PCx6CeA7q0ciaDyke8oCYHvFXKSMYwS+cBmk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723459330; c=relaxed/simple; bh=4/Af0Ld7a8M7egpq5joT7M4CMURrpFr9NCOgulnJn4c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CE5b8ZoE8d+7p81BszyUYgVLc9x7CsM1oNqZXhRZnBwmrPVt+TcFJkE7xYjoRjpcmd32j07u6mKUxqJ5F36pU4Yd+TDOSs+LxfP1Zsc4NAawhvvSD9NDEzDGh5XV26tWtgxLnC8DNK4WygXhC0g+hTYN59YEvsT7nQdB+Ny7T4s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=qnnSw8ve; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=JZycTMb1; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="qnnSw8ve"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="JZycTMb1" From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1723459327; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tXxiZ1HSlsfMpK9KfoV+2vAEQ7Qxc0sfPHhUxDuEOsA=; b=qnnSw8veRe6xMBV9unvIQE40hEEeeViF9Z9BMvBMlkl8WJBEkA5O4OpjC2DUs4DOqqXH2g XA1RkdIwFW3Xhhq2YRC27alnoeoVVJXP0iBincgt43sneKsOMvzDfebmzZVEQEvD0kpgaa X+WVAxfhwgB3SLPfaYBXOe9lf5TwGHTflAUOx791stq6530tzgykWgEPbv7B7L4uocNeqf I9prCZNmS4kaEHe3R9poBCAEYtZOWmHaiSfIb6vbNwbk2eR0gFpCUdo6G4ySOtINc5hl2T 8K9wFNY8TSrhAYDJK8LthZkdCoNIXhKWS1VVoKVsQBG/R2buMOvYaJnB8howfQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1723459327; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tXxiZ1HSlsfMpK9KfoV+2vAEQ7Qxc0sfPHhUxDuEOsA=; b=JZycTMb1Vr3zGEEDcnpVUQNJHS7vhyeMfGkDSzBEXgnWrdAdcCCqG4dwGRgOqWLiuKdKqi XE7IdARetDOm1FDg== To: linux-kernel@vger.kernel.org Cc: tglx@linutronix.de, Peter Zijlstra , Ingo Molnar , Will Deacon , Waiman Long , Boqun Feng , Sebastian Andrzej Siewior Subject: [PATCH 1/4] locking/rt: Add sparse annotation PREEMPT_RT's sleeping locks. Date: Mon, 12 Aug 2024 12:39:02 +0200 Message-ID: <20240812104200.2239232-2-bigeasy@linutronix.de> In-Reply-To: <20240812104200.2239232-1-bigeasy@linutronix.de> References: <20240812104200.2239232-1-bigeasy@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The sleeping locks on PREEMPT_RT (rt_spin_lock() and friends) lack sparse annotation. Therefore a missing spin_unlock() won't be spotted by sparse in a PREEMPT_RT build while it is noticed on a !PREEMPT_RT build. Add the __acquires/__releases macros to the lock/ unlock functions. The trylock functions already use the __cond_lock() wrapper. Signed-off-by: Sebastian Andrzej Siewior --- include/linux/rwlock_rt.h | 10 +++++----- include/linux/spinlock_rt.h | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/linux/rwlock_rt.h b/include/linux/rwlock_rt.h index 8544ff05e594d..7d81fc6918ee8 100644 --- a/include/linux/rwlock_rt.h +++ b/include/linux/rwlock_rt.h @@ -24,13 +24,13 @@ do { \ __rt_rwlock_init(rwl, #rwl, &__key); \ } while (0) =20 -extern void rt_read_lock(rwlock_t *rwlock); +extern void rt_read_lock(rwlock_t *rwlock) __acquires(rwlock); extern int rt_read_trylock(rwlock_t *rwlock); -extern void rt_read_unlock(rwlock_t *rwlock); -extern void rt_write_lock(rwlock_t *rwlock); -extern void rt_write_lock_nested(rwlock_t *rwlock, int subclass); +extern void rt_read_unlock(rwlock_t *rwlock) __releases(rwlock); +extern void rt_write_lock(rwlock_t *rwlock) __acquires(rwlock); +extern void rt_write_lock_nested(rwlock_t *rwlock, int subclass) __acquire= s(rwlock); extern int rt_write_trylock(rwlock_t *rwlock); -extern void rt_write_unlock(rwlock_t *rwlock); +extern void rt_write_unlock(rwlock_t *rwlock) __releases(rwlock); =20 static __always_inline void read_lock(rwlock_t *rwlock) { diff --git a/include/linux/spinlock_rt.h b/include/linux/spinlock_rt.h index 61c49b16f69ab..babc3e0287791 100644 --- a/include/linux/spinlock_rt.h +++ b/include/linux/spinlock_rt.h @@ -32,10 +32,10 @@ do { \ __rt_spin_lock_init(slock, #slock, &__key, true); \ } while (0) =20 -extern void rt_spin_lock(spinlock_t *lock); -extern void rt_spin_lock_nested(spinlock_t *lock, int subclass); -extern void rt_spin_lock_nest_lock(spinlock_t *lock, struct lockdep_map *n= est_lock); -extern void rt_spin_unlock(spinlock_t *lock); +extern void rt_spin_lock(spinlock_t *lock) __acquires(lock); +extern void rt_spin_lock_nested(spinlock_t *lock, int subclass) __acquires= (lock); +extern void rt_spin_lock_nest_lock(spinlock_t *lock, struct lockdep_map *n= est_lock) __acquires(lock); +extern void rt_spin_unlock(spinlock_t *lock) __releases(lock); extern void rt_spin_lock_unlock(spinlock_t *lock); extern int rt_spin_trylock_bh(spinlock_t *lock); extern int rt_spin_trylock(spinlock_t *lock); --=20 2.45.2 From nobody Sat Feb 7 07:26:04 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7C3D7170822 for ; Mon, 12 Aug 2024 10:42:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723459331; cv=none; b=WVF81cLfEdU8WeMehgVUN4lJq33kLE8mueUhFp/iw5CJGDp1xo3YYjJFzpqDx63m6t5DDAgUBoeRZRJbe4zHlh1CweP3iSCZUJpzzYOkmarqAbNfuz/REPtYFZOGYXuAlJV9UZyAVdO3pMM173mJIWrMHVqRyr/Sj+AYhJtAPuU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723459331; c=relaxed/simple; bh=VZsmijDKid7tM6bWHfJ2i17Rl/uZiaKRSPrRusNR354=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UtWjT4mseHmCHC93SoGY5NJZAIvwK6Km4S2b2weD2xgaNaZ3ZgXgotObAopa2dinO7iH3E/6Wxf2TwJ1Y9UbKM7c6yI2NpLDhW27Iho7t6i/RHDv0yiCPLQLtesg72c+SYZvnZOSH2gRbMXsXArM5Vtum5J/ggUzrpqlZ8P4yIg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=pnGqhcfg; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=yy/FdoPn; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="pnGqhcfg"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="yy/FdoPn" From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1723459327; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IK5+JoyiPBwiFxOBi7sh5IY29l1DPeZVngamdBZqWlE=; b=pnGqhcfgIiZBxBgSO1floZLDQxwb/ZGh8kLQS3z0MzvxvWVMpWLGCcIIuuy6FG3JppnV7Y /G6qKxNFHExJEIgEDh9sq2bSut+E7e9914p95ytudCKj4pSB13K/a1N0T507vmXU1eS9VR 7iEEOD9YiW+YkHjWmmIlb1GHosrAkhE75A0Kco2szoz2Nvy1ZHCUT/rDKrQyBd2iseLhiY VWLIZFO64eXjkaDQLwC/RzdRM3GGMwJPKyLWqJbzuGt6tSsKDlCqCMcgqr8Pb/FdwtoGFJ L2drPrD0uOiq6zHLW3ZRZxQPqd3sE3GDc+L75i7yCXpSXoh8g0nd2VL5UVsVew== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1723459327; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IK5+JoyiPBwiFxOBi7sh5IY29l1DPeZVngamdBZqWlE=; b=yy/FdoPn21b7isxdYGFY/7drcx4Ao49x4L07DelLdi2nIXZUSDEa8vyWCvbl9lwdHQc8nT SuR9a5xy6GopaWBQ== To: linux-kernel@vger.kernel.org Cc: tglx@linutronix.de, Peter Zijlstra , Ingo Molnar , Will Deacon , Waiman Long , Boqun Feng , Sebastian Andrzej Siewior Subject: [PATCH 2/4] locking/rt: Remove one __cond_lock() in RT's spin_trylock_irqsave() Date: Mon, 12 Aug 2024 12:39:03 +0200 Message-ID: <20240812104200.2239232-3-bigeasy@linutronix.de> In-Reply-To: <20240812104200.2239232-1-bigeasy@linutronix.de> References: <20240812104200.2239232-1-bigeasy@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" spin_trylock_irqsave() has a __cond_lock() wrapper which points to __spin_trylock_irqsave(). The function then invokes spin_trylock() which has another __cond_lock() finally pointing to rt_spin_trylock(). The compiler has no problem to parse this but sparse does not recognise that users of spin_trylock_irqsave() acquire a conditional lock and complains. Remove one layer of __cond_lock() so that sparse recognises conditional locking. Signed-off-by: Sebastian Andrzej Siewior --- include/linux/spinlock_rt.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/include/linux/spinlock_rt.h b/include/linux/spinlock_rt.h index babc3e0287791..f9f14e135be7b 100644 --- a/include/linux/spinlock_rt.h +++ b/include/linux/spinlock_rt.h @@ -132,7 +132,7 @@ static __always_inline void spin_unlock_irqrestore(spin= lock_t *lock, #define spin_trylock_irq(lock) \ __cond_lock(lock, rt_spin_trylock(lock)) =20 -#define __spin_trylock_irqsave(lock, flags) \ +#define spin_trylock_irqsave(lock, flags) \ ({ \ int __locked; \ \ @@ -142,9 +142,6 @@ static __always_inline void spin_unlock_irqrestore(spin= lock_t *lock, __locked; \ }) =20 -#define spin_trylock_irqsave(lock, flags) \ - __cond_lock(lock, __spin_trylock_irqsave(lock, flags)) - #define spin_is_contended(lock) (((void)(lock), 0)) =20 static inline int spin_is_locked(spinlock_t *lock) --=20 2.45.2 From nobody Sat Feb 7 07:26:04 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AD85C170828 for ; Mon, 12 Aug 2024 10:42:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723459331; cv=none; b=Odjh5e8+xG+jwJGEKgoH8e+8kAF6P7OJQTEKI35nZr40oVjSRyWeLzaUAhte7Kcbt23SUBcMrZ5NmDBnww9yG7KSEjcdNX8bYoMxgybdD+m0FveuOUL3+ib+FPu1Y+SfhI/BcDJ4UqoYGlM9ivvkVEck/tyLuBiKyFnysFpGJHs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723459331; c=relaxed/simple; bh=3YlCf+NMedo/zckHv+HKZtFLRIW9P7oYH0jrPJuPsjg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=O93Yq3xW86leS30nAW+fIXpVevvWsRwIdjskKoNdDghHFqFsmuDcxNfb21+AMOGCXBX08WWrctK5VAit2bNGT3w5VqVDs2YOC5PT0ep0tLkauE9FSLHhGsbtBxIKrz80Y+sDBN8ZcoI35IwFDBJl9wBR+FJModa/huVvREOysx0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=Q89qmv+V; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=PAqY91R4; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Q89qmv+V"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="PAqY91R4" From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1723459328; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HjM0SVz4kOhTwFkccQW4pdtbDEZ+SXQVrvLOG1uKGio=; b=Q89qmv+VXxTqLVtX4/T44UE4ZxLlLXKVLBQ6u+mODYLH8vgTuOxlsp1BeUp1e1iY4o6DHb 27B7TgLqHxwCQxNhg+qTyapAi6MTLjk4smOBeMbkomxbMZXylms0AdS2ta7FXMh6c1Gi0j WH2qM/Dwzg3w/xnkHmNPZlMGxfr28u/WEHD6n1Hyj105OON6odMuJ8QlRMuIjSR6qB9OP6 0uJ3ARboAwOkdWqtzfj55XQw7MWaLtw4CN/Pp4GXZIOFly8TeMIsaPgXHj8VvPHE6tfINc D9VMajfaikJhnEd2+7k1113duI+6Cwm8bVf/fxw7eoq5/Pb5u71UeFX5HpkVYw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1723459328; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HjM0SVz4kOhTwFkccQW4pdtbDEZ+SXQVrvLOG1uKGio=; b=PAqY91R49R2Se8/OJwSIjBb0SWEsbsgoWN3dDwRS6IVI/yYVo8BDWbAMx6uRSpLUXYB2Vr utC6xpqumLTguBCA== To: linux-kernel@vger.kernel.org Cc: tglx@linutronix.de, Peter Zijlstra , Ingo Molnar , Will Deacon , Waiman Long , Boqun Feng , Sebastian Andrzej Siewior Subject: [PATCH 3/4] locking/rt: Add sparse annotation for RCU. Date: Mon, 12 Aug 2024 12:39:04 +0200 Message-ID: <20240812104200.2239232-4-bigeasy@linutronix.de> In-Reply-To: <20240812104200.2239232-1-bigeasy@linutronix.de> References: <20240812104200.2239232-1-bigeasy@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Every lock, that becomes a sleeping on PREEMPT_RT, starts a RCU read section. There is no sparse annotation for this and sparse complains about unbalanced locking. Add __acquires/ __releases for the RCU lock. This covers all but the trylock functions. I tried the __cond_acquires() annotation but it didn't work. Signed-off-by: Sebastian Andrzej Siewior --- kernel/locking/spinlock_rt.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/kernel/locking/spinlock_rt.c b/kernel/locking/spinlock_rt.c index 38e292454fccb..d1cf8b2b6dcac 100644 --- a/kernel/locking/spinlock_rt.c +++ b/kernel/locking/spinlock_rt.c @@ -51,7 +51,7 @@ static __always_inline void __rt_spin_lock(spinlock_t *lo= ck) migrate_disable(); } =20 -void __sched rt_spin_lock(spinlock_t *lock) +void __sched rt_spin_lock(spinlock_t *lock) __acquires(RCU) { spin_acquire(&lock->dep_map, 0, 0, _RET_IP_); __rt_spin_lock(lock); @@ -75,7 +75,7 @@ void __sched rt_spin_lock_nest_lock(spinlock_t *lock, EXPORT_SYMBOL(rt_spin_lock_nest_lock); #endif =20 -void __sched rt_spin_unlock(spinlock_t *lock) +void __sched rt_spin_unlock(spinlock_t *lock) __releases(RCU) { spin_release(&lock->dep_map, _RET_IP_); migrate_enable(); @@ -225,7 +225,7 @@ int __sched rt_write_trylock(rwlock_t *rwlock) } EXPORT_SYMBOL(rt_write_trylock); =20 -void __sched rt_read_lock(rwlock_t *rwlock) +void __sched rt_read_lock(rwlock_t *rwlock) __acquires(RCU) { rtlock_might_resched(); rwlock_acquire_read(&rwlock->dep_map, 0, 0, _RET_IP_); @@ -235,7 +235,7 @@ void __sched rt_read_lock(rwlock_t *rwlock) } EXPORT_SYMBOL(rt_read_lock); =20 -void __sched rt_write_lock(rwlock_t *rwlock) +void __sched rt_write_lock(rwlock_t *rwlock) __acquires(RCU) { rtlock_might_resched(); rwlock_acquire(&rwlock->dep_map, 0, 0, _RET_IP_); @@ -246,7 +246,7 @@ void __sched rt_write_lock(rwlock_t *rwlock) EXPORT_SYMBOL(rt_write_lock); =20 #ifdef CONFIG_DEBUG_LOCK_ALLOC -void __sched rt_write_lock_nested(rwlock_t *rwlock, int subclass) +void __sched rt_write_lock_nested(rwlock_t *rwlock, int subclass) __acquir= es(RCU) { rtlock_might_resched(); rwlock_acquire(&rwlock->dep_map, subclass, 0, _RET_IP_); @@ -257,7 +257,7 @@ void __sched rt_write_lock_nested(rwlock_t *rwlock, int= subclass) EXPORT_SYMBOL(rt_write_lock_nested); #endif =20 -void __sched rt_read_unlock(rwlock_t *rwlock) +void __sched rt_read_unlock(rwlock_t *rwlock) __releases(RCU) { rwlock_release(&rwlock->dep_map, _RET_IP_); migrate_enable(); @@ -266,7 +266,7 @@ void __sched rt_read_unlock(rwlock_t *rwlock) } EXPORT_SYMBOL(rt_read_unlock); =20 -void __sched rt_write_unlock(rwlock_t *rwlock) +void __sched rt_write_unlock(rwlock_t *rwlock) __releases(RCU) { rwlock_release(&rwlock->dep_map, _RET_IP_); rcu_read_unlock(); --=20 2.45.2 From nobody Sat Feb 7 07:26:04 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E13E1170849 for ; Mon, 12 Aug 2024 10:42:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723459331; cv=none; b=YxbZ7o1Jj5OcyccnR5wm8PTrjJrowz5kjotJwK6+6TnFz+ZhssUVUyuvsTCs5RKCGSFp15r5Ql6khQxl4NiDHQEapn57COWTzECKxkD2k5nHPhvHPtI+kuNQJ1LBv+eN33gy90PoNUj5sfic+ALDuwOXLivLXHCcOhJAMpDaSoo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723459331; c=relaxed/simple; bh=o4+8ORhhb5Y21RAzXkUl06n1R34xyy+UUpRzOGGKZ+Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DGCYn8SB9AXG9RwSrxb2oUPBqR4V4YrZCJ6MinAs/0CdBkti+lg2dCopfSzTFP/PIiC4wDedPr07vQLFii/0IO+doTvviX6ytCxIs0v5DBJia+Se0x9EtvZ/jk0zURQdfFinCPuCh24OL8WnuEngXZ46FlFvUJZuaXSBjmNmhRs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=nvxVVDey; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=AkMPmLRu; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="nvxVVDey"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="AkMPmLRu" From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1723459328; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aqu+zvdYqrYNOg+n+RIMOdzPm3Y/ZxUaNwQty9rNRHw=; b=nvxVVDeyXDsl7iCaqZk6uQoosl9dSoINQ/qdd6jiLKUPyolagycvVdrC/K9uWHHEWm4ok2 rOVJkYzMoSFg1PDmjNSvMrgqg+pNKuGfMkutuHdfM/AAPF6pOj2govCYRkAGN8adX5hdHf qmHnvSJHpdjzFNCHjpWUei5D8KEOxWf8nNeJUM5F/YfvuMf50PEA+h+o3SI7oKCKh9ds47 rBzG+1/u3bXEkCTqDTWbn1rFf4JZBcEY5E6rfiTwJNo3k2zorV/rlcVs9e0nb+5z97OIAN oz+4Bs4Cwn1NShx26OHX6Gi9sX/8UrE/RP3J7JGKwncjN9e6J3Gwt5hrAT178w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1723459328; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aqu+zvdYqrYNOg+n+RIMOdzPm3Y/ZxUaNwQty9rNRHw=; b=AkMPmLRuIubd0nMzhD0v11HsvaZtd+kJ6uPVy4dA9d0aS592u77/OMHRFug7DPrS3Ns8AH 9Psh/CLw9zlnl1AA== To: linux-kernel@vger.kernel.org Cc: tglx@linutronix.de, Peter Zijlstra , Ingo Molnar , Will Deacon , Waiman Long , Boqun Feng , Sebastian Andrzej Siewior Subject: [PATCH 4/4] locking/rt: Annotate unlock followed by lock for sparse. Date: Mon, 12 Aug 2024 12:39:05 +0200 Message-ID: <20240812104200.2239232-5-bigeasy@linutronix.de> In-Reply-To: <20240812104200.2239232-1-bigeasy@linutronix.de> References: <20240812104200.2239232-1-bigeasy@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" rt_mutex_slowlock_block() and rtlock_slowlock_locked() both unlock lock::wait_lock and then lock it later. This is unusual and sparse complains about it. Add __releases() + __acquires() annotation to mark that it is expected. Signed-off-by: Sebastian Andrzej Siewior --- kernel/locking/rtmutex.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/locking/rtmutex.c b/kernel/locking/rtmutex.c index 88d08eeb8bc03..e389078bddecb 100644 --- a/kernel/locking/rtmutex.c +++ b/kernel/locking/rtmutex.c @@ -1601,6 +1601,7 @@ static int __sched rt_mutex_slowlock_block(struct rt_= mutex_base *lock, unsigned int state, struct hrtimer_sleeper *timeout, struct rt_mutex_waiter *waiter) + __releases(&lock->wait_lock) __acquires(&lock->wait_lock) { struct rt_mutex *rtm =3D container_of(lock, struct rt_mutex, rtmutex); struct task_struct *owner; @@ -1804,6 +1805,7 @@ static __always_inline int __rt_mutex_lock(struct rt_= mutex_base *lock, * @lock: The underlying RT mutex */ static void __sched rtlock_slowlock_locked(struct rt_mutex_base *lock) + __releases(&lock->wait_lock) __acquires(&lock->wait_lock) { struct rt_mutex_waiter waiter; struct task_struct *owner; --=20 2.45.2