From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50088.outbound.protection.outlook.com [40.107.5.88]) by dpdk.org (Postfix) with ESMTP id 8DE9B1B123; Wed, 26 Sep 2018 11:30:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector1-arm-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=geOUkK+dM2h33h03b1gPMZunoWKRkCTyTwZR2HTFVc0=; b=m/42s7Fd3otDRECLXQMhjQNeTKOJwGW+5JJ0Os6SLN9VOy0VzKJgbR0jcchU+QULr/Ilw5X5GBiarZ7e4u/UDtNVaRElbSkL3HZT76x8x4HeyHLde8Rrlj/h0TLWrn7afJ8ndWipdEbuQnLsPFGJZX6tEUGBf2BFVCTNc1+jZFg= Received: from VI1PR08MB3167.eurprd08.prod.outlook.com (52.133.15.142) by VI1PR08MB0608.eurprd08.prod.outlook.com (10.163.169.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1143.18; Wed, 26 Sep 2018 09:29:59 +0000 Received: from VI1PR08MB3167.eurprd08.prod.outlook.com ([fe80::4c13:b1f:ad01:86d7]) by VI1PR08MB3167.eurprd08.prod.outlook.com ([fe80::4c13:b1f:ad01:86d7%4]) with mapi id 15.20.1164.024; Wed, 26 Sep 2018 09:29:59 +0000 From: "Gavin Hu (Arm Technology China)" To: "Gavin Hu (Arm Technology China)" , "dev@dpdk.org" CC: Honnappa Nagarahalli , Steve Capper , Ola Liljedahl , "jerin.jacob@caviumnetworks.com" , nd , "stable@dpdk.org" , Justin He Thread-Topic: [PATCH v3 3/3] ring: move the atomic load of head above the loop Thread-Index: AQHUTl7qxSXFnEIzfUOrA7WYC48RUqUCWifA Date: Wed, 26 Sep 2018 09:29:59 +0000 Message-ID: References: <20180807031943.5331-1-gavin.hu@arm.com> <1537172244-64874-1-git-send-email-gavin.hu@arm.com> <1537172244-64874-3-git-send-email-gavin.hu@arm.com> In-Reply-To: <1537172244-64874-3-git-send-email-gavin.hu@arm.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Gavin.Hu@arm.com; x-originating-ip: [113.29.88.7] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; VI1PR08MB0608; 6:gIOgA36cfhqAdvxHS0HpinjLIpQK5h3HFglBL14z/PtYa+6/ZYW1H2buJPiCIbSgKBEPEa/PFkn4Ov/Wtq2ENnbvKYWbi+xivoo/z9dWF0d+xfdabbQ9Z5T8oHpxpxRalrTKAKnabDuw9wpXb7/wqOR3M+Jtovl/JAwYKa6heVLaLqc6fSvuPxSez+GlwXuOme0xDY0LtkNP2sDUEOorAIQV0M/8GASgsiCawi+JlyR+J/qAoJ1QGJQS0SbsIEdbNU8RnXv2ppM6AKNYWwWuXDqVHfrPz+B8V/2xywo+tGfbiicDPAnHocnpsc/chSuhC8zfmqyz2ca8xHUhA34LzCJ+LOwYoLsSMi7wMxCa6ZUck8+TFezilUF/DX+4Es9bI8K6OxmS82135qdaVpXUXbAgp8dUB+s0oazv6x466iocJ78Q93FrI+t8PtM2lEoF/VUGti5hDbdV9+nSyPrUBA==; 5:k8h6NeY3HECmMXLYPWLv85epYdszdSNQdCoqQOUAjdomT2FuxUUEq2crWE0203GEQ9sZjnKJcD74FR/cr4SKg0ejbgWkfRyx8Z+8BciCqJHgLawXMq0gRWk4jxWvy4F42PU1AFN5uBwxJMRvwitDybXwbQjm1zeIjfMhFc1Vahw=; 7:rpzxhJ4cc64VL/qQt5G+Wh/zo34HiSik/MmZmDk1n4c7EBxacgyPfNMyQhOSQYDxod22AfCx3HXBnphLsjm4leNEmpkiJNqB0AdFA5PkCJ+JkLrufYa66z54DQQBvMQpA5h7tT8K5GESRTe0Mhp5Xvr5zsJW/hx7/tItQhbyeGlsmL8uXBmi+Xb9A6T+BvZr16nWRcYHRhio/jRKzDE4QjUN3TnhRu9HMYSrWAa1CAwznd/keSSt+bLw5WTDfBv4 x-ms-exchange-antispam-srfa-diagnostics: SOS;SOR; x-ms-office365-filtering-correlation-id: f08380ef-1f23-451b-0e3b-08d62392a0fa x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:VI1PR08MB0608; x-ms-traffictypediagnostic: VI1PR08MB0608: nodisclaimer: True x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(180628864354917); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3002001)(3231355)(944501410)(52105095)(93006095)(93001095)(10201501046)(6055026)(149066)(150057)(6041310)(20161123560045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123562045)(201708071742011)(7699051); SRVR:VI1PR08MB0608; BCL:0; PCL:0; RULEID:; SRVR:VI1PR08MB0608; x-forefront-prvs: 08076ABC99 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(376002)(39860400002)(346002)(136003)(396003)(13464003)(199004)(189003)(4326008)(5250100002)(316002)(229853002)(110136005)(6506007)(53546011)(66066001)(6246003)(54906003)(71200400001)(71190400001)(25786009)(11346002)(34290500001)(5660300001)(2906002)(7696005)(33656002)(76176011)(476003)(99286004)(2501003)(486006)(14444005)(8676002)(478600001)(446003)(86362001)(305945005)(55016002)(256004)(97736004)(74316002)(81166006)(81156014)(8936002)(7736002)(105586002)(14454004)(2900100001)(9686003)(53936002)(72206003)(68736007)(26005)(102836004)(106356001)(3846002)(6116002)(6436002); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR08MB0608; H:VI1PR08MB3167.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: rmtJLqlL1dfE4rS9KclvtVkyxZfAMyhAJbEeEml7ON0QqLtew8ebASkd6Q3ixkDHYMacryw0k+NN6NU2j2x39dEp7JJomO8B/0AnaxbrYa71+K+w3wsaSCh1XMpRmqRyY4tDllVDQGa3siOQ3tFU4+L1qh7gDkHa8/Z1dygp9/MWU8xMB5/RIah7sMWUY+8QH3zSTQhx3vN4u0lgGhzL75avX+zWPEMV1YqCqnt6z1oKAcZ1nhQVcr5FfkrLjANUfxSG0OafIR6PgHiT4q6Y8ypWZNQgsude6AZSMaPZbGVPOVqFw7hIKe1mlY37Uuy3aLP0pxh6TiozHGwm7B1M29YX0QfmgsoAlUbv6UPG2qg= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-Network-Message-Id: f08380ef-1f23-451b-0e3b-08d62392a0fa X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Sep 2018 09:29:59.1037 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB0608 Subject: Re: [dpdk-dev] [PATCH v3 3/3] ring: move the atomic load of head above the loop X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 Sep 2018 09:30:00 -0000 +Justin He for review > -----Original Message----- > From: Gavin Hu > Sent: Monday, September 17, 2018 4:17 PM > To: dev@dpdk.org > Cc: Gavin Hu (Arm Technology China) ; Honnappa > Nagarahalli ; Steve Capper > ; Ola Liljedahl ; > jerin.jacob@caviumnetworks.com; nd ; stable@dpdk.org > Subject: [PATCH v3 3/3] ring: move the atomic load of head above the loop >=20 > In __rte_ring_move_prod_head, move the __atomic_load_n up and out of > the do {} while loop as upon failure the old_head will be updated, anothe= r > load is costly and not necessary. >=20 > This helps a little on the latency,about 1~5%. >=20 > Test result with the patch(two cores): > SP/SC bulk enq/dequeue (size: 8): 5.64 > MP/MC bulk enq/dequeue (size: 8): 9.58 > SP/SC bulk enq/dequeue (size: 32): 1.98 MP/MC bulk enq/dequeue (size: > 32): 2.30 >=20 > Fixes: 39368ebfc6 ("ring: introduce C11 memory model barrier option") > Cc: stable@dpdk.org >=20 > Signed-off-by: Gavin Hu > Reviewed-by: Honnappa Nagarahalli > Reviewed-by: Steve Capper > Reviewed-by: Ola Liljedahl > --- > lib/librte_ring/rte_ring_c11_mem.h | 10 ++++------ > 1 file changed, 4 insertions(+), 6 deletions(-) >=20 > diff --git a/lib/librte_ring/rte_ring_c11_mem.h > b/lib/librte_ring/rte_ring_c11_mem.h > index 0eae3b3..95cc508 100644 > --- a/lib/librte_ring/rte_ring_c11_mem.h > +++ b/lib/librte_ring/rte_ring_c11_mem.h > @@ -61,13 +61,11 @@ __rte_ring_move_prod_head(struct rte_ring *r, > unsigned int is_sp, > unsigned int max =3D n; > int success; >=20 > + *old_head =3D __atomic_load_n(&r->prod.head, > __ATOMIC_ACQUIRE); > do { > /* Reset n to the initial burst count */ > n =3D max; >=20 > - *old_head =3D __atomic_load_n(&r->prod.head, > - __ATOMIC_ACQUIRE); > - > /* load-acquire synchronize with store-release of ht->tail > * in update_tail. > */ > @@ -93,6 +91,7 @@ __rte_ring_move_prod_head(struct rte_ring *r, > unsigned int is_sp, > if (is_sp) > r->prod.head =3D *new_head, success =3D 1; > else > + /* on failure, *old_head is updated */ > success =3D __atomic_compare_exchange_n(&r- > >prod.head, > old_head, *new_head, > 0, __ATOMIC_ACQUIRE, > @@ -134,13 +133,11 @@ __rte_ring_move_cons_head(struct rte_ring *r, int > is_sc, > int success; >=20 > /* move cons.head atomically */ > + *old_head =3D __atomic_load_n(&r->cons.head, > __ATOMIC_ACQUIRE); > do { > /* Restore n as it may change every loop */ > n =3D max; >=20 > - *old_head =3D __atomic_load_n(&r->cons.head, > - __ATOMIC_ACQUIRE); > - > /* this load-acquire synchronize with store-release of ht->tail > * in update_tail. > */ > @@ -165,6 +162,7 @@ __rte_ring_move_cons_head(struct rte_ring *r, int > is_sc, > if (is_sc) > r->cons.head =3D *new_head, success =3D 1; > else > + /* on failure, *old_head will be updated */ > success =3D __atomic_compare_exchange_n(&r- > >cons.head, > old_head, > *new_head, > 0, > __ATOMIC_ACQUIRE, > -- > 2.7.4