From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from dpdk.org (dpdk.org [92.243.14.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 1D123A0519;
	Mon, 22 Jun 2020 12:12:36 +0200 (CEST)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id BFF281D657;
	Mon, 22 Jun 2020 12:12:34 +0200 (CEST)
Received: from EUR05-AM6-obe.outbound.protection.outlook.com
 (mail-am6eur05on2067.outbound.protection.outlook.com [40.107.22.67])
 by dpdk.org (Postfix) with ESMTP id DDF271D656
 for <dev@dpdk.org>; Mon, 22 Jun 2020 12:12:32 +0200 (CEST)
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=iSBVZC4QpYZFPSDeaJhVn2M4x7h7XU79Zl5eWfOlYuo=;
 b=8OpLbJe0eh70LoMGngTHfuOm/cV95NHWSPYxk11thglwliXX+SKS9viBQ1no74x+1N9Zh76R9OV2WxbYrCpuM+hN3rVLIwrBfi6A2ZzFTshwHh33E+3SJz9xy0ykUU0SeC6H8NNrKjdeShWjMNVjABuuJOvhmU/mUNYGskJv9Jk=
Received: from DB6PR0802CA0036.eurprd08.prod.outlook.com (2603:10a6:4:a3::22)
 by DB6PR08MB2821.eurprd08.prod.outlook.com (2603:10a6:6:19::15) with
 Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22; Mon, 22 Jun
 2020 10:12:31 +0000
Received: from DB5EUR03FT031.eop-EUR03.prod.protection.outlook.com
 (2603:10a6:4:a3:cafe::e0) by DB6PR0802CA0036.outlook.office365.com
 (2603:10a6:4:a3::22) with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22 via Frontend
 Transport; Mon, 22 Jun 2020 10:12:31 +0000
X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123)
 smtp.mailfrom=arm.com; dpdk.org; dkim=pass (signature was verified)
 header.d=armh.onmicrosoft.com;dpdk.org; dmarc=bestguesspass action=none
 header.from=arm.com;
Received-SPF: Pass (protection.outlook.com: domain of arm.com designates
 63.35.35.123 as permitted sender) receiver=protection.outlook.com;
 client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com;
Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by
 DB5EUR03FT031.mail.protection.outlook.com (10.152.20.142) with
 Microsoft SMTP
 Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id
 15.20.3109.22 via Frontend Transport; Mon, 22 Jun 2020 10:12:31 +0000
Received: ("Tessian outbound 147ff5d152c1:v59");
 Mon, 22 Jun 2020 10:12:31 +0000
X-CR-MTA-TID: 64aa7808
Received: from 8acee13f1ca7.3
 by 64aa7808-outbound-1.mta.getcheckrecipient.com id
 78F1BCF2-4728-4F67-ABBA-CA849CE1779B.1; 
 Mon, 22 Jun 2020 10:12:26 +0000
Received: from EUR05-VI1-obe.outbound.protection.outlook.com
 by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 8acee13f1ca7.3
 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384);
 Mon, 22 Jun 2020 10:12:26 +0000
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;
 b=FzifkUpB8FLBuSAVDMqbJ4a7wb0FviUNnvawNikuGnXg4JGKenSyyBk4ERTIL98c2qvwgsMr1tdF9neWo9ZUko+jGbUIuCtNNQ+bjiLNFP8w0yWAIVSwW/F9NhstKmh9xFjPEbnHVRkPtAeF73RB1uz2qk+C3kkT0DJX6NaYk1IqIH/7/Nb3Bc7LvwNohOxB6vRkpvQKzLw8UMvhfbafdsg+0pPRq4h43bd5GMp3mSDY0TtvusOG3z9z2OclODC3ma5srAfMSe/rHD9Mj7L6jdj3gRqEqhehGyRP8S8K6aIz5VXW8X6PxuxGdh++RUFgSA/BsohqsAD6IsLkKtmBMA==
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-SenderADCheck;
 bh=iSBVZC4QpYZFPSDeaJhVn2M4x7h7XU79Zl5eWfOlYuo=;
 b=Foe/niGmelcvG8k1eZvi06SBRslGWbEt01e2mmCWV38CXAQPUkqoIJcrBdqUFMpHU97zJqDGlGq68rkBSLM0/QFGRDuufHT4cFs3U8tnv7BXbaCg+Uzc+PU3hMGdoRnGyr+iCL5i7wKLSB7xT5+mtOsOdDg5R9Pz+SYwtJUpOqeMAIEUxhKMBmZyHBVqSXlv/YSqHsnlnV0Y+tL4klgX6In9TtzZ0PylF/iiGhGBsXDF0E+xzUMgjTz13yciOZz7/Jk75j3VRZJu9/65BT6ik3Vard5qwsypTG9T/3RlKRKvb/4+mFhLzYX9VgDFRXdAj/1GGtL3yX5JbWGLbL6IPg==
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=iSBVZC4QpYZFPSDeaJhVn2M4x7h7XU79Zl5eWfOlYuo=;
 b=8OpLbJe0eh70LoMGngTHfuOm/cV95NHWSPYxk11thglwliXX+SKS9viBQ1no74x+1N9Zh76R9OV2WxbYrCpuM+hN3rVLIwrBfi6A2ZzFTshwHh33E+3SJz9xy0ykUU0SeC6H8NNrKjdeShWjMNVjABuuJOvhmU/mUNYGskJv9Jk=
