From: Waiman Long <waiman.long@hpe.com>
To: xinhui <xinhui.pan@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
Arnd Bergmann <arnd@arndb.de>, <linux-arch@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <waiman.long@hp.com>
Subject: Re: [PATCH] locking/qrwlock: fix write unlock issue in big endian
Date: Fri, 3 Jun 2016 16:57:55 -0400 [thread overview]
Message-ID: <5751EF53.3080205@hpe.com> (raw)
In-Reply-To: <201606030718.u537FQg0009963@mx0a-001b2d01.pphosted.com>
On 06/03/2016 03:17 AM, xinhui wrote:
>
> On 2016年06月02日 19:02, Peter Zijlstra wrote:
>> On Thu, Jun 02, 2016 at 12:44:51PM +0200, Arnd Bergmann wrote:
>>> On Thursday, June 2, 2016 6:09:08 PM CEST Pan Xinhui wrote:
>>>> diff --git a/include/asm-generic/qrwlock.h
>>>> b/include/asm-generic/qrwlock.h
>>>> index 54a8e65..eadd7a3 100644
>>>> --- a/include/asm-generic/qrwlock.h
>>>> +++ b/include/asm-generic/qrwlock.h
>>>> @@ -139,7 +139,7 @@ static inline void queued_read_unlock(struct
>>>> qrwlock *lock)
>>>> */
>>>> static inline void queued_write_unlock(struct qrwlock *lock)
>>>> {
>>>> - smp_store_release((u8 *)&lock->cnts, 0);
>>>> + (void)atomic_sub_return_release(_QW_LOCKED, &lock->cnts);
>>>> }
>>>
>>> Isn't this more expensive than the existing version?
>>
>> Yes, loads. And while this might be a suitable fix for asm-generic, it
>> will introduce a fairly large regression on x86 (which is currently the
>> only user of this).
>>
> well, to show respect to struct __qrwlock private field.
> We can keep smp_store_release((u8 *)&lock->cnts, 0) in little_endian
> machine.
> as this should be quick and no performance issue to all other
> archs(although there is only 1 now)
>
> BUT, We need use (void)atomic_sub_return_release(_QW_LOCKED,
> &lock->cnts) in big_endian machine.
> because it's bad to export struct __qrwlock and set its private field
> to NULL.
>
> How about code like below.
>
> static inline void queued_write_unlock(struct qrwlock *lock)
> {
> #ifdef __BIG_ENDIAN
> (void)atomic_sub_return_release(_QW_LOCKED, &lock->cnts);
> #else
> smp_store_release((u8 *)&lock->cnts, 0);
> #endif
> }
>
> BUT I think that would make thing a little complex to understand. :(
> So at last, in my opinion, I suggest my patch :)
> any thoughts?
Another alternative is to make queued_write_unlock() overrideable from
asm/qrwlock.h, just like what we did with queued_spin_unlock().
Cheers,
Longman
next prev parent reply other threads:[~2016-06-03 20:58 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-02 10:09 [PATCH] locking/qrwlock: fix write unlock issue in big endian Pan Xinhui
2016-06-02 10:44 ` Arnd Bergmann
2016-06-02 11:01 ` xinhui
2016-06-02 11:15 ` Peter Zijlstra
2016-06-03 7:20 ` xinhui
2016-06-02 11:02 ` Peter Zijlstra
2016-06-03 7:17 ` xinhui
[not found] ` <201606030718.u537FQg0009963@mx0a-001b2d01.pphosted.com>
2016-06-03 20:57 ` Waiman Long [this message]
2016-06-06 3:15 ` xinhui
2016-06-08 9:22 ` Will Deacon
2016-06-14 6:11 ` xinhui
2016-06-14 10:40 ` Will Deacon
2016-06-15 3:47 ` xinhui
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=5751EF53.3080205@hpe.com \
--to=waiman.long@hpe.com \
--cc=arnd@arndb.de \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=waiman.long@hp.com \
--cc=xinhui.pan@linux.vnet.ibm.com \
/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;
as well as URLs for NNTP newsgroup(s).