From: Peter Zijlstra <peterz@infradead.org>
To: Hernan Ponce de Leon <hernan.poncedeleon@huaweicloud.com>
Cc: Waiman Long <longman@redhat.com>,
paulmck@kernel.org, Arjan van de Ven <arjan@linux.intel.com>,
mingo@redhat.com, will@kernel.org, boqun.feng@gmail.com,
akpm@osdl.org, tglx@linutronix.de, joel@joelfernandes.org,
stern@rowland.harvard.edu, diogo.behrens@huawei.com,
jonas.oberhauser@huawei.com, linux-kernel@vger.kernel.org,
Hernan Ponce de Leon <hernanl.leon@huawei.com>,
stable@vger.kernel.org,
Jonas Oberhauser <jonas.oberhauser@huaweicloud.com>
Subject: Re: [PATCH] Fix data race in mark_rt_mutex_waiters
Date: Thu, 26 Jan 2023 13:20:07 +0100 [thread overview]
Message-ID: <Y9Jv9yL8x7/TAq/X@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <c300747a-cf81-0e2d-77ec-f861421291f9@huaweicloud.com>
On Thu, Jan 26, 2023 at 10:42:07AM +0100, Hernan Ponce de Leon wrote:
> On 1/24/2023 5:04 PM, Waiman Long wrote:
> >
> > On 1/24/23 10:52, Peter Zijlstra wrote:
> > > On Tue, Jan 24, 2023 at 10:42:24AM -0500, Waiman Long wrote:
> > >
> > > > I would suggest to do it as suggested by PeterZ. Instead of set_bit(),
> > > > however, it is probably better to use atomic_long_or() like
> > > >
> > > > atomic_long_or_relaxed(RT_MUTEX_HAS_WAITERS, (atomic_long_t
> > > > *)&lock->owner)
> > > That function doesn't exist, atomic_long_or() is implicitly relaxed for
> > > not returning a value.
> > >
> > You are right. atomic_long_or() doesn't have variants like some others.
> >
> > Cheers,
> > Longman
> >
>
> When you say "replace the whole of that function", do you mean "barrier
> included"? I argue in the other email that I think this should not affect
> correctness (at least not obviously), but removing the barrier is doing more
> than just fixing the data race as this patch suggests.
Well, set_bit() implies smp_mb(), atomic_long_or() does not and would
need to retain the barrier.
That said, the comments are all batshit. The top comment states relaxed
ordering is suffient since holding lock, the comment with the barrier
utterly fails to explain what it's ordering against.
So all that would need to be updated as well.
That said, looking at 1c0908d8e441 I'm not at all sure we need that
barrier. Even in the try_to_take_rt_mutex(.waiter=NULL) case, where we
skip over the task->pi_lock region, rt_mutex_set_owner(.acquire=true)
will be ACQUIRE.
And in case of rt_mutex_owner(), we fail the trylock (return with 0) and
a failed trylock does not imply any ordering.
So why are we having this barrier?
next prev parent reply other threads:[~2023-01-26 12:20 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-20 13:55 [PATCH] Fix data race in mark_rt_mutex_waiters Hernan Ponce de Leon
2023-01-20 14:58 ` Arjan van de Ven
2023-01-20 15:54 ` Paul E. McKenney
2023-01-22 15:24 ` Hernan Ponce de Leon
2023-01-23 16:40 ` Paul E. McKenney
2023-01-23 17:34 ` Alan Stern
2023-01-23 17:48 ` Paul E. McKenney
2023-01-23 20:02 ` Jonas Oberhauser
2023-01-24 14:57 ` Hernan Ponce de Leon
2023-01-24 15:42 ` Waiman Long
2023-01-24 15:52 ` Peter Zijlstra
2023-01-24 16:04 ` Waiman Long
2023-01-26 9:42 ` Hernan Ponce de Leon
2023-01-26 12:20 ` Peter Zijlstra [this message]
2023-01-26 14:20 ` Peter Zijlstra
2023-01-26 21:07 ` Hernan Ponce de Leon
2023-01-26 22:10 ` David Laight
2023-01-27 1:46 ` Waiman Long
2023-03-01 16:32 ` lock_torture results for different patches: Antonio Paolillo
2023-03-06 7:58 ` Hernan Ponce de Leon
2023-03-10 17:11 ` Paul E. McKenney
2023-01-24 16:12 ` [PATCH] Fix data race in mark_rt_mutex_waiters Paul E. McKenney
2023-01-20 16:23 ` Peter Zijlstra
2023-01-20 16:58 ` David Laight
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=Y9Jv9yL8x7/TAq/X@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=akpm@osdl.org \
--cc=arjan@linux.intel.com \
--cc=boqun.feng@gmail.com \
--cc=diogo.behrens@huawei.com \
--cc=hernan.poncedeleon@huaweicloud.com \
--cc=hernanl.leon@huawei.com \
--cc=joel@joelfernandes.org \
--cc=jonas.oberhauser@huawei.com \
--cc=jonas.oberhauser@huaweicloud.com \
--cc=linux-kernel@vger.kernel.org \
--cc=longman@redhat.com \
--cc=mingo@redhat.com \
--cc=paulmck@kernel.org \
--cc=stable@vger.kernel.org \
--cc=stern@rowland.harvard.edu \
--cc=tglx@linutronix.de \
--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