All of lore.kernel.org
 help / color / mirror / Atom feed
From: xinhui <xinhui.pan@linux.vnet.ibm.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org,
	mingo@redhat.com, arnd@arndb.de, Waiman.Long@hpe.com
Subject: Re: [PATCH v3] locking/qrwlock: Let qrwlock has same layout regardless of the endian
Date: Thu, 14 Jul 2016 15:44:42 +0800	[thread overview]
Message-ID: <578742EA.7060108@linux.vnet.ibm.com> (raw)
In-Reply-To: <20160713195423.GD30921@twins.programming.kicks-ass.net>



On 2016年07月14日 03:54, Peter Zijlstra wrote:
> On Mon, Jun 20, 2016 at 02:20:52PM +0800, Pan Xinhui wrote:
>> This patch aims to get rid of endianness in queued_write_unlock(). We
>> want to set  __qrwlock->wmode to NULL, however the address is not
>> &lock->cnts in big endian machine. That causes queued_write_unlock()
>> write NULL to the wrong field of __qrwlock.
>>
>> Actually qrwlock can have same layout, IOW we can remove the #if
>> __little_endian in struct __qrwlock. With such modification, we only
>> need define some _QW* and _QR* with corresponding values in different
>> endian systems.
>>
>> Suggested-by: Will Deacon <will.deacon@arm.com>
>> Signed-off-by: Pan Xinhui <xinhui.pan@linux.vnet.ibm.com>
>> Acked-by: Waiman Long <Waiman.Long@hpe.com>
>> ---
>
> Urgh, I hate this stuff :/
>
> OK, so I poked at this a bit and I ended up with the below; but now
> qrwlock and qspinlock are inconsistent; although I suspect qspinlock is
> similarly busted wrt endian muck.
>
> Not sure what to do..
>
Lets talk about the qspinlock.

for x86, We has already assumed that ->locked sit at the low 8 bits, as is
smp_store_release((u8 *)lock, 0);

Then we can do a favor, export ->locked but other fields as reserved.
say

struct __qspinlock_unlcok_interface {/* what name is better?*/
#ifdef __LITTLE_ENDIAN
		u8      locked;
		u8      reserved[3]; /* do not touch it, internally use only  */
#else
		u8      reserved[3];
		u8      locked;
#endif
};

I think it is acceptable. and we can do similar things with qrwlock, too.

any thoughts?


>   /*
> - * Writer states & reader shift and bias
> + * Writer states & reader shift and bias.
> + *
> + *       | +0 | +1 | +2 | +3 |
> + *   ----+----+----+----+----+
> + *    LE | 12 | 34 | 56 | 78 | 0x12345678
> + *   ----+----+----+----+----+
> + *    BE | 78 | 56 | 34 | 12 | 0x12345678
> + *   ----+----+----+----+----+
> + *       | wr |      rd      |
> + *       +----+----+----+----+
> + *
>    */

very clearly. :)

thanks
xinhui

  parent reply	other threads:[~2016-07-14  7:45 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-20  6:20 [PATCH v3] locking/qrwlock: Let qrwlock has same layout regardless of the endian Pan Xinhui
2016-07-13 19:54 ` Peter Zijlstra
2016-07-13 20:40   ` Peter Zijlstra
2016-07-14  1:54   ` Waiman Long
2016-07-14  1:54     ` Waiman Long
2016-07-14  7:44   ` xinhui [this message]
2016-07-14  9:37     ` Peter Zijlstra
2016-07-14  9:46       ` Peter Zijlstra
2016-07-15  0:41         ` Boqun Feng
2016-07-15  6:28       ` panxinhui

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=578742EA.7060108@linux.vnet.ibm.com \
    --to=xinhui.pan@linux.vnet.ibm.com \
    --cc=Waiman.Long@hpe.com \
    --cc=arnd@arndb.de \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.