Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1421604 > unrolled thread

Re: [PATCH] locking/qrwlock: fix write unlock issue in big endian

Started byxinhui <xinhui.pan@linux.vnet.ibm.com>
First post2016-06-14 08:20 +0200
Last post2016-06-15 05:50 +0200
Articles 3 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH] locking/qrwlock: fix write unlock issue in big endian xinhui <xinhui.pan@linux.vnet.ibm.com> - 2016-06-14 08:20 +0200
    Re: [PATCH] locking/qrwlock: fix write unlock issue in big endian Will Deacon <will.deacon@arm.com> - 2016-06-14 12:50 +0200
      Re: [PATCH] locking/qrwlock: fix write unlock issue in big endian xinhui <xinhui.pan@linux.vnet.ibm.com> - 2016-06-15 05:50 +0200

#1421604 — Re: [PATCH] locking/qrwlock: fix write unlock issue in big endian

Fromxinhui <xinhui.pan@linux.vnet.ibm.com>
Date2016-06-14 08:20 +0200
SubjectRe: [PATCH] locking/qrwlock: fix write unlock issue in big endian
Message-ID<rJPRD-UQ-11@gated-at.bofh.it>
On 2016年06月08日 17:22, Will Deacon wrote:
> On Thu, Jun 02, 2016 at 06:09:08PM +0800, Pan Xinhui wrote:
>> strcut __qrwlock has different layout in big endian machine. we need set
>> the __qrwlock->wmode to NULL, and the address is not &lock->cnts in big
>> endian machine.
>>
>> Do as what read unlock does. we are lucky that the __qrwlock->wmode's
>> val is _QW_LOCKED.
>
> Doesn't this have wider implications for the qrwlocks, for example:
>
>    while ((cnts & _QW_WMASK) == _QW_LOCKED) { ... }
>
> would actually end up looking at the wrong field of the lock?
>
I does not clearly understand your idea. :(
the condition in the while() is always true from the view of current code.
BUT if __qrwlock has same layout on the two endian machine, the while() will end up. :)


> Shouldn't we just remove the #ifdef __LITTLE_ENDIAN stuff from __qrwlock,
> given that all the struct members are u8?
>
No. that makes codes complex. for example

struct __qrwlock lock;

WRITE_ONCE(lock->wmode, _QW_WAITING);
if (atomic_(&lock->cnts) == _QW_WAITING) {
	do_something();
}

IF you remove the  #ifdef __LITTLE_ENDIAN stuff from __qrwlock.
codes above obviously will break. And we already have such code.

thanks
xinhui

> Will
>

[toc] | [next] | [standalone]


#1421758

FromWill Deacon <will.deacon@arm.com>
Date2016-06-14 12:50 +0200
Message-ID<rJU4W-3FD-7@gated-at.bofh.it>
In reply to#1421604
On Tue, Jun 14, 2016 at 02:11:48PM +0800, xinhui wrote:
> 
> On 2016年06月08日 17:22, Will Deacon wrote:
> >On Thu, Jun 02, 2016 at 06:09:08PM +0800, Pan Xinhui wrote:
> >>strcut __qrwlock has different layout in big endian machine. we need set
> >>the __qrwlock->wmode to NULL, and the address is not &lock->cnts in big
> >>endian machine.
> >>
> >>Do as what read unlock does. we are lucky that the __qrwlock->wmode's
> >>val is _QW_LOCKED.
> >
> >Doesn't this have wider implications for the qrwlocks, for example:
> >
> >   while ((cnts & _QW_WMASK) == _QW_LOCKED) { ... }
> >
> >would actually end up looking at the wrong field of the lock?
> >
> I does not clearly understand your idea. :(

That's because I'm talking rubbish :) Sorry, I completely confused myself.
Locking is bad enough on its own, but add big-endian to the mix and I'm
all done.

> >Shouldn't we just remove the #ifdef __LITTLE_ENDIAN stuff from __qrwlock,
> >given that all the struct members are u8?
> >
> No. that makes codes complex. for example
> 
> struct __qrwlock lock;
> 
> WRITE_ONCE(lock->wmode, _QW_WAITING);
> if (atomic_(&lock->cnts) == _QW_WAITING) {
> 	do_something();
> }
> 
> IF you remove the  #ifdef __LITTLE_ENDIAN stuff from __qrwlock.
> codes above obviously will break. And we already have such code.

I was wondering more along the lines of having one definition of the data
structure, but then defining _QW_* differently depending on endianness
(i.e. add a << 24 when big-endian). That way queued_write_unlock can
stay like it is (having an arch override to handle the big-endian case
is incredibly ugly).

Will

[toc] | [prev] | [next] | [standalone]


#1422576

Fromxinhui <xinhui.pan@linux.vnet.ibm.com>
Date2016-06-15 05:50 +0200
Message-ID<rKa02-5Bx-25@gated-at.bofh.it>
In reply to#1421758

On 2016年06月14日 18:40, Will Deacon wrote:
> On Tue, Jun 14, 2016 at 02:11:48PM +0800, xinhui wrote:
>>
>> On 2016年06月08日 17:22, Will Deacon wrote:
>>> On Thu, Jun 02, 2016 at 06:09:08PM +0800, Pan Xinhui wrote:
>>>> strcut __qrwlock has different layout in big endian machine. we need set
>>>> the __qrwlock->wmode to NULL, and the address is not &lock->cnts in big
>>>> endian machine.
>>>>
>>>> Do as what read unlock does. we are lucky that the __qrwlock->wmode's
>>>> val is _QW_LOCKED.
>>>
>>> Doesn't this have wider implications for the qrwlocks, for example:
>>>
>>>    while ((cnts & _QW_WMASK) == _QW_LOCKED) { ... }
>>>
>>> would actually end up looking at the wrong field of the lock?
>>>
>> I does not clearly understand your idea. :(
>
> That's because I'm talking rubbish :) Sorry, I completely confused myself.
> Locking is bad enough on its own, but add big-endian to the mix and I'm
> all done.
>
>>> Shouldn't we just remove the #ifdef __LITTLE_ENDIAN stuff from __qrwlock,
>>> given that all the struct members are u8?
>>>
>> No. that makes codes complex. for example
>>
>> struct __qrwlock lock;
>>
>> WRITE_ONCE(lock->wmode, _QW_WAITING);
>> if (atomic_(&lock->cnts) == _QW_WAITING) {
>> 	do_something();
>> }
>>
>> IF you remove the  #ifdef __LITTLE_ENDIAN stuff from __qrwlock.
>> codes above obviously will break. And we already have such code.
>
> I was wondering more along the lines of having one definition of the data
> structure, but then defining _QW_* differently depending on endianness
> (i.e. add a << 24 when big-endian). That way queued_write_unlock can
make sense. And I review all the code, there is not much code to be changed.
I will work out one patch based on your idea :)

> stay like it is (having an arch override to handle the big-endian case
> is incredibly ugly).
>
I admit that. HOWEVER from the view of performance, having an arch override is acceptable.

thanks
xinhui
> Will
>

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web