From mboxrd@z Thu Jan 1 00:00:00 1970 From: Honnappa Nagarahalli Subject: Re: [PATCH v2 2/3] test/distributor: replace sync builtins with atomic builtins Date: Mon, 1 Apr 2019 16:24:01 +0000 Message-ID: References: <1546508946-12552-1-git-send-email-phil.yang@arm.com> <1553856998-25394-3-git-send-email-phil.yang@arm.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Cc: "david.hunt@intel.com" , "reshma.pattan@intel.com" , "Gavin Hu (Arm Technology China)" , "Phil Yang (Arm Technology China)" , nd , Honnappa Nagarahalli , nd To: "Phil Yang (Arm Technology China)" , "dev@dpdk.org" , "thomas@monjalon.net" Return-path: Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-eopbgr140048.outbound.protection.outlook.com [40.107.14.48]) by dpdk.org (Postfix) with ESMTP id 79A74548B for ; Mon, 1 Apr 2019 18:24:03 +0200 (CEST) In-Reply-To: <1553856998-25394-3-git-send-email-phil.yang@arm.com> Content-Language: en-US List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" >=20 > diff --git a/app/test/test_distributor.c b/app/test/test_distributor.c in= dex > 98919ec..ddab08d 100644 > --- a/app/test/test_distributor.c > +++ b/app/test/test_distributor.c > @@ -62,9 +62,14 @@ handle_work(void *arg) > struct worker_params *wp =3D arg; > struct rte_distributor *db =3D wp->dist; > unsigned int count =3D 0, num =3D 0; > - unsigned int id =3D __sync_fetch_and_add(&worker_idx, 1); > int i; >=20 > +#ifdef RTE_USE_C11_MEM_MODEL > + unsigned int id =3D __atomic_fetch_add(&worker_idx, 1, > +__ATOMIC_RELAXED); #else > + unsigned int id =3D __sync_fetch_and_add(&worker_idx, 1); #endif > + I suggest we remove the conditional compilation and just keep the __atomic_= xxx calls as this is test code. More over the distributor library does not = have a C11 version of the library (assuming that using __atomic_xxx does no= t impact performance on other platforms negatively). This applies to other = instances in this patch. > for (i =3D 0; i < 8; i++) > buf[i] =3D NULL; > num =3D rte_distributor_get_pkt(db, id, buf, buf, num); @@ -270,7 > +275,12 @@ handle_work_with_free_mbufs(void *arg) > unsigned int count =3D 0; > unsigned int i; > unsigned int num =3D 0; > + > +#ifdef RTE_USE_C11_MEM_MODEL > + unsigned int id =3D __atomic_fetch_add(&worker_idx, 1, > +__ATOMIC_RELAXED); #else > unsigned int id =3D __sync_fetch_and_add(&worker_idx, 1); > +#endif >=20 > for (i =3D 0; i < 8; i++) > buf[i] =3D NULL; > @@ -343,7 +353,13 @@ handle_work_for_shutdown_test(void *arg) > unsigned int total =3D 0; > unsigned int i; > unsigned int returned =3D 0; > + > +#ifdef RTE_USE_C11_MEM_MODEL > + const unsigned int id =3D __atomic_fetch_add(&worker_idx, 1, > + __ATOMIC_RELAXED); > +#else > const unsigned int id =3D __sync_fetch_and_add(&worker_idx, 1); > +#endif >=20 > num =3D rte_distributor_get_pkt(d, id, buf, buf, num); >=20 > diff --git a/app/test/test_distributor_perf.c b/app/test/test_distributor= _perf.c > index edf1998..9367460 100644 > --- a/app/test/test_distributor_perf.c > +++ b/app/test/test_distributor_perf.c > @@ -111,9 +111,14 @@ handle_work(void *arg) > unsigned int count =3D 0; > unsigned int num =3D 0; > int i; > - unsigned int id =3D __sync_fetch_and_add(&worker_idx, 1); > struct rte_mbuf *buf[8] __rte_cache_aligned; >=20 > +#ifdef RTE_USE_C11_MEM_MODEL > + unsigned int id =3D __atomic_fetch_add(&worker_idx, 1, > +__ATOMIC_RELAXED); #else > + unsigned int id =3D __sync_fetch_and_add(&worker_idx, 1); #endif > + > for (i =3D 0; i < 8; i++) > buf[i] =3D NULL; >=20 > -- > 2.7.4