[dpdk-dev] [PATCH v8 01/15] eal: introduce atomic exchange operation
Bruce Richardson
bruce.richardson at intel.com
Mon Jan 29 10:51:44 CET 2018
On Fri, Jan 26, 2018 at 01:54:23PM -0800, Stephen Hemminger wrote:
> On Fri, 26 Jan 2018 17:24:40 +0000
> Bruce Richardson <bruce.richardson at intel.com> wrote:
>
> > On Fri, Jan 26, 2018 at 06:14:01PM +0100, Thomas Monjalon wrote:
> > > 26/01/2018 03:01, Stephen Hemminger:
> > > > To handle atomic update of link status (64 bit), every driver was
> > > > doing its own version using cmpset. Atomic exchange is a useful
> > > > primitive in its own right; therefore make it a EAL routine.
> > > >
> > > > Signed-off-by: Stephen Hemminger <stephen at networkplumber.org> ---
> > > > .../common/include/arch/ppc_64/rte_atomic.h | 21 +++++-
> > > > .../common/include/arch/x86/rte_atomic.h | 24 +++++++
> > > > .../common/include/arch/x86/rte_atomic_32.h | 12 ++++
> > > > .../common/include/arch/x86/rte_atomic_64.h | 12 ++++
> > > > lib/librte_eal/common/include/generic/rte_atomic.h | 78
> > > > ++++++++++++++++++++++ 5 files changed, 146 insertions(+), 1
> > > > deletion(-)
> > >
> > > Looks good, thanks.
> > >
> > > It probably deserves a review by PPC experts. Adding Chao, maintainer
> > > of this part. + Bruce and Konstantin for x86 part.
> > >
> > Would it not be simpler to use __sync_bool_compare_and_swap compiler
> > built-in on all supported platforms? Do we really need the per-platform
> > optimization of this?
> >
> > /Bruce
>
> Exchange is different than compare and swap. The is nice atomic intrinsic
> in GCC. The x86 part is in Linux and BSD already.
Yes, sorry, I picked the wrong builtin. I should have referenced
instead "__sync_lock_test_and_set", which is an xchg op according to the
docs [https://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Atomic-Builtins.html].
More information about the dev
mailing list