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


Groups > linux.kernel > #1376860

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

From Peter Zijlstra <peterz@infradead.org>
Newsgroups linux.kernel
Subject Re: [PATCH] powerpc: introduce {cmp}xchg for u8 and u16
Date 2016-04-12 16:40 +0200
Message-ID <rn7DY-p6-23@gated-at.bofh.it> (permalink)
References <rlyoW-8fi-9@gated-at.bofh.it> <rlzl0-rS-13@gated-at.bofh.it> <rmonw-6i9-9@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Sun, Apr 10, 2016 at 10:17:28PM +0800, Pan Xinhui wrote:
> 
> On 2016年04月08日 15:47, Peter Zijlstra wrote:
> > On Fri, Apr 08, 2016 at 02:41:46PM +0800, Pan Xinhui wrote:
> >> From: pan xinhui <xinhui.pan@linux.vnet.ibm.com>
> >>
> >> Implement xchg{u8,u16}{local,relaxed}, and
> >> cmpxchg{u8,u16}{,local,acquire,relaxed}.
> >>
> >> Atomic operation on 8-bit and 16-bit data type is supported from power7
> > 
> > And yes I see nothing P7 specific here, this implementation is for
> > everything PPC64 afaict, no?
> > 
> Hello Peter,
> 	No, it's not for every ppc. So yes, I need add #ifdef here. Thanks for pointing it out.
> We might need a new config option and let it depend on POWER7/POWER8_CPU or even POWER9...

Right, I'm not sure if PPC has alternatives, but you could of course
runtime patch the code from emulated with 32bit ll/sc to native 8/16bit
ll/sc if present on the current CPU if you have infrastructure for these
things.

> > Also, note that you don't need explicit 8/16 bit atomics to implement
> > these. Its fine to use 32bit atomics and only modify half the word.
> > 
> That is true. But I am a little worried about the performance. It will
> forbid any other tasks to touch the other half word during the
> load/reserve, right?

Well, not forbid, it would just make the LL/SC fail and try again. Other
archs already implement them this way. See commit 3226aad81aa6 ("sh:
support 1 and 2 byte xchg") for example.

> I am working on the qspinlock implementation on PPC.
> Your and Waiman's patches are so nice. :)

Thanks!, last time I looked at PPC spinlocks they could not use things
like ticket locks because PPC might be a guest and fairness blows etc..

You're making the qspinlock-paravirt thing work on PPC, or doing
qspinlock only for bare-metal PPC?

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


Thread

[PATCH] powerpc: introduce {cmp}xchg for u8 and u16 Pan Xinhui <xinhui@linux.vnet.ibm.com> - 2016-04-08 08:50 +0200
  Re: [PATCH] powerpc: introduce {cmp}xchg for u8 and u16 Peter Zijlstra <peterz@infradead.org> - 2016-04-08 09:50 +0200
    Re: [PATCH] powerpc: introduce {cmp}xchg for u8 and u16 Pan Xinhui <xinhui@linux.vnet.ibm.com> - 2016-04-10 16:20 +0200
      Re: [PATCH] powerpc: introduce {cmp}xchg for u8 and u16 Peter Zijlstra <peterz@infradead.org> - 2016-04-12 16:40 +0200
        Re: [PATCH] powerpc: introduce {cmp}xchg for u8 and u16 Pan Xinhui <xinhui@linux.vnet.ibm.com> - 2016-04-13 13:20 +0200
          Re: [PATCH] powerpc: introduce {cmp}xchg for u8 and u16 Waiman Long <waiman.long@hpe.com> - 2016-04-13 18:00 +0200
            Re: [PATCH] powerpc: introduce {cmp}xchg for u8 and u16 Pan Xinhui <xinhui@linux.vnet.ibm.com> - 2016-04-14 10:40 +0200

csiph-web