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


Groups > linux.kernel > #1386202

Re: [PATCH V3] powerpc: Implement {cmp}xchg for u8 and u16

From Pan Xinhui <xinhui@linux.vnet.ibm.com>
Newsgroups linux.kernel
Subject Re: [PATCH V3] powerpc: Implement {cmp}xchg for u8 and u16
Date 2016-04-25 12:20 +0200
Message-ID <rrLMu-406-1@gated-at.bofh.it> (permalink)
References <rpxui-2ov-3@gated-at.bofh.it> <rq0mC-5D-11@gated-at.bofh.it> <rq1iH-Pz-23@gated-at.bofh.it> <rqp1F-316-33@gated-at.bofh.it> <rqpuH-3tV-25@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 2016年04月22日 00:13, Peter Zijlstra wrote:
> On Thu, Apr 21, 2016 at 11:35:07PM +0800, Pan Xinhui wrote:
>> yes, you are right. more load/store will be done in C code.
>> However such xchg_u8/u16 is just used by qspinlock now. and I did not see any performance regression.
>> So just wrote in C, for simple. :)
> 
> Which is fine; but worthy of a note in your Changelog.
> 
will do that.

>> Of course I have done xchg tests.
>> we run code just like xchg((u8*)&v, j++); in several threads.
>> and the result is,
>> [  768.374264] use time[1550072]ns in xchg_u8_asm
>> [  768.377102] use time[2826802]ns in xchg_u8_c
>>
>> I think this is because there is one more load in C.
>> If possible, we can move such code in asm-generic/.
> 
> So I'm not actually _that_ familiar with the PPC LL/SC implementation;
> but there are things a CPU can do to optimize these loops.
> 
> For example, a CPU might choose to not release the exclusive hold of the
> line for a number of cycles, except when it passes SC or an interrupt
> happens. This way there's a smaller chance the SC fails and inhibits
> forward progress.
I am not sure if there is such hardware optimization.

> 
> By doing the modification outside of the LL/SC you loose such
> advantages.
> 
> And yes, doing a !exclusive load prior to the exclusive load leads to an
> even bigger window where the data can get changed out from under you.
> 
you are right.
We have observed such data change during the two different loads.

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH V2] powerpc: Implement {cmp}xchg for u8 and u16 Pan Xinhui <xinhui@linux.vnet.ibm.com> - 2016-04-19 08:40 +0200
  Re: [PATCH V2] powerpc: Implement {cmp}xchg for u8 and u16 Boqun Feng <boqun.feng@gmail.com> - 2016-04-19 11:20 +0200
    Re: [PATCH V2] powerpc: Implement {cmp}xchg for u8 and u16 Pan Xinhui <xinhui@linux.vnet.ibm.com> - 2016-04-20 05:50 +0200
  [PATCH V3] powerpc: Implement {cmp}xchg for u8 and u16 Pan Xinhui <xinhui@linux.vnet.ibm.com> - 2016-04-20 15:30 +0200
    Re: [PATCH V3] powerpc: Implement {cmp}xchg for u8 and u16 Peter Zijlstra <peterz@infradead.org> - 2016-04-20 16:30 +0200
      Re: [PATCH V3] powerpc: Implement {cmp}xchg for u8 and u16 Boqun Feng <boqun.feng@gmail.com> - 2016-04-21 17:50 +0200
        Re: [PATCH V3] powerpc: Implement {cmp}xchg for u8 and u16 Pan Xinhui <xinhui@linux.vnet.ibm.com> - 2016-04-22 04:10 +0200
          Re: [PATCH V3] powerpc: Implement {cmp}xchg for u8 and u16 Boqun Feng <boqun.feng@gmail.com> - 2016-04-22 05:20 +0200
      Re: [PATCH V3] powerpc: Implement {cmp}xchg for u8 and u16 Pan Xinhui <xinhui@linux.vnet.ibm.com> - 2016-04-21 18:10 +0200
        Re: [PATCH V3] powerpc: Implement {cmp}xchg for u8 and u16 Peter Zijlstra <peterz@infradead.org> - 2016-04-21 18:20 +0200
          Re: [PATCH V3] powerpc: Implement {cmp}xchg for u8 and u16 Pan Xinhui <xinhui@linux.vnet.ibm.com> - 2016-04-25 12:20 +0200
            Re: [PATCH V3] powerpc: Implement {cmp}xchg for u8 and u16 Peter Zijlstra <peterz@infradead.org> - 2016-04-25 17:40 +0200
              Re: [PATCH V3] powerpc: Implement {cmp}xchg for u8 and u16 Pan Xinhui <xinhui@linux.vnet.ibm.com> - 2016-04-26 13:40 +0200
    [PATCH V4] powerpc: Implement {cmp}xchg for u8 and u16 Pan Xinhui <xinhui@linux.vnet.ibm.com> - 2016-04-27 11:20 +0200
      Re: [PATCH V4] powerpc: Implement {cmp}xchg for u8 and u16 Boqun Feng <boqun.feng@gmail.com> - 2016-04-27 16:00 +0200
        Re: [PATCH V4] powerpc: Implement {cmp}xchg for u8 and u16 Boqun Feng <boqun.feng@gmail.com> - 2016-04-27 16:20 +0200
        Re: [PATCH V4] powerpc: Implement {cmp}xchg for u8 and u16 Boqun Feng <boqun.feng@gmail.com> - 2016-04-27 16:50 +0200
          Re: [PATCH V4] powerpc: Implement {cmp}xchg for u8 and u16 Boqun Feng <boqun.feng@gmail.com> - 2016-04-27 17:00 +0200
            Re: [PATCH V4] powerpc: Implement {cmp}xchg for u8 and u16 Pan Xinhui <xinhui@linux.vnet.ibm.com> - 2016-04-28 12:30 +0200
      Re: [PATCH V4] powerpc: Implement {cmp}xchg for u8 and u16 Peter Zijlstra <peterz@infradead.org> - 2016-04-28 10:00 +0200

csiph-web