Received: from VE1PR08MB4640.eurprd08.prod.outlook.com (2603:10a6:802:b2::11)
 by VE1PR08MB4688.eurprd08.prod.outlook.com (2603:10a6:802:a3::10)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22; Mon, 22 Jun
 2020 10:12:23 +0000
Received: from VE1PR08MB4640.eurprd08.prod.outlook.com
 ([fe80::c2e:9ccb:a690:6863]) by VE1PR08MB4640.eurprd08.prod.outlook.com
 ([fe80::c2e:9ccb:a690:6863%6]) with mapi id 15.20.3109.027; Mon, 22 Jun 2020
 10:12:23 +0000
From: Phil Yang <Phil.Yang@arm.com>
To: Phil Yang <Phil.Yang@arm.com>, "dev@dpdk.org" <dev@dpdk.org>,
 "erik.g.carrillo@intel.com" <erik.g.carrillo@intel.com>
CC: "drc@linux.vnet.ibm.com" <drc@linux.vnet.ibm.com>, Honnappa Nagarahalli
 <Honnappa.Nagarahalli@arm.com>, Ruifeng Wang <Ruifeng.Wang@arm.com>, Dharmik
 Thakkar <Dharmik.Thakkar@arm.com>, nd <nd@arm.com>
Thread-Topic: [dpdk-dev] [PATCH 3/3] eventdev: relax smp barriers with c11
 atomics
Thread-Index: AQHWQKuOoFq5cth9D0eZxl4zUNwL86jkc1Wg
Date: Mon, 22 Jun 2020 10:12:23 +0000
Message-ID: <VE1PR08MB464086A9E268D36233CB605FE9970@VE1PR08MB4640.eurprd08.prod.outlook.com>
References: <1591960798-24024-1-git-send-email-phil.yang@arm.com>
 <1591960798-24024-3-git-send-email-phil.yang@arm.com>
In-Reply-To: <1591960798-24024-3-git-send-email-phil.yang@arm.com>
Accept-Language: zh-CN, en-US
Content-Language: en-US
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
x-ts-tracking-id: 53fa3827-5682-40a6-91fd-3731fb1d899d.0
x-checkrecipientchecked: true
Authentication-Results-Original: arm.com; dkim=none (message not signed)
 header.d=none;arm.com; dmarc=none action=none header.from=arm.com;
