From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: Bart Van Assche <bvanassche@acm.org>
Cc: Peter Zijlstra <peterz@infradead.org>,
Marco Elver <elver@google.com>,
linux-kernel@vger.kernel.org, Ingo Molnar <mingo@redhat.com>,
Will Deacon <will@kernel.org>, Boqun Feng <boqun@kernel.org>,
Clark Williams <clrkwllms@kernel.org>,
Steven Rostedt <rostedt@goodmis.org>,
Joel Granados <joel.granados@kernel.org>,
Alexei Starovoitov <ast@kernel.org>,
Vlastimil Babka <vbabka@kernel.org>
Subject: Re: [PATCH v2] locking/rtmutex: Annotate API and implementation
Date: Wed, 6 May 2026 09:35:41 +0200 [thread overview]
Message-ID: <20260506073541.d8Ywsyl6@linutronix.de> (raw)
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);
> >
> > What does this do? Shouldn't this define the struct?
>
> 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, … 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 int 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);
> > > }
> >
> > *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.
>
> Yes, that's correct.
I meant this as an improved comment ;)
> > 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.
>
> There is an alternative that does not require __no_context_analysis:
>
> void __sched rt_mutex_lock_nested(struct rt_mutex *lock, unsigned int
> subclass)
> {
> int ret = __rt_mutex_lock_common(lock, TASK_UNINTERRUPTIBLE, NULL,
> subclass);
>
> BUG_ON(ret);
> }
> EXPORT_SYMBOL_GPL(rt_mutex_lock_nested);
>
> 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,
>
> Bart.
Sebastian
next prev parent reply other threads:[~2026-05-06 7:35 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-05 2:26 [PATCH v2] locking/rtmutex: Annotate API and implementation Bart Van Assche
2026-05-05 7:01 ` Sebastian Andrzej Siewior
2026-05-05 7:24 ` Bart Van Assche
2026-05-05 7:32 ` Sebastian Andrzej Siewior
2026-05-05 7:50 ` Bart Van Assche
2026-05-05 14:03 ` Sebastian Andrzej Siewior
2026-05-05 15:26 ` Bart Van Assche
2026-05-05 16:14 ` Sebastian Andrzej Siewior
2026-05-05 10:55 ` [tip: locking/core] " tip-bot2 for Bart Van Assche
2026-05-05 16:12 ` [PATCH v2] " Sebastian Andrzej Siewior
2026-05-05 20:05 ` Bart Van Assche
2026-05-06 7:35 ` Sebastian Andrzej Siewior [this message]
2026-05-06 9:53 ` Bart Van Assche
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260506073541.d8Ywsyl6@linutronix.de \
--to=bigeasy@linutronix.de \
--cc=ast@kernel.org \
--cc=boqun@kernel.org \
--cc=bvanassche@acm.org \
--cc=clrkwllms@kernel.org \
--cc=elver@google.com \
--cc=joel.granados@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=vbabka@kernel.org \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox