From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70080.outbound.protection.outlook.com [40.107.7.80]) by dpdk.org (Postfix) with ESMTP id B0D791B136; Wed, 26 Sep 2018 12:06:37 +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=16Ty+ZkVve4TiuPSB5uH08ddibW7aSfQVU6J3w0XxPg=; b=IspQwbyKXxmR782KczJ17j1+VlZTfmND8pGgFyAHt6itUle52AXDT/YttTw3P2GVJnhZQSL5RKAugRrAK4vwP0R0JN+Lug2ot9kda72zKZANKmCuPYbyIajwaL2XFLoQOlEWE/ekHAKsZtb1e0v2MTO3TGy/ENg9npCPXXKLDJw= Received: from DB7PR08MB3082.eurprd08.prod.outlook.com (52.134.110.24) by DB7PR08MB3386.eurprd08.prod.outlook.com (20.176.238.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1164.22; Wed, 26 Sep 2018 10:06:36 +0000 Received: from DB7PR08MB3082.eurprd08.prod.outlook.com ([fe80::6c4d:ef1:bd1c:4589]) by DB7PR08MB3082.eurprd08.prod.outlook.com ([fe80::6c4d:ef1:bd1c:4589%6]) with mapi id 15.20.1143.022; Wed, 26 Sep 2018 10:06:36 +0000 From: Justin He To: "Gavin Hu (Arm Technology China)" , "dev@dpdk.org" CC: Honnappa Nagarahalli , Steve Capper , Ola Liljedahl , "jerin.jacob@caviumnetworks.com" , nd , "stable@dpdk.org" Thread-Topic: [PATCH v3 3/3] ring: move the atomic load of head above the loop Thread-Index: AQHUTl7qxSXFnEIzfUOrA7WYC48RUqUCWifAgAAJ24A= Date: Wed, 26 Sep 2018 10:06:36 +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: Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Justin.He@arm.com; x-originating-ip: [113.29.88.7] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DB7PR08MB3386; 6:y0rl0m09BQ2XyvoAxVG1pjIFlUQbFZ6yYF2f1rDONe4Z0H+cevJ9+7Hv5oHbSkB9hgEDucW2qTYNcUxdsrQYUniaVdjXjVg6VtV1QzVGPLEH9IYKNMeSih5oWBwx3oxZ7bvo9Npyxm7PQLnSLTIIY51wKMRMqAUS+OBxk830VWZI58zbYcXpIzFcyfLGpbGluzmeh/Iba7ldbzJzeiAKbV8kRYxeXSvKjcVXDTfVPzT0lub6VtAA32hHBpDoApYvCn7JPmLAF32CvBEWxVC1j0G+KmrylgJyX0IA86CQFlkUVpKb/0AlSc4ixX65MT5FX5ZclKd7vYMiaxCDkyR7vWcN4WBjspRxLXH7y4cjFLzRXI9xrCGMOX3hyfFfHysaGVi/Mt3rDZui+SIP5jqkc4a2tuOduI3EuAHa/lPrByLH5cL0oCYw+FxC8/pCSqdDDvCHU+M+/66OqsWT2RGG8g==; 5:1gep7P7f/dTYRUUj7hQX1QFJ9ZvImYfMVlAyzdP2CLdXiC1qvnDHiF3/+eBwIcQgojAGYO5pLwIANzP8CYhunJiKiXd2RpWzGYkareSFalboNRrWkW+LjYrw98T5LFc5lZC/uK3IaYsH+ZdcZ7JTx95mB1qNBeFyaQz4fHj13ho=; 7:DYgSIBJSZMqBQD1YlQcu1s8hdR2hJGJrYybfcmaudDgbyzECWyPNTLQUlG36tbUVSzm27hjU2B9tZSHkET9aPeC1bWTh2z6DYZ/7vuaCkw1gSSORXGgV/3p16o8nABTCwx+wTjjFKXr7SsCiFwfQoQpyUWVxxbFq3VKabIRj41KEuo6yzS71dDBNU5idCVdn+ikGBliXm2+67RS4BZoFYCj99VIiEiFh0t5g6TUe58J7GcU/NGCDWJk5esyEqUk3 x-ms-exchange-antispam-srfa-diagnostics: SOS;SOR; x-ms-office365-filtering-correlation-id: 5f073c32-5058-4b7c-a122-08d62397be76 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:DB7PR08MB3386; x-ms-traffictypediagnostic: DB7PR08MB3386: 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)(8121501046)(5005006)(10201501046)(3002001)(3231355)(944501410)(52105095)(93006095)(93001095)(6055026)(149066)(150057)(6041310)(20161123564045)(20161123558120)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(201708071742011)(7699051); SRVR:DB7PR08MB3386; BCL:0; PCL:0; RULEID:; SRVR:DB7PR08MB3386; x-forefront-prvs: 08076ABC99 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(136003)(376002)(396003)(346002)(39860400002)(366004)(199004)(189003)(13464003)(40434004)(66066001)(72206003)(478600001)(7696005)(14454004)(74316002)(7736002)(305945005)(110136005)(5250100002)(71190400001)(71200400001)(2501003)(54906003)(33656002)(6116002)(8676002)(3846002)(81166006)(476003)(26005)(86362001)(486006)(53546011)(6506007)(81156014)(34290500001)(2906002)(11346002)(446003)(68736007)(76176011)(5660300001)(105586002)(97736004)(14444005)(8936002)(256004)(316002)(93886005)(5024004)(25786009)(229853002)(102836004)(99286004)(106356001)(2900100001)(9686003)(4326008)(6436002)(55016002)(53936002)(6246003); DIR:OUT; SFP:1101; SCL:1; SRVR:DB7PR08MB3386; H:DB7PR08MB3082.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: Xhnv7ZgnT+buaDEbA5uyZR0UwZzs83Vc0elbS3yk//iYp5NUZ9IYjMyD2QycPBkqNmibuigZtZ2MEouQP6hOPti7lAblyp8epFbI++BpXyCBRlbnH2QUkXhhTqxrZJGlo5/oj2OMy/wkipnMGjdKHRmnyVN2VM/HS6AzsuAd9X1b48WPhnEofbYPtuBFS1ki5SLCe9iabWrlow/hwx+Hwy/pU+2z/gOdcP0bq6tpn3oqJ5DJJGZmuPUWwFawUDR80s4SV7ZVrtCJfNFZ/6b9lCgONxwz+KgQgkk5t6RJDufuKQ0CIZBFOARlxOT2zeM2n71S61Bpt4Dl23EnqNrcI59KbOVe5/iATqylBAQCvsg= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-2022-jp" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5f073c32-5058-4b7c-a122-08d62397be76 X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Sep 2018 10:06:36.0522 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR08MB3386 X-Mailman-Approved-At: Thu, 27 Sep 2018 13:25:05 +0200 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 10:06:38 -0000 > -----Original Message----- > From: Gavin Hu (Arm Technology China) > Sent: 2018=1B$BG/=1B(B9=1B$B7n=1B(B26=1B$BF|=1B(B 17:30 > 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 > Subject: RE: [PATCH v3 3/3] ring: move the atomic load of head above the = loop > > +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 lo= op > > > > 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, anot= her > > load is costly and not necessary. > > > > This helps a little on the latency,about 1~5%. > > > > 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 > > > > Fixes: 39368ebfc6 ("ring: introduce C11 memory model barrier option") > > Cc: stable@dpdk.org > > > > 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(-) > > > > 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; > > > > +*old_head =3D __atomic_load_n(&r->prod.head, > > __ATOMIC_ACQUIRE); > > do { > > /* Reset n to the initial burst count */ > > n =3D max; > > > > -*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; > > > > /* 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; > > > > -*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 Reviewed-by: Jia He Cheers, Justin (Jia He) IMPORTANT NOTICE: The contents of this email and any attachments are confid= ential and may also be privileged. If you are not the intended recipient, p= lease notify the sender immediately and do not disclose the contents to any= other person, use it for any purpose, or store or copy the information in = any medium. Thank you.