DPDK-dev Archive on lore.kernel.org
 help / color / Atom feed
From: "Gavin Hu (Arm Technology China)" <Gavin.Hu@arm.com>
To: Jerin Jacob <jerinjacobk@gmail.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>, nd <nd@arm.com>,
	"thomas@monjalon.net" <thomas@monjalon.net>,
	"stephen@networkplumber.org" <stephen@networkplumber.org>,
	"hemant.agrawal@nxp.com" <hemant.agrawal@nxp.com>,
	"jerinj@marvell.com" <jerinj@marvell.com>,
	Pavan Nikhilesh <pbhagavatula@marvell.com>,
	Honnappa Nagarahalli <Honnappa.Nagarahalli@arm.com>
Subject: Re: [dpdk-dev] [PATCH v5 3/8] eal: add the APIs to wait until equal
Date: Fri, 13 Sep 2019 17:05:13 +0000
Message-ID: <VI1PR08MB5376E498ED0EDFFD98C19BA58FB30@VI1PR08MB5376.eurprd08.prod.outlook.com> (raw)
In-Reply-To: <CALBAE1Mm-RUN3mfZW8HDavAq3LdgfXVDrXNR3kSJ=pbm8V5fWw@mail.gmail.com>

Hi Jerin,

> -----Original Message-----
> From: Jerin Jacob <jerinjacobk@gmail.com>
> Sent: Friday, September 13, 2019 12:12 AM
> To: Gavin Hu (Arm Technology China) <Gavin.Hu@arm.com>
> Cc: dev@dpdk.org; nd <nd@arm.com>; thomas@monjalon.net;
> stephen@networkplumber.org; hemant.agrawal@nxp.com;
> jerinj@marvell.com; Pavan Nikhilesh <pbhagavatula@marvell.com>;
> Honnappa Nagarahalli <Honnappa.Nagarahalli@arm.com>
> Subject: Re: [dpdk-dev] [PATCH v5 3/8] eal: add the APIs to wait until equal
> 
> On Thu, Sep 12, 2019 at 4:56 PM Gavin Hu <gavin.hu@arm.com> wrote:
> >
> > The rte_wait_until_equalxx APIs abstract the functionality of 'polling
> > for a memory location to become equal to a given value'.
> >
> > Signed-off-by: Gavin Hu <gavin.hu@arm.com>
> > Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
> > Reviewed-by: Steve Capper <steve.capper@arm.com>
> > Reviewed-by: Ola Liljedahl <ola.liljedahl@arm.com>
> > Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
> > Reviewed-by: Phil Yang <phil.yang@arm.com>
> > Acked-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
> > ---
> >  .../common/include/arch/arm/rte_pause_64.h         | 30 +++++++
> >  lib/librte_eal/common/include/generic/rte_pause.h  | 98
> +++++++++++++++++++++-
> >  2 files changed, 127 insertions(+), 1 deletion(-)
> >
> > diff --git a/lib/librte_eal/common/include/arch/arm/rte_pause_64.h
> b/lib/librte_eal/common/include/arch/arm/rte_pause_64.h
> > index 93895d3..dabde17 100644
> > --- a/lib/librte_eal/common/include/arch/arm/rte_pause_64.h
> > +++ b/lib/librte_eal/common/include/arch/arm/rte_pause_64.h
> > @@ -1,5 +1,6 @@
> >  /* SPDX-License-Identifier: BSD-3-Clause
> >   * Copyright(c) 2017 Cavium, Inc
> > + * Copyright(c) 2019 Arm Limited
> >   */
> >
> >  #ifndef _RTE_PAUSE_ARM64_H_
> > @@ -17,6 +18,35 @@ static inline void rte_pause(void)
> >         asm volatile("yield" ::: "memory");
> >  }
> >
> > +#ifdef RTE_ARM_USE_WFE
> > +#define __WAIT_UNTIL_EQUAL(name, asm_op, wide, type) \
> > +static __rte_always_inline void \
> > +rte_wait_until_equal_##name(volatile type * addr, type expected) \
> > +{ \
> > +       type tmp; \
> > +       asm volatile( \
> > +               #asm_op " %" #wide "[tmp], %[addr]\n" \
> > +               "cmp    %" #wide "[tmp], %" #wide "[expected]\n" \
> > +               "b.eq   2f\n" \
> > +               "sevl\n" \
> > +               "1:     wfe\n" \
> > +               #asm_op " %" #wide "[tmp], %[addr]\n" \
> > +               "cmp    %" #wide "[tmp], %" #wide "[expected]\n" \
> > +               "bne    1b\n" \
> > +               "2:\n" \
> > +               : [tmp] "=&r" (tmp) \
> > +               : [addr] "Q"(*addr), [expected] "r"(expected) \
> > +               : "cc", "memory"); \
> > +}
> > +/* Wait for *addr to be updated with expected value */
> > +__WAIT_UNTIL_EQUAL(relaxed_16, ldxrh, w, uint16_t)
> > +__WAIT_UNTIL_EQUAL(acquire_16, ldaxrh, w, uint16_t)
> > +__WAIT_UNTIL_EQUAL(relaxed_32, ldxr, w, uint32_t)
> > +__WAIT_UNTIL_EQUAL(acquire_32, ldaxr, w, uint32_t)
> > +__WAIT_UNTIL_EQUAL(relaxed_64, ldxr, x, uint64_t)
> > +__WAIT_UNTIL_EQUAL(acquire_64, ldaxr, x, uint64_t)
> > +#endif
> 
> Looks good.
> 
> > +
> >  #ifdef __cplusplus
> >  }
> >  #endif
> > diff --git a/lib/librte_eal/common/include/generic/rte_pause.h
> b/lib/librte_eal/common/include/generic/rte_pause.h
> > index 52bd4db..dfa6a53 100644
> > --- a/lib/librte_eal/common/include/generic/rte_pause.h
> > +++ b/lib/librte_eal/common/include/generic/rte_pause.h
> > @@ -1,10 +1,10 @@
> >  /* SPDX-License-Identifier: BSD-3-Clause
> >   * Copyright(c) 2017 Cavium, Inc
> > + * Copyright(c) 2019 Arm Limited
> >   */
> >
> >  #ifndef _RTE_PAUSE_H_
> >  #define _RTE_PAUSE_H_
> > -
> 
> Unwanted change.
Will fix it.
> 
> >  /**
> >   * @file
> >   *
> > @@ -12,6 +12,10 @@
> >   *
> >   */
> >
> > +#include <stdint.h>
> > +#include <rte_common.h>
> > +#include <rte_atomic.h>
> > +
> >  /**
> >   * Pause CPU execution for a short while
> >   *
> > @@ -20,4 +24,96 @@
> >   */
> >  static inline void rte_pause(void);
> >
> > +/**
> > + * Wait for *addr to be updated with expected value
> 
> IMO, We need to mention relaxed attribute also in the comment.
Will fix it.
> 
> > + *
> > + * @param addr
> > + *  A pointer to the memory location.
> > + * @param expected
> > + *  An expected value to be in the memory location.
> > + */
> > +__rte_always_inline
> > +static void
> > +rte_wait_until_equal_relaxed_16(volatile uint16_t *addr, uint16_t
> expected);
> 
> > +
> > +/**
> > + * Wait for *addr to be updated with expected value
> > + *
> > + * @param addr
> > + *  A pointer to the memory location.
> > + * @param expected
> > + *  An expected value to be in the memory location.
> > + */
> > +__rte_always_inline
> > +static void
> > +rte_wait_until_equal_acquire_64(volatile uint64_t *addr, uint64_t
> expected);
> > +
> > +#if !defined(RTE_ARM_USE_WFE)
> 
> Looks like there is a side effect as meson's build/rte_build_config.h
> comes as below
> #define RTE_ARM_USE_WFE 0
> 
> So actually it is defined.
Good catch, thanks, will fix it.
> 
> > +#define __WAIT_UNTIL_EQUAL(op_name, size, type, memorder) \
> > +__rte_always_inline \
> > +static void    \
> > +rte_wait_until_equal_##op_name##_##size(volatile type *addr, \
> > +       type expected) \
> > +{ \
> > +       while (__atomic_load_n(addr, memorder) != expected) \
> > +               rte_pause(); \
> > +}
> > +
> > +/* Wait for *addr to be updated with expected value */
> > +__WAIT_UNTIL_EQUAL(relaxed, 16, uint16_t, __ATOMIC_RELAXED)
> > +__WAIT_UNTIL_EQUAL(acquire, 16, uint16_t, __ATOMIC_ACQUIRE)
> > +__WAIT_UNTIL_EQUAL(relaxed, 32, uint32_t, __ATOMIC_RELAXED)
> > +__WAIT_UNTIL_EQUAL(acquire, 32, uint32_t, __ATOMIC_ACQUIRE)
> > +__WAIT_UNTIL_EQUAL(relaxed, 64, uint64_t, __ATOMIC_RELAXED)
> > +__WAIT_UNTIL_EQUAL(acquire, 64, uint64_t, __ATOMIC_ACQUIRE)
> > +#endif /* RTE_ARM_USE_WFE */
> > +
> >  #endif /* _RTE_PAUSE_H_ */
> > --
> > 2.7.4
> >

  reply index

