From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8B8DDA00C2; Fri, 24 Apr 2020 09:27:17 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 255251C1CD; Fri, 24 Apr 2020 09:27:17 +0200 (CEST) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2045.outbound.protection.outlook.com [40.107.20.45]) by dpdk.org (Postfix) with ESMTP id DB65E1C1CB for ; Fri, 24 Apr 2020 09:27:14 +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=PHQmjFnCZTyvXoKiEfWEIdcCypYeL2Eecw1horOsM7A=; b=MnrUTTs61vc07p4nZx1HXXn3NG28rqdu1hZdnIRyaGgPbgwaC/v6iHWppGkadOwPjoapdoaD//mkCIaJTBenEVheYFVzMBnJJTP3E0iApSLQVCS/EyQQ55xxO6oAynHwb5a+PEmpsK4tfDX+wDIzTVAPq+cO1l7a6N014h9/aiM= Received: from AM6PR05CA0033.eurprd05.prod.outlook.com (2603:10a6:20b:2e::46) by VI1PR08MB3264.eurprd08.prod.outlook.com (2603:10a6:803:4b::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2921.27; Fri, 24 Apr 2020 07:27:11 +0000 Received: from AM5EUR03FT034.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:2e:cafe::9b) by AM6PR05CA0033.outlook.office365.com (2603:10a6:20b:2e::46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2937.13 via Frontend Transport; Fri, 24 Apr 2020 07:27:11 +0000 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 AM5EUR03FT034.mail.protection.outlook.com (10.152.16.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2937.19 via Frontend Transport; Fri, 24 Apr 2020 07:27:11 +0000 Received: ("Tessian outbound 7626dd1b3605:v53"); Fri, 24 Apr 2020 07:27:10 +0000 X-CR-MTA-TID: 64aa7808 Received: from 46de52ed8768.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 3F2108AE-E778-40F0-9236-E4206D32C636.1; Fri, 24 Apr 2020 07:27:05 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 46de52ed8768.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 24 Apr 2020 07:27:05 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AlySwEUJu/l94PvFFRls/+kpAHzjEGvF4o6jzlFa9z5Rqf1TyvuPjwSyRsALKW4oSW0UtBhHfv3msRm7RTFQMDs61g08IlwNmt2teKnIf1gvFPwsk6yHwmAf7ljlpHtRXqsrNHT3E85CVuwp5ABl6mIQa456vFOVHoA3kBQZ+E2L+SOD8/TACL1K8DQpN5YTEz3XlqcB85yxytMIeEC9vZJFsK8FXXGaD1fQasBNJVHCMPZiWqvo36ziKNN/NIyz/cdXjUeZIJLMVYjGQiP/ct+mbZCImj205Rl7f/SM1+jDJFCD2i6Tcmm5/Fe8pU1ysGZ4VwT5Mq389ydXkWKE0g== 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=PHQmjFnCZTyvXoKiEfWEIdcCypYeL2Eecw1horOsM7A=; b=oTN8xUygwgji3tBnASN/78k6ImOhV6QNlkWzZSU0IobFNWrKcXyC9kdOZHaBvGrHdJTb9yzfAWaO3s00jZ2XZR5ZoUgwt8gJaPz+Vr/8xuvfgi4iDpV4Xura4hwZHc5RC+ljzaC993RfTNlKIbNr9nJyQ/ihEAO/5Lt9CvvbJbYRtJY9vZw3jjFVRlvycIpvL1m/uFyLYqm5+bkPAUnrwyi9VvBu8DeizUkXCbl03jlCQfu3xfBc8zY0NVz63KCKLi750x1206rGOh+2wh17dPWWHReoR2p1IgM/Jj5nqLdpJQqQ3RuIy93bx2HCO1n5k2kz7dr8yHx5kj/KujZGnQ== 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=PHQmjFnCZTyvXoKiEfWEIdcCypYeL2Eecw1horOsM7A=; b=MnrUTTs61vc07p4nZx1HXXn3NG28rqdu1hZdnIRyaGgPbgwaC/v6iHWppGkadOwPjoapdoaD//mkCIaJTBenEVheYFVzMBnJJTP3E0iApSLQVCS/EyQQ55xxO6oAynHwb5a+PEmpsK4tfDX+wDIzTVAPq+cO1l7a6N014h9/aiM= Received: from VE1PR08MB4640.eurprd08.prod.outlook.com (2603:10a6:802:b2::11) by VE1PR08MB5054.eurprd08.prod.outlook.com (2603:10a6:803:10d::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2921.29; Fri, 24 Apr 2020 07:27:02 +0000 Received: from VE1PR08MB4640.eurprd08.prod.outlook.com ([fe80::785b:54ca:be80:7b66]) by VE1PR08MB4640.eurprd08.prod.outlook.com ([fe80::785b:54ca:be80:7b66%2]) with mapi id 15.20.2921.030; Fri, 24 Apr 2020 07:27:02 +0000 From: Phil Yang To: "Carrillo, Erik G" , Honnappa Nagarahalli , "rsanford@akamai.com" , "dev@dpdk.org" CC: "thomas@monjalon.net" , "david.marchand@redhat.com" , "Ananyev, Konstantin" , "jerinj@marvell.com" , "hemant.agrawal@nxp.com" , Gavin Hu , nd , nd , nd Thread-Topic: [PATCH v2] lib/timer: relax barrier for status update Thread-Index: AQHWGaqrEFDqdFXMEkS2uYcG5rNr+aiHe3kAgABkI5A= Date: Fri, 24 Apr 2020 07:27:02 +0000 Message-ID: References: <1582526539-14360-2-git-send-email-phil.yang@arm.com> <1587398752-9345-1-git-send-email-phil.yang@arm.com> In-Reply-To: Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ts-tracking-id: 6585f38f-318d-459b-80f3-fa6abf4bee60.0 x-checkrecipientchecked: true Authentication-Results-Original: spf=none (sender IP is ) smtp.mailfrom=Phil.Yang@arm.com; x-originating-ip: [113.29.88.7] x-ms-publictraffictype: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 8278c5e4-70e6-413a-7a44-08d7e820e728 x-ms-traffictypediagnostic: VE1PR08MB5054:|VE1PR08MB5054:|VI1PR08MB3264: x-ld-processed: f34e5979-57d9-4aaa-ad4d-b122a662184d,ExtAddr x-ms-exchange-transport-forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true nodisclaimer: true x-ms-oob-tlc-oobclassifiers: OLM:8882;OLM:8882; x-forefront-prvs: 03838E948C 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:(10009020)(4636009)(366004)(39860400002)(396003)(346002)(376002)(136003)(316002)(53546011)(6506007)(66946007)(55236004)(8936002)(2906002)(7696005)(66446008)(64756008)(54906003)(8676002)(66556008)(66476007)(81156014)(9686003)(15650500001)(76116006)(26005)(55016002)(4326008)(966005)(5660300002)(186003)(52536014)(71200400001)(33656002)(478600001)(110136005)(86362001); DIR:OUT; SFP:1101; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: 313XE1/ZKzaH9MtygElKvYY4zM4boZSSZl/445aMz+YeoPNyqQXLsvXHBHVYEA03BDHMGef0TDioBzeOBNce0zUhZxONFwgXnN4BMR2iyEhppZra/mp7d6xFo5QnZ8sOPAoC4StPBbgCobyNBxVER2J5/KstbGTOjD8Pl0aC5K1O3f6na4tlDJIlOqDq2lipxXsm8B+MphEpvennjDbYI8hnvTvm26oMrm8Kt3i9yPVEnybnrK9DYL86Ag4wJMBoLx68JAfzCBAakjoaokCxuvnAt+KYTMbXqxspsDPzQTYM44RkqSdvQ1+15Ms+S0dlvUQkyl8j2RPn3DmFfgS/oKRG3jcS7TjFtWeZNstBiNDs6k/+u4b9EqUiQSVpTn6FmuFhS92264jefnl0gBmwCVUD+JWI7zHoyxrIk7Pwt2s0bBHHZnYYa70+0vOZsdUzt+OxU+GcdyMd1AfSvB51bRi9ZT9NK50sW2vwdGQa5hR/lSKYt8McSH2VKShixqxPNCiE+aB+MG1BPC2iN7tsZw== x-ms-exchange-antispam-messagedata: zrOUonGiUFGslixhJ4oFlrG83gUf2VXWt90852y8qovI2Bvltoi+1AhAtgl64OqnswR9J4mNnD74UVSv7u0jz+d9VlZo2GhWjUZFwO/6NxcYT6/ChsO6rEawNX3B6cezmuszz7AAN75Bxf4FmI78Sw== Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB5054 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Phil.Yang@arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT034.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:(10009020)(4636009)(39860400002)(376002)(136003)(346002)(396003)(46966005)(52536014)(55016002)(82310400002)(9686003)(316002)(70206006)(86362001)(54906003)(36906005)(186003)(53546011)(70586007)(81156014)(110136005)(5660300002)(7696005)(8936002)(336012)(6506007)(26005)(8676002)(82740400003)(966005)(47076004)(15650500001)(81166007)(33656002)(478600001)(4326008)(2906002)(356005); DIR:OUT; SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: a4add030-c69f-48ca-ab2c-08d7e820e21f X-Forefront-PRVS: 03838E948C X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ePrilA32Rev8dF4RoZjN8DCYw7Ot5e5C5indQJFQ2NxyhbY6dGjo929vjRQ0fFpWHAZUpZ1xI028wrvCA4aEfohKnDuc3vmot54Zjj/uo7tF1yCWW+QkjOGZT14dgYHl0AbM2h1B6nKmSmqKkhQlBDO27fOcBqQiPKT53ZXC1YRNjBXeTBiF5L1tbb2uJOuCfmjDltw4+Fqh+xMIAku40rB4WZzSDuw/0l0l0ryo88EBDcEHvGIJ4MPr8z+1H4/F5lukWJxQ8+GRGChqRy2l+qQydby0sn32YcDQgjb9WNrKWfMHA2rhZIGADLU0uTteI7vyskgnnM57u4UfFeaL7IFrUArwPX3aKZZfpPXuYgRiHhW+a9R9xKpsBsyQKYTSydJEpPImhcw6FSKESxWOmw6w5josvMOhB0Adm05Vez9jOgen1Egdxe0Ra+ho7ze3G+3HkT3+roxp/h7FDy4Ld9S9Vtm4rjIpdE0lH2ZMTw0p53IB0xsr7drR6hKUqNLa367nBshpRg+sj1TnLWzmMttsKYixX6FxLp2557U2eT2DiSry++sv2mmTYeXuvmMZGdta7pdq6YHfx8f8PsV3QXTR78Aoigtd13dNF1QeUFQ= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2020 07:27:11.0242 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8278c5e4-70e6-413a-7a44-08d7e820e728 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: VI1PR08MB3264 Subject: Re: [dpdk-dev] [PATCH v2] lib/timer: relax barrier for status update 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" > -----Original Message----- > From: Carrillo, Erik G > Sent: Friday, April 24, 2020 9:27 AM > To: Honnappa Nagarahalli ; Phil Yang > ; rsanford@akamai.com; dev@dpdk.org > Cc: thomas@monjalon.net; david.marchand@redhat.com; Ananyev, > Konstantin ; jerinj@marvell.com; > hemant.agrawal@nxp.com; Gavin Hu ; nd > ; nd > Subject: RE: [PATCH v2] lib/timer: relax barrier for status update >=20 > Hi Honnappa, >=20 > > -----Original Message----- > > From: Honnappa Nagarahalli > > Sent: Thursday, April 23, 2020 3:06 PM > > To: Phil Yang ; Carrillo, Erik G > > ; rsanford@akamai.com; dev@dpdk.org > > Cc: thomas@monjalon.net; david.marchand@redhat.com; Ananyev, > > Konstantin ; jerinj@marvell.com; > > hemant.agrawal@nxp.com; Gavin Hu ; nd > > ; Honnappa Nagarahalli ; > > nd > > Subject: RE: [PATCH v2] lib/timer: relax barrier for status update > > > > Hi Erik, > > > > > Subject: [PATCH v2] lib/timer: relax barrier for status update > > > > > > Volatile has no ordering semantics. The rte_timer structure defines > > > timer status as a volatile variable and uses the rte_r/wmb barrier to > > > guarantee inter-thread visibility. > > > > > > This patch optimized the volatile operation with c11 atomic operation= s > > > and one-way barrier to save the performance penalty. According to the > > > timer_perf_autotest benchmarking results, this patch can uplift > > > 10%~16% timer appending performance, 3%~20% timer resetting > > > performance and 45% timer callbacks scheduling performance on aarch64 > > > and no loss in performance for x86. > > > > > > Suggested-by: Honnappa Nagarahalli > > > Signed-off-by: Phil Yang > > > Reviewed-by: Gavin Hu > > > > > > --- > > > This patch depends on patch: > > > http://patchwork.dpdk.org/patch/65997/ > > > > > > v2: > > > 1. Changed the memory ordering comment in timer_set_config_state. > > > 2. It is still using built-ins as the wrapper functions for C11 > > > built-ins are not defined yet. > > It is too late to get the wrapper functions done for 20.05. It was deci= ded in > > yesterday's tech board meeting to go ahead with C11 atomic built-ins (s= ince > > there is lot of code in DPDK that uses C11 built-ins). If there are no = further > > comments, can you please provide your ack? > > >=20 > Ok, thanks for letting me know. Based on that decision, I've taken anot= her > look > and done some testing and it looks good to me. I've made one comment in- > line > below and acked it. >=20 > <... snipped ...> >=20 > > > @@ -258,9 +257,15 @@ timer_set_config_state(struct rte_timer *tim, > > > * mark it atomically as being configured */ > > > status.state =3D RTE_TIMER_CONFIG; > > > status.owner =3D (int16_t)lcore_id; > > > - success =3D rte_atomic32_cmpset(&tim->status.u32, > > > - prev_status.u32, > > > - status.u32); > > > + /* CONFIG states are acting as locked states. If the > > > + * timer is in CONFIG state, the state cannot be changed > > > + * by other threads. So, we should use ACQUIRE here. > > > + */ > > > + success =3D __atomic_compare_exchange_n(&tim- > > >status.u32, > > > + &prev_status.u32, > > > + status.u32, 0, > > > + __ATOMIC_ACQUIRE, > > > + __ATOMIC_RELAXED); > > > } > > > > > > ret_prev_status->u32 =3D prev_status.u32; @@ -279,20 +284,27 @@ > > > timer_set_running_state(struct rte_timer *tim) > > > > > > /* wait that the timer is in correct status before update, > > > * and mark it as running */ > > > - while (success =3D=3D 0) { > > > - prev_status.u32 =3D tim->status.u32; > > > + prev_status.u32 =3D __atomic_load_n(&tim->status.u32, > > > __ATOMIC_RELAXED); > > > > > > + while (success =3D=3D 0) { > > > /* timer is not pending anymore */ > > > if (prev_status.state !=3D RTE_TIMER_PENDING) > > > return -1; > > > > > > /* here, we know that timer is stopped or pending, >=20 > We know that the timer will be pending at this point... Since we're corre= cting > the comment below, we can correct this part too. >=20 > With that change: > Acked-by: Erik Gabriel Carrillo Thanks Erik. Updated in v3. Thanks, Phil=20 >=20 > > > - * mark it atomically as being configured */ > > > + * mark it atomically as being running > > > + */ > > > status.state =3D RTE_TIMER_RUNNING; > > > status.owner =3D (int16_t)lcore_id; > > > - success =3D rte_atomic32_cmpset(&tim->status.u32, > > > - prev_status.u32, > > > - status.u32); > > > + /* RUNNING states are acting as locked states. If the > > > + * timer is in RUNNING state, the state cannot be changed > > > + * by other threads. So, we should use ACQUIRE here. > > > + */ > > > + success =3D __atomic_compare_exchange_n(&tim- > > >status.u32, > > > + &prev_status.u32, > > > + status.u32, 0, > > > + __ATOMIC_ACQUIRE, > > > + __ATOMIC_RELAXED); > > > } > > > > > > return 0; >=20 > Thanks, > Erik