x-originating-ip: [203.126.0.112]
x-ms-publictraffictype: Email
X-MS-Office365-Filtering-HT: Tenant
X-MS-Office365-Filtering-Correlation-Id: 829ed328-ba8b-43f0-d3b6-08d81694c64f
x-ms-traffictypediagnostic: VE1PR08MB4688:|DB6PR08MB2821:
x-ms-exchange-transport-forked: True
X-Microsoft-Antispam-PRVS: <DB6PR08MB2821512A0AEB8AC475D94A5AE9970@DB6PR08MB2821.eurprd08.prod.outlook.com>
x-checkrecipientrouted: true
nodisclaimer: true
x-ms-oob-tlc-oobclassifiers: OLM:9508;OLM:9508;
x-forefront-prvs: 0442E569BC
X-MS-Exchange-SenderADCheck: 1
X-Microsoft-Antispam-Untrusted: BCL:0;
X-Microsoft-Antispam-Message-Info-Original: UmuE6TM5Z8o6UIWS88bnHNkTUjioKblvHBwxdgorIoKdwmae6yitRFMfz/n/SDygK+TD2zXBk70PU3YKRUyUFztucS0srpsOf24nJhw8c0NOad4PRB74gLylxZlRp2mRGhuETzwl/Nc5XKTF5zJzngeXfP18YJAEIgE9F68ZY7N5ACq7yvxqw2LiFm/QlpkZAerfJmhoESW6dstd8Kbt/PfAKDneOvqboP8cbCawOtbw2rJr4G/mXXBAidU0xlnO6dCbSo1hAKdq69X2cOmJ6g0HKDnTsMlSzqM6yO3wikrOMXiTU3uvKxlfrW/Rh/Hz6Vp/bxts4D321+VUuwJuHA==
X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en;
 SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VE1PR08MB4640.eurprd08.prod.outlook.com;
 PTR:; CAT:NONE; SFTY:;
 SFS:(4636009)(366004)(346002)(39860400002)(376002)(136003)(396003)(64756008)(53546011)(66446008)(4326008)(66476007)(71200400001)(316002)(7696005)(478600001)(54906003)(110136005)(33656002)(83380400001)(6506007)(5660300002)(55016002)(9686003)(52536014)(26005)(8936002)(66556008)(66946007)(186003)(2906002)(8676002)(76116006)(86362001);
 DIR:OUT; SFP:1101; 
x-ms-exchange-antispam-messagedata: MHCwGkyajXCm6UYpQV6lZFgAbD+k68gKULk9Azl2lYuh6P0ddOywWH2ICcGih5g0ZlQwhANGNaaNEdKaJJ5K3kA7WwM1tkEM+rqL8pTJSVQN50jEUMmKB5FOUEpCLNAbCZyeVR3meqlQvJqguKGjVCicloK+YAX7quwBj+JHP6l2u5vS8lhEX4DTmKe7Sw5YXiT6Qy70V6onW1cO09SDCDc8pY8W4yArIkO35rWFz5V9V4aALLEVKrpjtnVUl+81AVGzRqeYnydueYrHXom7a13hDB6FjNglL9WpNHRbfsKlS41pzBH/8aZrLXWUOm0toq2ryJXoBPbIdFUCEpY00D0EexjcIlJyh+cJuUNKlYKegy5s7phQOls8Uzyzc4oOsuQLd1pbC3xjRbe3C0m9BDWA2AlcM1QXa1h+LVboXFZVT0lnhWl8JpqxUVGG3YlVhcoWV/ufMbS2Mg8VykRpfELGb7m8Tfg69OqHMh8BqE8=
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB4688
Original-Authentication-Results: arm.com; dkim=none (message not signed)
 header.d=none;arm.com; dmarc=none action=none header.from=arm.com;
X-EOPAttributedMessage: 0
X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT031.eop-EUR03.prod.protection.outlook.com
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; SFTY:;
 SFS:(4636009)(39860400002)(376002)(346002)(396003)(136003)(46966005)(33656002)(26005)(86362001)(2906002)(4326008)(186003)(9686003)(55016002)(82740400003)(83380400001)(82310400002)(47076004)(6506007)(53546011)(478600001)(81166007)(356005)(7696005)(336012)(70206006)(5660300002)(52536014)(54906003)(8676002)(110136005)(8936002)(70586007)(316002);
 DIR:OUT; SFP:1101; 
