From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0F9BCA0C4B; Tue, 16 Nov 2021 20:52:43 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9810940141; Tue, 16 Nov 2021 20:52:42 +0100 (CET) Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-eopbgr00079.outbound.protection.outlook.com [40.107.0.79]) by mails.dpdk.org (Postfix) with ESMTP id 1C25A40040 for ; Tue, 16 Nov 2021 20:52:41 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kAkJ57CK8ZcGa1DJG+vcWmVD2+jlX0/wryJjqgRyhV4=; b=3Sla7VCgOWxD8HFQ7hHAizBWavKeGM5VT4wDV5lp535TNTrt27eMG5uXN29OUol7JOboUIsjfKdqv8KoG/5Ej76uNZINXuzbw9pIuD781E7LhgtyliyeSl8vgt12naJYM1NymyIpnmDtUF4zj3BGR489V3eEyG4J+dYkpBu4A1c= Received: from AM3PR07CA0097.eurprd07.prod.outlook.com (2603:10a6:207:6::31) by DB8PR08MB5483.eurprd08.prod.outlook.com (2603:10a6:10:11b::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.22; Tue, 16 Nov 2021 19:52:39 +0000 Received: from AM5EUR03FT029.eop-EUR03.prod.protection.outlook.com (2603:10a6:207:6:cafe::4f) by AM3PR07CA0097.outlook.office365.com (2603:10a6:207:6::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4713.15 via Frontend Transport; Tue, 16 Nov 2021 19:52:39 +0000 X-MS-Exchange-Authentication-Results: spf=temperror (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=temperror action=none header.from=arm.com; Received-SPF: TempError (protection.outlook.com: error in processing during lookup of arm.com: DNS Timeout) Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT029.mail.protection.outlook.com (10.152.16.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.20 via Frontend Transport; Tue, 16 Nov 2021 19:52:37 +0000 Received: ("Tessian outbound f493ab4f1fb8:v110"); Tue, 16 Nov 2021 19:52:37 +0000 X-CR-MTA-TID: 64aa7808 Received: from a85f087a3178.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id D48BA814-78F7-456D-882D-451EC6CE7AE7.1; Tue, 16 Nov 2021 19:52:26 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id a85f087a3178.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 16 Nov 2021 19:52:26 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=S7c/H+LEceHRF21O4mf56SGoJuYQ+w1npTai/mStstybVmIX5TqMWAt4BmykbuHLARZczWV3FrV5Ve4WnoMcWg21evgCMTc1JFpwex7kDsSLIi91lT7y4TN+3aI9aOGpr0MA0Gqtp0/dm2+SMOPyrEjZF8LcZ+D5pYdo99ckzwfA0/bdKSZoNsir16UYTJisMfjkHlTn8KJqTZUjFCf4yGFWeAVAnG5kKF7Kba1aPFwuA7NW0bqpfgqkoa/GDnhgriwNfuxEL/PUqLj2Rn/U++ILhSIRxrrghbaloBGc+FlfjNFJOVOHOSnpK3bO1li3gKsbhC50ZHfZG2GMDftJwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=kAkJ57CK8ZcGa1DJG+vcWmVD2+jlX0/wryJjqgRyhV4=; b=Q/aZZ1svUNahHOAn2ACRAntxMnkf4cUcqutqOHHT2QYVzqKIKeREXv+kVNVCF3ildnEwLm4dsBNEwk8Fhpi61KDEKvwnE5Ck8olFHlk58aonwQeCSalJTvXp8Cz2pgeOXFBCJcwsfYTGwKXkakehVEYHnfIDhO2ugj0FpcQ6EH1Tbl3HWCg87s477JWQivVfgAgvBH3Pi6xLmWFJ4sstcpq4NuHbQZsOl/l3oXTkDAajQwybSNiR3mgGw2HJvwaF6GtDzH8UIK1/GYHkTzVJJUsImBUB1XwALM81y6bSBW+iveRvkAZ7j7RV70Y3df2bsM1v8ERHT9iaKU1MPNvNcg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kAkJ57CK8ZcGa1DJG+vcWmVD2+jlX0/wryJjqgRyhV4=; b=3Sla7VCgOWxD8HFQ7hHAizBWavKeGM5VT4wDV5lp535TNTrt27eMG5uXN29OUol7JOboUIsjfKdqv8KoG/5Ej76uNZINXuzbw9pIuD781E7LhgtyliyeSl8vgt12naJYM1NymyIpnmDtUF4zj3BGR489V3eEyG4J+dYkpBu4A1c= Received: from AM8PR08MB5810.eurprd08.prod.outlook.com (2603:10a6:20b:1d2::20) by AM9PR08MB6898.eurprd08.prod.outlook.com (2603:10a6:20b:301::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4713.19; Tue, 16 Nov 2021 19:52:18 +0000 Received: from AM8PR08MB5810.eurprd08.prod.outlook.com ([fe80::21ce:5175:83fd:3368]) by AM8PR08MB5810.eurprd08.prod.outlook.com ([fe80::21ce:5175:83fd:3368%4]) with mapi id 15.20.4713.019; Tue, 16 Nov 2021 19:52:18 +0000 From: Honnappa Nagarahalli To: Joyce Kong , Robert Sanford , Erik Gabriel Carrillo CC: "dev@dpdk.org" , nd , Joyce Kong , Ruifeng Wang , nd Subject: RE: [PATCH v2 03/12] test/timer: use compiler atomic builtins for sync Thread-Topic: [PATCH v2 03/12] test/timer: use compiler atomic builtins for sync Thread-Index: AQHX2s5bATcgobcJl0WCiFPx2C8dlKwGkQoQ Date: Tue, 16 Nov 2021 19:52:18 +0000 Message-ID: References: <20211116094205.750359-1-joyce.kong@arm.com> <20211116094205.750359-4-joyce.kong@arm.com> In-Reply-To: <20211116094205.750359-4-joyce.kong@arm.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ts-tracking-id: 3BD3A90D10CDDB4BA1E2429E90468174.0 x-checkrecipientchecked: true Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; x-ms-publictraffictype: Email X-MS-Office365-Filtering-Correlation-Id: 0007166c-42eb-4a76-5043-08d9a93aa42b x-ms-traffictypediagnostic: AM9PR08MB6898:|DB8PR08MB5483: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true nodisclaimer: true x-ms-oob-tlc-oobclassifiers: OLM:4941;OLM:4941; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: WbguLVoPzvkWg2hkd6UG4U9LmgCwKtIVlCiIg/TfuBp7NodqHt47yHPDubQ7KlZ6OI12sittednlQiddVCJxNdC1xGyNV/BC7lilPOZcBvJz9bApe2dbHZCadBaXGRvPj/pvpFLg8vgsUewyCCpSw5D3s72aHvscLfhLTI7NlBtaVUDTcBE8KXv57CC+ZiOP0xKZy/eubLos3TlW02zwHZ3xAXHQbszcZYl29AZZUgOgmJu+yRC1rnbdaPdS7oGk6LsLKTEww6PqWVHuu1gtWgzehUW/0XXOgR+IGCpA9Ut3Pzw2imj7uv52XYlO/Kz7yisj1kZiRaHOzQFrnu3aXFstZTn0oqJhqMjWvjWyVgdWAYWA7nesdaPGXreqssfvw2gNkt50GNsWbZ+3JN/sVIVl6r5BxZsAkuM9spGgFXPrkt8e9GapVwgEyQr4eSxifrQF3yL9fFDi4+x7JUSkLwTdqR74oFXKEcHw6qMbMtZvOAsUTFLVRUxF6FyWKOwYNZNoFt1vPbl1f3q1/62zq8aOHh5Ic7Mw87XQgBTBLUoqGwM9vDe7nq/a3K1rRdZz4WlcA0Omu+aF/tjwiJ33HEPTafLdtzdK2QmhWJkrrwEfdt2fOyYxw5jH08NUzAyf4ShfbRROQgjfRwiP46bssPFRHzAY2UoiMr8tnx1BAtLhbue3bKIFsDonhtd2ZPBmaZVR3Iw5DOumBG3EDeoX7g== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM8PR08MB5810.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(66446008)(38100700002)(122000001)(5660300002)(316002)(66946007)(8676002)(52536014)(64756008)(66556008)(66476007)(54906003)(110136005)(8936002)(76116006)(4326008)(83380400001)(55016002)(33656002)(26005)(9686003)(71200400001)(7696005)(508600001)(6506007)(2906002)(38070700005)(86362001)(186003); DIR:OUT; SFP:1101; Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR08MB6898 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT029.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: eab05574-eafb-493d-9865-08d9a93a98d8 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jaYKd9gzBB6TraSsZIoln9oEmqOo6lzl1Wuewjgn+gOQfUcrmwemSSx0p4HsiN1lQgks3gufZ5u0xReF7K7BsvJAS2G18NLK/koMYJxyE3bXPv6UrBE4cC0LWX7FVXLES1zUnwZrEWpyVhSy0iQ3uZS2T7uOTalKOTF4Z428y/2MuTuAr4IiqQRNm0WIDIuPVP4gZtforAyJ6YoexrpVlFPdwooMY0TdBQ5WaqmFD6pj1u3o0qcssqwxuwJocdOD3lRHkKV1wRjF92XiK2ewgz0cHnDJmofOt87Te+56MYoVQF3YspnHjAzNBoLjFeUxNiWk+8p9FZIo1qCPWOrg5v1co9kKlUcZumcQBADhoAC1eJv9aATkAFH/we4oi2nZBjWu6SnHoLViIPbCGYuQnhndf8Tdm47DmSxtukmVABDX0YpL4bE1rf/QewQ9yaBj5f2vTd6HKSYNCWtxXNi88/bRgisILw659nxSNUihbtklhIY+lQuCdI9M2/QzNZAeDl1ybLnRwfwkJmwdzRlmNRXx0akgoqf2PqXRiPLqapPP6rzIfX1/cI1wTfbcx6cfOYQHOyv4huvI0Zrlw46K+49Oul7XGMUJ4VnKuVPpne4HaLsLIQ+MErKuh0fc7KZYWJmBwllAqln8cNUQb/6kaGUNkp3rB0rOBAgcWD+4oh6STWzTA/DETPpqmPoA2thPFb/8782S6FZceQ7TaE9B0A== X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(4636009)(36840700001)(46966006)(336012)(86362001)(6506007)(5660300002)(63370400001)(7696005)(54906003)(26005)(186003)(52536014)(36860700001)(63350400001)(356005)(81166007)(47076005)(316002)(55016002)(508600001)(110136005)(70586007)(4326008)(70206006)(8676002)(9686003)(83380400001)(33656002)(8936002)(2906002)(82310400003); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Nov 2021 19:52:37.6615 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0007166c-42eb-4a76-5043-08d9a93aa42b X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM5EUR03FT029.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR08MB5483 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org >=20 > Convert rte_atomic usages to compiler atomic built-ins for lcore_state an= d > collisions sync. >=20 > Also, move 'main_init_workers' outside of 'timer_stress2_main_loop' to > guarantee lcore_state initialized correctly before the threads launched. >=20 > Signed-off-by: Joyce Kong > Reviewed-by: Ruifeng Wang Reviewed-by: Honnappa Nagarahalli > --- > app/test/test_timer.c | 30 +++++++++++++----------------- > app/test/test_timer_secondary.c | 1 - > 2 files changed, 13 insertions(+), 18 deletions(-) >=20 > diff --git a/app/test/test_timer.c b/app/test/test_timer.c index > a10b2fe9da..c97e5c891c 100644 > --- a/app/test/test_timer.c > +++ b/app/test/test_timer.c > @@ -102,7 +102,6 @@ > #include > #include > #include > -#include > #include > #include > #include > @@ -203,7 +202,7 @@ timer_stress_main_loop(__rte_unused void *arg) >=20 > /* Need to synchronize worker lcores through multiple steps. */ enum { > WORKER_WAITING =3D 1, WORKER_RUN_SIGNAL, WORKER_RUNNING, > WORKER_FINISHED }; -static rte_atomic16_t lcore_state[RTE_MAX_LCORE]; > +static uint16_t lcore_state[RTE_MAX_LCORE]; >=20 > static void > main_init_workers(void) > @@ -211,7 +210,7 @@ main_init_workers(void) > unsigned i; >=20 > RTE_LCORE_FOREACH_WORKER(i) { > - rte_atomic16_set(&lcore_state[i], WORKER_WAITING); > + __atomic_store_n(&lcore_state[i], WORKER_WAITING, > __ATOMIC_RELAXED); > } > } >=20 > @@ -221,11 +220,10 @@ main_start_workers(void) > unsigned i; >=20 > RTE_LCORE_FOREACH_WORKER(i) { > - rte_atomic16_set(&lcore_state[i], WORKER_RUN_SIGNAL); > + __atomic_store_n(&lcore_state[i], WORKER_RUN_SIGNAL, > +__ATOMIC_RELEASE); > } > RTE_LCORE_FOREACH_WORKER(i) { > - while (rte_atomic16_read(&lcore_state[i]) !=3D > WORKER_RUNNING) > - rte_pause(); > + rte_wait_until_equal_16(&lcore_state[i], WORKER_RUNNING, > +__ATOMIC_ACQUIRE); > } > } >=20 > @@ -235,8 +233,7 @@ main_wait_for_workers(void) > unsigned i; >=20 > RTE_LCORE_FOREACH_WORKER(i) { > - while (rte_atomic16_read(&lcore_state[i]) !=3D > WORKER_FINISHED) > - rte_pause(); > + rte_wait_until_equal_16(&lcore_state[i], WORKER_FINISHED, > +__ATOMIC_ACQUIRE); > } > } >=20 > @@ -245,9 +242,8 @@ worker_wait_to_start(void) { > unsigned lcore_id =3D rte_lcore_id(); >=20 > - while (rte_atomic16_read(&lcore_state[lcore_id]) !=3D > WORKER_RUN_SIGNAL) > - rte_pause(); > - rte_atomic16_set(&lcore_state[lcore_id], WORKER_RUNNING); > + rte_wait_until_equal_16(&lcore_state[lcore_id], > WORKER_RUN_SIGNAL, __ATOMIC_ACQUIRE); > + __atomic_store_n(&lcore_state[lcore_id], WORKER_RUNNING, > +__ATOMIC_RELEASE); > } >=20 > static void > @@ -255,7 +251,7 @@ worker_finish(void) > { > unsigned lcore_id =3D rte_lcore_id(); >=20 > - rte_atomic16_set(&lcore_state[lcore_id], WORKER_FINISHED); > + __atomic_store_n(&lcore_state[lcore_id], WORKER_FINISHED, > +__ATOMIC_RELEASE); > } >=20 >=20 > @@ -281,13 +277,12 @@ timer_stress2_main_loop(__rte_unused void *arg) > unsigned int lcore_id =3D rte_lcore_id(); > unsigned int main_lcore =3D rte_get_main_lcore(); > int32_t my_collisions =3D 0; > - static rte_atomic32_t collisions; > + static uint32_t collisions; >=20 > if (lcore_id =3D=3D main_lcore) { > cb_count =3D 0; > test_failed =3D 0; > - rte_atomic32_set(&collisions, 0); > - main_init_workers(); > + __atomic_store_n(&collisions, 0, __ATOMIC_RELAXED); > timers =3D rte_malloc(NULL, sizeof(*timers) * > NB_STRESS2_TIMERS, 0); > if (timers =3D=3D NULL) { > printf("Test Failed\n"); > @@ -315,7 +310,7 @@ timer_stress2_main_loop(__rte_unused void *arg) > my_collisions++; > } > if (my_collisions !=3D 0) > - rte_atomic32_add(&collisions, my_collisions); > + __atomic_fetch_add(&collisions, my_collisions, > __ATOMIC_RELAXED); >=20 > /* wait long enough for timers to expire */ > rte_delay_ms(100); > @@ -329,7 +324,7 @@ timer_stress2_main_loop(__rte_unused void *arg) >=20 > /* now check that we get the right number of callbacks */ > if (lcore_id =3D=3D main_lcore) { > - my_collisions =3D rte_atomic32_read(&collisions); > + my_collisions =3D __atomic_load_n(&collisions, > __ATOMIC_RELAXED); > if (my_collisions !=3D 0) > printf("- %d timer reset collisions (OK)\n", > my_collisions); > rte_timer_manage(); > @@ -573,6 +568,7 @@ test_timer(void) > /* run a second, slightly different set of stress tests */ > printf("\nStart timer stress tests 2\n"); > test_failed =3D 0; > + main_init_workers(); > rte_eal_mp_remote_launch(timer_stress2_main_loop, NULL, > CALL_MAIN); > rte_eal_mp_wait_lcore(); > if (test_failed) > diff --git a/app/test/test_timer_secondary.c b/app/test/test_timer_second= ary.c > index 16a9f1878b..5795c97f07 100644 > --- a/app/test/test_timer_secondary.c > +++ b/app/test/test_timer_secondary.c > @@ -9,7 +9,6 @@ > #include > #include > #include > -#include > #include > #include > #include > -- > 2.25.1