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 0A7F9481257 for ; Tue, 5 May 2026 16:12:59 +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=1777997581; cv=none; b=sKSSOXS3/QMP6TUZsJvqQHJPGXyhzRz5ZKiGAFLhqrW8xvhdiBFMYSP0F9Yfzdba7e67wIUJjdEIdN94GskqPvfl0noXxoaL6niaQs5oCj7VVcbhe/WQpVsyeMq63S9Vbq7z/Dx+o/KFmJlfx/hroInh3KPMTSbb7xzA6y9aZy8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777997581; c=relaxed/simple; bh=M7J8GXJlc7L2yzKwXTGYz9m2a++/QgUoI4jjqawJeDc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Atleyft+wR0z9t8FhDj++5uXzrUHgb9GyGBa/2r2nZjFYttoyQSlZCt29TGltxieT3XGlvFYSZRc8Qcejh7I11aj6VAGkZjyjFd4g6xN6XrYlMd0HeYLU9o7L4h0L85qzKZ8GpDiUd5zj9yr+r95u0Fzx6getotF7tkG2gu0I84= 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=U6c/xAIN; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=kMulEGrJ; 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="U6c/xAIN"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="kMulEGrJ" Date: Tue, 5 May 2026 18:12:56 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1777997577; 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=C8/HfKHd0oHX5bHrUa3pwQAGaUy0ydefv9Smwq8s1Sg=; b=U6c/xAINmYF2nxP0nTIxKiDlkHmUjeaQImSAezkeVT8KQx2bEA4Pw6+OwtyZvDqoB69FWH RNe7YvuPJ1Yn0ylQf0ql6OyVxECAsv7Dll3wX9Q0yLlaDkjsCPId49BHPAlxtBDG45BDEG Fmje76ZMEWS7XBzTpROw9lRGoDB5RslZB3g3euvc0ydAgDlKZVMPwS622jSDerJI8fHXYx 6Qvik+qpPvzJhQg5JtiB5/UADxwhV50QA3gfYUnxe5Edyr66cuCPwAV6xemLkKZW5pbZht x63VwvjaI9I7iPuuB5rkG4OzhKKx3ZtJ4zfBS6vZb/lTIZfiT3RWFV8xHfajJg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1777997577; 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=C8/HfKHd0oHX5bHrUa3pwQAGaUy0ydefv9Smwq8s1Sg=; b=kMulEGrJCRdPAEiMBRgeFTDjSTnBfJ5v/EvyMvDsM4NxAn5mi9tSouxdQOeR4xtCk+NcPO DGo/y09qSvCaEkAg== 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: <20260505161256.0NhG6_Hm@linutronix.de> References: <20260505022649.870788-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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: <20260505022649.870788-1-bvanassche@acm.org> On 2026-05-05 04:26:44 [+0200], Bart Van Assche wrote: > --- a/include/linux/rtmutex.h > +++ b/include/linux/rtmutex.h > @@ -56,6 +56,8 @@ static inline struct task_struct *rt_mutex_owner(struct= rt_mutex_base *lock) > #endif > extern void rt_mutex_base_init(struct rt_mutex_base *rtb); > =20 > +context_lock_struct(rt_mutex); What does this do? Shouldn't this define the struct? > /** > * The rt_mutex structure > * > @@ -108,8 +110,10 @@ do { \ > extern void __rt_mutex_init(struct rt_mutex *lock, const char *name, str= uct lock_class_key *key); > =20 > #ifdef CONFIG_DEBUG_LOCK_ALLOC > -extern void rt_mutex_lock_nested(struct rt_mutex *lock, unsigned int sub= class); > -extern void _rt_mutex_lock_nest_lock(struct rt_mutex *lock, struct lockd= ep_map *nest_lock); > +extern void rt_mutex_lock_nested(struct rt_mutex *lock, unsigned int sub= class) > + __acquires(lock); > +extern void _rt_mutex_lock_nest_lock(struct rt_mutex *lock, struct lockd= ep_map *nest_lock) > + __acquires(lock); > #define rt_mutex_lock(lock) rt_mutex_lock_nested(lock, 0) > #define rt_mutex_lock_nest_lock(lock, nest_lock) \ > do { \ > @@ -118,15 +122,19 @@ extern void _rt_mutex_lock_nest_lock(struct rt_mute= x *lock, struct lockdep_map * > } while (0) > =20 > #else > -extern void rt_mutex_lock(struct rt_mutex *lock); > +extern void rt_mutex_lock(struct rt_mutex *lock) __acquires(lock); So this is "one" thing where you add annotation to the rt_mutex*() API for external users. Then you add the wait_lock annotation. Different scope but okay. =E2=80=A6 > --- 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 int su= bclass) > + __no_context_analysis /* ignoring the return value below is fine in thi= s case */ > { > __rt_mutex_lock_common(lock, TASK_UNINTERRUPTIBLE, NULL, subclass); > } > EXPORT_SYMBOL_GPL(rt_mutex_lock_nested); > =20 > void __sched _rt_mutex_lock_nest_lock(struct rt_mutex *lock, struct lock= dep_map *nest_lock) > + __no_context_analysis /* ignoring the return value below is fine in thi= s case */ > { > __rt_mutex_lock_common(lock, TASK_UNINTERRUPTIBLE, nest_lock, 0); > } *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. Something like that would be nice for the comment. Not sure if "__no_context_analysis" is the right thing to do here. __acquires(lock) __no_context_analysis might be better if just __acquires leads to trouble. Sebastian