From mboxrd@z Thu Jan 1 00:00:00 1970 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 C1F7217A300 for ; Wed, 6 May 2026 07:35:43 +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=1778052945; cv=none; b=eN2Px+0F3TcbjDTCMSwi+xrbrlKt4XaR+x9LNNaZIYmye2As/hJNXXV5lRKecRZ65IcgYPqG66DmxBLmcS5F3u3eBKpmEqzO0dX0FXNHNDGpkKeZbVC8bzJ4FDzDIdWn7kYsMgLCw2NLwjwUkj1UGzCDkbcpuX+kgQzZ0LguKK4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778052945; c=relaxed/simple; bh=uKqY8UzWdQrZsaiz+LXIQZjwYlHpvjagkDTXn8juQpE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=pHkzIV6ihm3vMX6ljk8xRbirX/DhgHGKhqA0uO/lmx9nM5pxKwdID7OfiOryJ+slbr1glSUCt0d7kUOZaTcBAk6RURW0UQLor27GFzWrkNYN1//0dAVfmaIoNsYcsuSC0HekDYhVubIQjE3ysoe8edwV6KYY3BlEOvuemLKDPRc= 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=DDT1Byr+; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=7tdVVVFB; 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="DDT1Byr+"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="7tdVVVFB" Date: Wed, 6 May 2026 09:35:41 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1778052942; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Mb3NsoAV8Vy7w+rC4mCI1q7DzpfdemgivB5w4GOQhkc=; b=DDT1Byr++vXctqm0onoQfYDRSpIB5mVN11T9UawncvJ7VELRWCWpqGZaK9n+4aTvsPMZt6 XYnEZOyVzvjGDFJVcS3LJKSRV6F/TW8GudP0uRYi7dnSkx0EyY6HHa2ecVHOCekf0c4wjW Njvu7S1OXl2TQqRAuhGskqPlbEnnSJ7pJ/AoMf2k/1CCUHL5ZRdW9Z8M/RmeQDhQQiWL8q v9v7vRjWnXUsSSOEzQqS+Q9igPMheFFfq6GcdPgEk+MaCyE0iB8oK3EK+frWGe38n+GoKd USnMA1AhL+6DV2QGBVrLXXTqGrRgTnGkem9ZYfVlcoBtfYB8ExsgknrfD48nLg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1778052942; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Mb3NsoAV8Vy7w+rC4mCI1q7DzpfdemgivB5w4GOQhkc=; b=7tdVVVFB2esx8JxOriVx2QVn0F8Fr0k2JfaJlOy+LfbNoI0qW102wAJNjPU2AKQcXNYmHU hH67ZWzexmfvUxBQ== From: Sebastian Andrzej Siewior To: Bart Van Assche Cc: Peter Zijlstra , Marco Elver , linux-kernel@vger.kernel.org, Ingo Molnar , Will Deacon , Boqun Feng , Clark Williams , Steven Rostedt , Joel Granados , Alexei Starovoitov , Vlastimil Babka Subject: Re: [PATCH v2] locking/rtmutex: Annotate API and implementation Message-ID: <20260506073541.d8Ywsyl6@linutronix.de> References: <20260505022649.870788-1-bvanassche@acm.org> <20260505161256.0NhG6_Hm@linutronix.de> <41878012-e4db-4199-a3d5-ed2dc5badc0b@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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: <41878012-e4db-4199-a3d5-ed2dc5badc0b@acm.org> On 2026-05-05 22:05:51 [+0200], Bart Van Assche wrote: > On 5/5/26 6:12 PM, Sebastian Andrzej Siewior wrote: > > On 2026-05-05 04:26:44 [+0200], Bart Van Assche wrote: > > > +context_lock_struct(rt_mutex); > >=20 > > What does this do? Shouldn't this define the struct? >=20 > This enables context locking support for struct rt_mutex. I placed > context_lock_struct() on a line by itself because in my opinion that > results in a header file that is easier to read compared to > context_lock_struct(name) { ... }. Hmm. This was the confusing part, because everything else such as rwlock, rw_semaphore, mutex, =E2=80=A6 use that way. > > > --- a/kernel/locking/rtmutex_api.c > > > +++ b/kernel/locking/rtmutex_api.c > > > @@ -66,12 +67,14 @@ EXPORT_SYMBOL(rt_mutex_base_init); > > > * @subclass: the lockdep subclass > > > */ > > > void __sched rt_mutex_lock_nested(struct rt_mutex *lock, unsigned i= nt subclass) > > > + __no_context_analysis /* ignoring the return value below is fine in= this case */ > > > { > > > __rt_mutex_lock_common(lock, TASK_UNINTERRUPTIBLE, NULL, subclass); > > > } > > > EXPORT_SYMBOL_GPL(rt_mutex_lock_nested); > > > void __sched _rt_mutex_lock_nest_lock(struct rt_mutex *lock, struct= lockdep_map *nest_lock) > > > + __no_context_analysis /* ignoring the return value below is fine in= this case */ > > > { > > > __rt_mutex_lock_common(lock, TASK_UNINTERRUPTIBLE, nest_lock, 0); > > > } > >=20 > > *Why* is it okay? Because the void always acquire the lock and only the > > conditional locking (which can be interrupted by signal/ timeout) return > > an error if they failed to acquire the lock. >=20 > Yes, that's correct. I meant this as an improved comment ;) > > Something like that would be nice for the comment. > >=20 > > Not sure if "__no_context_analysis" is the right thing to do here. > > __acquires(lock) __no_context_analysis > >=20 > > might be better if just __acquires leads to trouble. >=20 > There is an alternative that does not require __no_context_analysis: >=20 > void __sched rt_mutex_lock_nested(struct rt_mutex *lock, unsigned int > subclass) > { > int ret =3D __rt_mutex_lock_common(lock, TASK_UNINTERRUPTIBLE, NU= LL, > subclass); >=20 > BUG_ON(ret); > } > EXPORT_SYMBOL_GPL(rt_mutex_lock_nested); >=20 > Please let me know which style you prefer. Hmm. This mostly reassembles __mutex_lock() from mutex.c which does the same thing. Couldn't we get away doing the same thing meaning a __cond_acquires() on those with a return value and a __acquire() in the void case? I think it would make sense to keep those two close in terms of annotations. > Thanks, >=20 > Bart. Sebastian