Thread overview: 76+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-30 16:21 [dpdk-dev] [RFC 0/5] use WFE for locks and ring on aarch64 Gavin Hu
2019-06-30 16:21 ` [dpdk-dev] [RFC 1/5] eal: add the APIs to wait until equal Gavin Hu
2019-06-30 20:27   ` Stephen Hemminger
2019-07-01  7:16     ` Gavin Hu (Arm Technology China)
2019-07-01  7:43       ` Thomas Monjalon
2019-07-02 14:07         ` Gavin Hu (Arm Technology China)
2019-07-01  9:58   ` Pavan Nikhilesh Bhagavatula
2019-07-02 14:08     ` Gavin Hu (Arm Technology China)
2019-06-30 16:21 ` [dpdk-dev] [RFC 2/5] ticketlock: use new API to reduce contention on aarch64 Gavin Hu
2019-06-30 16:21 ` [dpdk-dev] [RFC 3/5] ring: use wfe to wait for ring tail update " Gavin Hu
2019-06-30 16:21 ` [dpdk-dev] [RFC 4/5] spinlock: use wfe to reduce contention " Gavin Hu
2019-06-30 16:21 ` [dpdk-dev] [RFC 5/5] config: add WFE config entry for aarch64 Gavin Hu
2019-06-30 20:29 ` [dpdk-dev] [RFC 0/5] use WFE for locks and ring on aarch64 Stephen Hemminger
2019-07-01  9:12   ` Gavin Hu (Arm Technology China)
2019-07-03  8:58 ` [dpdk-dev] [RFC v2 " Gavin Hu
2019-07-03  8:58 ` [dpdk-dev] [RFC v2 1/5] eal: add the APIs to wait until equal Gavin Hu
2019-07-20  6:46   ` [dpdk-dev] [EXT] " Pavan Nikhilesh Bhagavatula
2019-07-03  8:58 ` [dpdk-dev] [RFC v2 2/5] ticketlock: use new API to reduce contention on aarch64 Gavin Hu
2019-07-20  6:57   ` Pavan Nikhilesh Bhagavatula
2019-07-03  8:58 ` [dpdk-dev] [RFC v2 3/5] ring: use wfe to wait for ring tail update " Gavin Hu
2019-07-03  8:58 ` [dpdk-dev] [RFC v2 4/5] spinlock: use wfe to reduce contention " Gavin Hu
2019-07-20  6:59   ` Pavan Nikhilesh Bhagavatula
2019-07-03  8:58 ` [dpdk-dev] [RFC v2 5/5] config: add WFE config entry for aarch64 Gavin Hu
2019-07-20  7:03   ` Pavan Nikhilesh Bhagavatula
2019-07-23 15:47     ` Gavin Hu (Arm Technology China)
2019-07-23 15:43 ` [dpdk-dev] [PATCH v3 0/5] use WFE for locks and ring on aarch64 Gavin Hu
2019-07-23 19:15   ` Honnappa Nagarahalli
2019-07-23 21:27     ` Thomas Monjalon
2019-07-24  2:44       ` Honnappa Nagarahalli
2019-07-24  7:43         ` Thomas Monjalon
2019-07-23 15:43 ` [dpdk-dev] [PATCH v3 1/5] eal: add the APIs to wait until equal Gavin Hu
2019-07-24 11:52   ` [dpdk-dev] [EXT] " Jerin Jacob Kollanukkaran
2019-07-24 18:10     ` Gavin Hu (Arm Technology China)
2019-07-23 15:43 ` [dpdk-dev] [PATCH v3 2/5] ticketlock: use new API to reduce contention on aarch64 Gavin Hu
2019-07-23 15:43 ` [dpdk-dev] [PATCH v3 3/5] ring: use wfe to wait for ring tail update " Gavin Hu
2019-07-23 15:43 ` [dpdk-dev] [PATCH v3 4/5] spinlock: use wfe to reduce contention " Gavin Hu
2019-07-24 12:17   ` [dpdk-dev] [EXT] " Jerin Jacob Kollanukkaran
2019-07-23 15:43 ` [dpdk-dev] [PATCH v3 5/5] config: add WFE config entry for aarch64 Gavin Hu
2019-07-23 18:05   ` Stephen Hemminger
2019-07-23 19:10     ` Honnappa Nagarahalli
2019-07-24 17:59       ` Gavin Hu (Arm Technology China)
2019-07-24 12:25   ` [dpdk-dev] [EXT] " Jerin Jacob Kollanukkaran
2019-08-22  6:12 ` [dpdk-dev] [PATCH v4 0/6] use WFE for locks and ring on aarch64 Gavin Hu
2019-08-22  6:12 ` [dpdk-dev] [PATCH v4 1/6] bus/fslmc: fix the conflicting dmb function Gavin Hu
2019-08-22  6:12 ` [dpdk-dev] [PATCH v4 2/6] eal: add the APIs to wait until equal Gavin Hu
2019-09-11 12:26   ` Jerin Jacob
2019-09-12  8:25     ` Gavin Hu (Arm Technology China)
2019-08-22  6:12 ` [dpdk-dev] [PATCH v4 3/6] ticketlock: use new API to reduce contention on aarch64 Gavin Hu
2019-08-22  6:12 ` [dpdk-dev] [PATCH v4 4/6] ring: use wfe to wait for ring tail update " Gavin Hu
2019-08-22  6:12 ` [dpdk-dev] [PATCH v4 5/6] spinlock: use wfe to reduce contention " Gavin Hu
     [not found]   ` <CY4PR1801MB1863AF9695BB10930E817D78DEB00@CY4PR1801MB1863.namprd18.prod.outlook.com>
     [not found]     ` <VI1PR08MB5376BEBCC1FD1E03F0B8A8848FB00@VI1PR08MB5376.eurprd08.prod.outlook.com>
2019-09-14 15:21       ` [dpdk-dev] [EXT] " Gavin Hu (Arm Technology China)
2019-08-22  6:12 ` [dpdk-dev] [PATCH v4 6/6] config: add WFE config entry for aarch64 Gavin Hu
2019-09-12 11:24 ` [dpdk-dev] [PATCH v5 0/8] use WFE " Gavin Hu
2019-09-12 11:24 ` [dpdk-dev] [PATCH v5 1/8] config: add WFE config entry " Gavin Hu
2019-09-12 15:48   ` Jerin Jacob
2019-09-13 16:01     ` Gavin Hu (Arm Technology China)
2019-09-12 11:24 ` [dpdk-dev] [PATCH v5 2/8] bus/fslmc: fix the conflicting dmb function Gavin Hu
2019-09-12 11:24 ` [dpdk-dev] [PATCH v5 3/8] eal: add the APIs to wait until equal Gavin Hu
2019-09-12 16:11   ` Jerin Jacob
2019-09-13 17:05     ` Gavin Hu (Arm Technology China) [this message]
2019-09-12 11:24 ` [dpdk-dev] [PATCH v5 4/8] spinlock: use wfe to reduce contention on aarch64 Gavin Hu
2019-09-12 11:24 ` [dpdk-dev] [PATCH v5 5/8] ticketlock: use new API " Gavin Hu
2019-09-12 16:14   ` Jerin Jacob
2019-09-12 11:24 ` [dpdk-dev] [PATCH v5 6/8] ring: use wfe to wait for ring tail update " Gavin Hu
2019-09-12 11:24 ` [dpdk-dev] [PATCH v5 7/8] net/thunderx: use new API to save cycles " Gavin Hu
2019-09-12 16:15   ` Jerin Jacob
2019-09-12 11:24 ` [dpdk-dev] [PATCH v5 8/8] event/opdl: " Gavin Hu
2019-09-12 16:16   ` Jerin Jacob
2019-09-14 14:59 ` [dpdk-dev] [PATCH v6 0/7] use WFE for aarch64 Gavin Hu
2019-09-14 14:59 ` [dpdk-dev] [PATCH v6 1/7] bus/fslmc: fix the conflicting dmb function Gavin Hu
2019-09-14 14:59 ` [dpdk-dev] [PATCH v6 2/7] eal: add the APIs to wait until equal Gavin Hu
2019-09-14 14:59 ` [dpdk-dev] [PATCH v6 3/7] spinlock: use wfe to reduce contention on aarch64 Gavin Hu
2019-09-14 14:59 ` [dpdk-dev] [PATCH v6 4/7] ticketlock: use new API " Gavin Hu
2019-09-14 14:59 ` [dpdk-dev] [PATCH v6 5/7] ring: use wfe to wait for ring tail update " Gavin Hu
2019-09-14 14:59 ` [dpdk-dev] [PATCH v6 6/7] net/thunderx: use new API to save cycles " Gavin Hu
2019-09-14 14:59 ` [dpdk-dev] [PATCH v6 7/7] event/opdl: " Gavin Hu

Reply instructions:

You may reply publically 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=VI1PR08MB5376E498ED0EDFFD98C19BA58FB30@VI1PR08MB5376.eurprd08.prod.outlook.com \
    --to=gavin.hu@arm.com \
    --cc=Honnappa.Nagarahalli@arm.com \
    --cc=dev@dpdk.org \
    --cc=hemant.agrawal@nxp.com \
    --cc=jerinj@marvell.com \
    --cc=jerinjacobk@gmail.com \
    --cc=nd@arm.com \
    --cc=pbhagavatula@marvell.com \
    --cc=stephen@networkplumber.org \
    --cc=thomas@monjalon.net \
    /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

DPDK-dev Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/dpdk-dev/0 dpdk-dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dpdk-dev dpdk-dev/ https://lore.kernel.org/dpdk-dev \
		dev@dpdk.org dpdk-dev@archiver.kernel.org
	public-inbox-index dpdk-dev


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/ public-inbox