From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (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 7666B37F734 for ; Mon, 4 May 2026 09:39:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777887587; cv=none; b=VTVPBjDDRwkU4Q3J1mz7AwizTlNR0zbMWAbMRYe2u22uyLZYd7vVqZcE7DIQscgsp28tk74LFFv+L0Us/pbPbn5FTeCeqqicDFxORlaTJSVX6h2e7zoP4OSOEpaXSXjfWWsyU6jZdqOH5IfXM1bMKbcYL6xzbqJr4E+mF2RxEnE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777887587; c=relaxed/simple; bh=/T0kJFAeO7clTEg1BIhBFPli3FmVAbdrxBP842g1Ayo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=NL46/bkK1G7dlCy8sX4drpcLs19XAdTRlglTK3Oz0I9SJ3bXWhDQIdA7/5wl+Z8BkaKIhLBXfOuKhGpv+TcBzWbgrb1EbOfSkYAk8Av4QTzz2s8VhQsth6f9VbFaDR1Y66Bu1Dmi4jZc4STOIzVeRZmXJxJGjtLjlO4ZykRAC8I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=Vf0ZVYBn; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="Vf0ZVYBn" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=h+xSyx79b5aJ8unAi+XxvPDKlph82rQ/e0s8vbeY1RI=; b=Vf0ZVYBnW4xhQMZHRVLQgY+h0p HtDdJL/Bp4yRxMu0Bf/sAlcHZuvbBPnfKlh4gU19x6rQVsr2WF3+71FYDsdJBmqYR4yGDrIIPCF4o OygOXn2FOewE21Pd2/uusjAj4kunTUUFavjzurkq/8RX73uRGhfbnqONuhER6OBOlD64dSXYh9PKv FknCQirHp3kJVjyBHmKpjfPGDUF9or3jntXiLDNFsrEz0QuY9oR45+Fkrxfyr0lCK1prxVbtnDg7X iVwaf5+ax5cTfOne9hxWLOBoKOUd8bIga00EpOxJ6GJPu4xTJhX2rK4vAzRxCFQHUIkXiDecKq52C DJ7PnJqg==; Received: from 77-249-17-252.cable.dynamic.v4.ziggo.nl ([77.249.17.252] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.98.2 #2 (Red Hat Linux)) id 1wJpm1-00000000fZA-3qsT; Mon, 04 May 2026 09:39:33 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 6ED7B300969; Mon, 04 May 2026 11:39:32 +0200 (CEST) Date: Mon, 4 May 2026 11:39:32 +0200 From: Peter Zijlstra To: Bart Van Assche Cc: Marco Elver , linux-kernel@vger.kernel.org, Ingo Molnar , Will Deacon , Boqun Feng , Joel Granados , Alexei Starovoitov , Sebastian Andrzej Siewior , Vlastimil Babka Subject: Re: [PATCH] locking/rtmutex: Annotate API and implementation Message-ID: <20260504093932.GR3126523@noisy.programming.kicks-ass.net> References: <20260502015354.430273-1-bvanassche@acm.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260502015354.430273-1-bvanassche@acm.org> On Fri, May 01, 2026 at 06:53:49PM -0700, Bart Van Assche wrote: > Add lock context annotations to the rtmutex API and implementation and > enable lock context analysis. > > Signed-off-by: Bart Van Assche This does not build, I need at least the below, but then PREEMPT_RT is still not happy. --- --- a/include/linux/rtmutex.h +++ b/include/linux/rtmutex.h @@ -20,7 +20,7 @@ extern int max_lock_depth; -struct rt_mutex_base { +context_lock_struct(rt_mutex_base) { raw_spinlock_t wait_lock; struct rb_root_cached waiters __guarded_by(&wait_lock); struct task_struct *owner __guarded_by(&wait_lock); --- a/kernel/locking/rtmutex.c +++ b/kernel/locking/rtmutex.c @@ -314,6 +314,7 @@ static __always_inline bool rt_mutex_cmp static int __sched rt_mutex_slowtrylock(struct rt_mutex_base *lock); static __always_inline bool rt_mutex_try_acquire(struct rt_mutex_base *lock) + __cond_acquires(true, lock) { /* * With debug enabled rt_mutex_cmpxchg trylock() will always fail. @@ -1095,6 +1096,7 @@ static int __sched try_to_take_rt_mutex(struct rt_mutex_base *lock, struct task_struct *task, struct rt_mutex_waiter *waiter) __must_hold(&lock->wait_lock) + __cond_acquires(nonzero, lock) { lockdep_assert_held(&lock->wait_lock); @@ -1625,6 +1627,7 @@ static int __sched rt_mutex_slowlock_blo struct rt_mutex_waiter *waiter, struct wake_q_head *wake_q) __releases(&lock->wait_lock) __acquires(&lock->wait_lock) + __cond_acquires(0, lock) { struct rt_mutex *rtm = container_of(lock, struct rt_mutex, rtmutex); struct task_struct *owner; @@ -1715,6 +1718,7 @@ static int __sched __rt_mutex_slowlock(s struct rt_mutex_waiter *waiter, struct wake_q_head *wake_q) __must_hold(&lock->wait_lock) + __cond_acquires(0, lock) { struct rt_mutex *rtm = container_of(lock, struct rt_mutex, rtmutex); struct ww_mutex *ww = ww_container_of(rtm); @@ -1773,6 +1777,7 @@ static inline int __rt_mutex_slowlock_lo unsigned int state, struct wake_q_head *wake_q) __must_hold(&lock->wait_lock) + __cond_acquires(0, lock) { struct rt_mutex_waiter waiter; int ret; @@ -1797,6 +1802,7 @@ static inline int __rt_mutex_slowlock_lo static int __sched rt_mutex_slowlock(struct rt_mutex_base *lock, struct ww_acquire_ctx *ww_ctx, unsigned int state) + __cond_acquires(0, lock) { DEFINE_WAKE_Q(wake_q); unsigned long flags; @@ -1829,6 +1835,7 @@ static int __sched rt_mutex_slowlock(str static __always_inline int __rt_mutex_lock(struct rt_mutex_base *lock, unsigned int state) + __cond_acquires(0, lock) { lockdep_assert(!current->pi_blocked_on); --- a/kernel/locking/rtmutex_api.c +++ b/kernel/locking/rtmutex_api.c @@ -88,6 +88,7 @@ EXPORT_SYMBOL_GPL(_rt_mutex_lock_nest_lo * @lock: the rt_mutex to be locked */ void __sched rt_mutex_lock(struct rt_mutex *lock) + __no_context_analysis /* ignoring the return value below is fine in this case */ { __rt_mutex_lock_common(lock, TASK_UNINTERRUPTIBLE, NULL, 0); } @@ -532,7 +533,7 @@ static __always_inline int __mutex_lock_ unsigned int subclass, struct lockdep_map *nest_lock, unsigned long ip) - __acquires(lock) + __cond_acquires(0, lock) { int ret;