X-MS-Office365-Filtering-Correlation-Id-Prvs: 7176d3e4-91f2-4cda-e577-08d81694c1dc
X-Forefront-PRVS: 0442E569BC
X-Microsoft-Antispam: BCL:0;
X-Microsoft-Antispam-Message-Info: O0ZXNJWZj28FUkeAl1ukCUzhPl1qpLNLC5JnZ2Vxx/tJDtnpgbPR5l7Ao3jdLyYZ++E+GH4P90fT5AcXqhjLpEgdKWKlDb7W8PfjMLw1/T29QpmEh9sNQsM1ZsQD15cRLJR+oqIIUVcMEH1YfNSLleDwWS+WUwTacRBhgtGMSVVhMss7LHN62DAJ8lpG9jgzy8KU4jpae6rWaIonYriL4MUSdHWmrUzOQxeY6uDgnVDHDbAl6SwSHmKp9zKEjFcXABWDuoN2vL/XwmHyuF1CrZzCjcEcIdT5i2qeZMZAhjmbUS5TlFGsJ4/WYiQfb4dv1O1xAXn95lO3axPTPLWk/WQfS2R+6+qcKfor/mwI8Hy20c6i/o8AkIc+mpddiz5qQNaMZasLpntcJLzKFJ3a5w==
X-OriginatorOrg: arm.com
X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jun 2020 10:12:31.0956 (UTC)
X-MS-Exchange-CrossTenant-Network-Message-Id: 829ed328-ba8b-43f0-d3b6-08d81694c64f
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-FromEntityHeader: HybridOnPrem
X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR08MB2821
Subject: Re: [dpdk-dev] [PATCH 3/3] eventdev: relax smp barriers with c11
 atomics
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>

> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Phil Yang
> Sent: Friday, June 12, 2020 7:20 PM
> To: dev@dpdk.org; erik.g.carrillo@intel.com
> Cc: drc@linux.vnet.ibm.com; Honnappa Nagarahalli
> <Honnappa.Nagarahalli@arm.com>; Ruifeng Wang
> <Ruifeng.Wang@arm.com>; Dharmik Thakkar <Dharmik.Thakkar@arm.com>;
> nd <nd@arm.com>
> Subject: [dpdk-dev] [PATCH 3/3] eventdev: relax smp barriers with c11
> atomics
>=20
> The implementation-specific opaque data is shared between arm and cancel
> operations. The state flag acts as a guard variable to make sure the
> update of opaque data is synchronized. This patch uses c11 atomics with
> explicit one way memory barrier instead of full barriers rte_smp_w/rmb()
> to synchronize the opaque data between timer arm and cancel threads.
>=20
> Signed-off-by: Phil Yang <phil.yang@arm.com>
> Reviewed-by: Dharmik Thakkar <dharmik.thakkar@arm.com>
> Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
> ---
>  lib/librte_eventdev/rte_event_timer_adapter.c | 55
> ++++++++++++++++++---------
>  lib/librte_eventdev/rte_event_timer_adapter.h |  2 +-
>  2 files changed, 38 insertions(+), 19 deletions(-)
>=20
> diff --git a/lib/librte_eventdev/rte_event_timer_adapter.c
> b/lib/librte_eventdev/rte_event_timer_adapter.c
> index 6947efb..0a26501 100644
> --- a/lib/librte_eventdev/rte_event_timer_adapter.c
> +++ b/lib/librte_eventdev/rte_event_timer_adapter.c
> @@ -629,7 +629,8 @@ swtim_callback(struct rte_timer *tim)
>  		sw->expired_timers[sw->n_expired_timers++] =3D tim;
>  		sw->stats.evtim_exp_count++;
>=20
> -		evtim->state =3D RTE_EVENT_TIMER_NOT_ARMED;
> +		__atomic_store_n(&evtim->state,
> RTE_EVENT_TIMER_NOT_ARMED,
> +				 __ATOMIC_RELEASE);
>  	}
>=20
>  	if (event_buffer_batch_ready(&sw->buffer)) {
> @@ -1020,6 +1021,7 @@ __swtim_arm_burst(const struct
> rte_event_timer_adapter *adapter,
>  	int n_lcores;
>  	/* Timer is not armed state */
>  	int16_t exp_state =3D 0;
> +	enum rte_event_timer_state n_state;
>=20
>  #ifdef RTE_LIBRTE_EVENTDEV_DEBUG
>  	/* Check that the service is running. */
> @@ -1060,30 +1062,36 @@ __swtim_arm_burst(const struct
> rte_event_timer_adapter *adapter,
>  	}
>=20
>  	for (i =3D 0; i < nb_evtims; i++) {
> -		/* Don't modify the event timer state in these cases */
> -		if (evtims[i]->state =3D=3D RTE_EVENT_TIMER_ARMED) {
> +		n_state =3D __atomic_load_n(&evtims[i]->state,
> __ATOMIC_RELAXED);
> +		if (n_state =3D=3D RTE_EVENT_TIMER_ARMED) {
>  			rte_errno =3D EALREADY;
>  			break;
> -		} else if (!(evtims[i]->state =3D=3D
> RTE_EVENT_TIMER_NOT_ARMED ||
> -			     evtims[i]->state =3D=3D
> RTE_EVENT_TIMER_CANCELED)) {
> +		} else if (!(n_state =3D=3D RTE_EVENT_TIMER_NOT_ARMED ||
> +			     n_state =3D=3D RTE_EVENT_TIMER_CANCELED)) {
>  			rte_errno =3D EINVAL;
>  			break;
>  		}
>=20
>  		ret =3D check_timeout(evtims[i], adapter);
>  		if (unlikely(ret =3D=3D -1)) {
> -			evtims[i]->state =3D
> RTE_EVENT_TIMER_ERROR_TOOLATE;
> +			__atomic_store_n(&evtims[i]->state,
> +					RTE_EVENT_TIMER_ERROR_TOOLATE,
> +					__ATOMIC_RELAXED);
>  			rte_errno =3D EINVAL;
>  			break;
>  		} else if (unlikely(ret =3D=3D -2)) {
> -			evtims[i]->state =3D
> RTE_EVENT_TIMER_ERROR_TOOEARLY;
> +			__atomic_store_n(&evtims[i]->state,
> +
> 	RTE_EVENT_TIMER_ERROR_TOOEARLY,
> +					__ATOMIC_RELAXED);
>  			rte_errno =3D EINVAL;
>  			break;
>  		}
>=20
>  		if (unlikely(check_destination_event_queue(evtims[i],
>  							   adapter) < 0)) {
> -			evtims[i]->state =3D RTE_EVENT_TIMER_ERROR;
> +			__atomic_store_n(&evtims[i]->state,
> +					RTE_EVENT_TIMER_ERROR,
> +					__ATOMIC_RELAXED);
>  			rte_errno =3D EINVAL;
>  			break;
>  		}
> @@ -1099,13 +1107,18 @@ __swtim_arm_burst(const struct
> rte_event_timer_adapter *adapter,
>  					  SINGLE, lcore_id, NULL, evtims[i]);
>  		if (ret < 0) {
>  			/* tim was in RUNNING or CONFIG state */
> -			evtims[i]->state =3D RTE_EVENT_TIMER_ERROR;
> +			__atomic_store_n(&evtims[i]->state,
> +					RTE_EVENT_TIMER_ERROR,
> +					__ATOMIC_RELEASE);
>  			break;
>  		}
>=20
> -		rte_smp_wmb();
>  		EVTIM_LOG_DBG("armed an event timer");
> -		evtims[i]->state =3D RTE_EVENT_TIMER_ARMED;
> +		/* RELEASE ordering guarantees the adapter specific value
> +		 * changes observed before the update of state.
> +		 */
> +		__atomic_store_n(&evtims[i]->state,
> RTE_EVENT_TIMER_ARMED,
> +				__ATOMIC_RELEASE);
>  	}
>=20
>  	if (i < nb_evtims)
> @@ -1132,6 +1145,7 @@ swtim_cancel_burst(const struct
> rte_event_timer_adapter *adapter,
>  	struct rte_timer *timp;
>  	uint64_t opaque;
>  	struct swtim *sw =3D swtim_pmd_priv(adapter);
> +	enum rte_event_timer_state n_state;
>=20
>  #ifdef RTE_LIBRTE_EVENTDEV_DEBUG
>  	/* Check that the service is running. */
> @@ -1143,16 +1157,18 @@ swtim_cancel_burst(const struct
> rte_event_timer_adapter *adapter,
>=20
>  	for (i =3D 0; i < nb_evtims; i++) {
>  		/* Don't modify the event timer state in these cases */
> -		if (evtims[i]->state =3D=3D RTE_EVENT_TIMER_CANCELED) {
> +		/* ACQUIRE ordering guarantees the access of
> implementation
> +		 * specific opague data under the correct state.
> +		 */
> +		n_state =3D __atomic_load_n(&evtims[i]->state,
> __ATOMIC_ACQUIRE);
> +		if (n_state =3D=3D RTE_EVENT_TIMER_CANCELED) {
>  			rte_errno =3D EALREADY;
>  			break;
> -		} else if (evtims[i]->state !=3D RTE_EVENT_TIMER_ARMED) {
> +		} else if (n_state !=3D RTE_EVENT_TIMER_ARMED) {
>  			rte_errno =3D EINVAL;
>  			break;
>  		}
>=20
> -		rte_smp_rmb();
> -
>  		opaque =3D evtims[i]->impl_opaque[0];
>  		timp =3D (struct rte_timer *)(uintptr_t)opaque;
>  		RTE_ASSERT(timp !=3D NULL);
> @@ -1166,11 +1182,14 @@ swtim_cancel_burst(const struct
> rte_event_timer_adapter *adapter,
>=20
>  		rte_mempool_put(sw->tim_pool, (void **)timp);
>=20
> -		evtims[i]->state =3D RTE_EVENT_TIMER_CANCELED;
> +		__atomic_store_n(&evtims[i]->state,
> RTE_EVENT_TIMER_CANCELED,
> +				__ATOMIC_RELAXED);
>  		evtims[i]->impl_opaque[0] =3D 0;
>  		evtims[i]->impl_opaque[1] =3D 0;

Is that safe to remove impl_opaque cleanup above?

Once the soft timer canceled, the __swtim_arm_burst cannot access these two=
 fields under the RTE_EVENT_TIMER_CANCELED state.
After new timer armed, it refills these two fields in the __swtim_arm_burst=
 thread, which is the only producer of these two fields.
I think the only risk is that the values of these two field might be unknow=
 after swtim_cancel_burst. =20
So it should be safe to remove them if no other thread access them after ca=
nceling the timer.=20

Any comments on this?
If we remove these two instructions, we can also remove the __atomic_thread=
_fence below to save performance penalty.

Thanks,
Phil

> -
> -		rte_smp_wmb();
> +		/* The RELEASE fence make sure the clean up
> +		 * of opaque data observed between threads.
> +		 */
> +		__atomic_thread_fence(__ATOMIC_RELEASE);
>  	}
>=20
>  	return i;
> diff --git a/lib/librte_eventdev/rte_event_timer_adapter.h
> b/lib/librte_eventdev/rte_event_timer_adapter.h
> index d2ebcb0..6f64b90 100644
> --- a/lib/librte_eventdev/rte_event_timer_adapter.h
> +++ b/lib/librte_eventdev/rte_event_timer_adapter.h
> @@ -467,7 +467,7 @@ struct rte_event_timer {
>  	 *  - op: RTE_EVENT_OP_NEW
>  	 *  - event_type: RTE_EVENT_TYPE_TIMER
>  	 */
> -	volatile enum rte_event_timer_state state;
> +	enum rte_event_timer_state state;
>  	/**< State of the event timer. */
>  	uint64_t timeout_ticks;
>  	/**< Expiry timer ticks expressed in number of *timer_ticks_ns*
> from
> --
> 2.7.4