[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <320cf54f-719c-8aa5-17af-455a53db4478@windriver.com>
Date: Mon, 5 Jul 2021 22:52:34 +0800
From: "Xu, Yanfei" <yanfei.xu@...driver.com>
To: Peter Zijlstra <peterz@...radead.org>
Cc: mingo@...hat.com, longman@...hat.com, boqun.feng@...il.com,
will@...nel.org, linux-kernel@...r.kernel.org
Subject: Re: [RFC][PATCH 1/4] locking/mutex: Use try_cmpxchg()
On 7/5/21 10:00 PM, Peter Zijlstra wrote:
> [Please note: This e-mail is from an EXTERNAL e-mail address]
>
> On Mon, Jul 05, 2021 at 07:59:12PM +0800, Xu, Yanfei wrote:
>>
>>
>> On 6/30/21 11:35 PM, Peter Zijlstra wrote:
>>> For simpler and better code.
>>>
>>> Signed-off-by: Peter Zijlstra (Intel)<peterz@...radead.org>
>>> ---
>>> kernel/locking/mutex.c | 27 ++++++---------------------
>>> 1 file changed, 6 insertions(+), 21 deletions(-)
>>
>> Hi Peter,
>>
>> I read the mutex codes today, and find there seems something wrong for the
>> patch. Should we consider the race condition as blow?
>>
>> From 4035f50c96e17cbe3febab768b64da5c000e5b76 Mon Sep 17 00:00:00 2001
>> From: Yanfei Xu <yanfei.xu@...driver.com>
>> Date: Mon, 5 Jul 2021 17:56:58 +0800
>> Subject: [PATCH] locking/mutex: fix the endless loop when racing against
>> mutex.owner
>>
>> if a race condition happened on mutex.owner after we fetch its value,
>> atomic_long_try_cmpxchg_acquire/release invoked on &mutex.owner will
>> return false. Then we need to reassign the temporary variable which
>> saves mutex.owner value if in loop, or it will lead an endless loop.
>
> No, when try_cmpxchg() fails it will update oldp. This is the reason old
> is now a pointer too.
Got it. Thanks!
Yanfei
>
Powered by blists - more mailing lists