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 201C7A0564; Tue, 24 Mar 2020 11:37:31 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id CFD681C0C7; Tue, 24 Mar 2020 11:37:29 +0100 (CET) Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60069.outbound.protection.outlook.com [40.107.6.69]) by dpdk.org (Postfix) with ESMTP id 2B85A1C0C9 for ; Tue, 24 Mar 2020 11:37:28 +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=F8yA/GS+0zx3PI2yrig6tlMTODzZcfikpSgMG6zzb70=; b=QbiKoPfQnVvDRq2188SuWiNI1kkD16WiDA/YvQ3Ln5OZIzcB6i2lvYuEvj2AqmzCRxE2pb2O7/3glhBYMGpYWK6cKscRc/zhWi7nSnVlanIK/IgsFwDAUKbbuUhKy5cQ7ZG3Jmy9Csqofyx3tzhBh2fLocKAncC0OEv/ndUbjCY= Received: from DB6PR0402CA0022.eurprd04.prod.outlook.com (2603:10a6:4:91::32) by VI1PR08MB3663.eurprd08.prod.outlook.com (2603:10a6:803:85::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2835.20; Tue, 24 Mar 2020 10:37:26 +0000 Received: from DB5EUR03FT012.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:91:cafe::9b) by DB6PR0402CA0022.outlook.office365.com (2603:10a6:4:91::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2835.18 via Frontend Transport; Tue, 24 Mar 2020 10:37:26 +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 DB5EUR03FT012.mail.protection.outlook.com (10.152.20.161) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2814.13 via Frontend Transport; Tue, 24 Mar 2020 10:37:26 +0000 Received: ("Tessian outbound 0e34ea672d09:v48"); Tue, 24 Mar 2020 10:37:26 +0000 X-CR-MTA-TID: 64aa7808 Received: from 56a33467d5bd.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id AD6D460B-8132-4493-8B2B-9823B7BEAD4F.1; Tue, 24 Mar 2020 10:37:21 +0000 Received: from EUR02-VE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 56a33467d5bd.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 24 Mar 2020 10:37:21 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=keIZQyoFD0v+4qauDgCiB1DGJOWmwYFwdGZlMaYfYaoiuivI7cWZ9mOddqKAC94Wj2vWpEHT7B7AZtErhDIedYmFW1xLRUc3hgJhKnZGKe85r/x8lJTERB/UpfnG8ycZ4+/xq+UfSj2vVm81FeZXyu3O1G6GqCw7CDrNziHy7E91fGqgMhv4zeDdY0wFplm/JNli9vD+YDuXjvMXYH4l8a/VJYSWRj5gwmekd58OxfJF9rndAQhRY3xx18j1broorD4ooQR+/g5FbyTFioV5oYRge180exsDKlJOAIhP5V4VsfJqm2vJg/+AoWm71Dw/UNpErY4RxbmwYanLKcRMaA== 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=F8yA/GS+0zx3PI2yrig6tlMTODzZcfikpSgMG6zzb70=; b=KZFW82pcWWq8kGRZYZxsE8OP6ufRiSXIErNh1ED06BIaMKjb8TuiyuAdAJOnM0OpbiAKZMztm49+cwfMZyxaQrrbQ55b3287alrmKcUDxEx0vAFBJXcO7DTDTK832Lzh+iHIYnsN+WpBAjNUf0XmgPdlXhEjXs4fd8TVUefaI9kvFr4Fxsk5wdzskL37zxdMKpjuN0Z4dzEWR6uNRXhRv50mo61Rj2m0sBMtiTEiJAPFxk9Px0DaKOxqhFb3YR70vckZcM5ZyeJrfLqYQjBUYeHKb1E5mEyIx8YpoT+nl540VefZE0k9RdsD1rsnTru3H6KBDkjCKvai+7KUBKZ3AQ== 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=F8yA/GS+0zx3PI2yrig6tlMTODzZcfikpSgMG6zzb70=; b=QbiKoPfQnVvDRq2188SuWiNI1kkD16WiDA/YvQ3Ln5OZIzcB6i2lvYuEvj2AqmzCRxE2pb2O7/3glhBYMGpYWK6cKscRc/zhWi7nSnVlanIK/IgsFwDAUKbbuUhKy5cQ7ZG3Jmy9Csqofyx3tzhBh2fLocKAncC0OEv/ndUbjCY= Received: from VE1PR08MB4640.eurprd08.prod.outlook.com (10.255.27.75) by VE1PR08MB5039.eurprd08.prod.outlook.com (10.255.159.153) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2835.20; Tue, 24 Mar 2020 10:37:18 +0000 Received: from VE1PR08MB4640.eurprd08.prod.outlook.com ([fe80::7df3:e3c8:54f7:57c2]) by VE1PR08MB4640.eurprd08.prod.outlook.com ([fe80::7df3:e3c8:54f7:57c2%6]) with mapi id 15.20.2835.021; Tue, 24 Mar 2020 10:37:18 +0000 From: Phil Yang To: "Ananyev, Konstantin" , Honnappa Nagarahalli , "thomas@monjalon.net" , "Van Haaren, Harry" , "stephen@networkplumber.org" , "maxime.coquelin@redhat.com" , "dev@dpdk.org" , "Richardson, Bruce" CC: "david.marchand@redhat.com" , "jerinj@marvell.com" , "hemant.agrawal@nxp.com" , Gavin Hu , Ruifeng Wang , Joyce Kong , nd , nd , nd Thread-Topic: [PATCH v3 06/12] ipsec: optimize with c11 atomic for sa outbound sqn update Thread-Index: AQHWAUOu42jzlX7hWEmw28niYBSJr6hWiikAgAADAgCAAO2asA== Date: Tue, 24 Mar 2020 10:37:18 +0000 Message-ID: References: <1583999071-22872-1-git-send-email-phil.yang@arm.com> <1584407863-774-1-git-send-email-phil.yang@arm.com> <1584407863-774-7-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: bed998f4-bdd0-46ce-8d08-b61294ac0f51.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: 75409927-4632-4c2a-a896-08d7cfdf5842 x-ms-traffictypediagnostic: VE1PR08MB5039:|VE1PR08MB5039:|VI1PR08MB3663: 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:9508;OLM:9508; x-forefront-prvs: 03524FBD26 X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(4636009)(39850400004)(366004)(346002)(376002)(396003)(136003)(33656002)(8676002)(52536014)(7416002)(6506007)(9686003)(81156014)(5660300002)(26005)(86362001)(81166006)(71200400001)(55236004)(8936002)(7696005)(66946007)(54906003)(76116006)(4326008)(55016002)(110136005)(66476007)(64756008)(66556008)(2906002)(316002)(66446008)(478600001)(186003)(15650500001)(921003)(1121003); DIR:OUT; SFP:1101; SCL:1; SRVR:VE1PR08MB5039; H:VE1PR08MB4640.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; 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: t5bHUP+iVZiRqoikiJsDSBFeYRUkoJX8UCgqM2/MYjBZcP334F3/A5ku3TLy7wf6CYnB9MyKH1zfrAvtK+Wh4XhrKtA0arC6uhmzL6Mt4lNUY9KyWCqmF9XtnNiTELanbziqodmi1OBrbMgONmnlUD2G0pQx5kzxpU3oO4YlMDzEiYefbiwDNUQ7aj2mmzWgQLtNONUb9z0P2uiX0G5C2SvLpWlfzm3uYZj42IxhoJZ5SLrAKu34mLjYIMwFjALCaMsHjSBfyRytPdIjBk/kmYtNaoQJ+jF3Ca9eyUhy48eRKWwRzR+e5mka5U9JeJFyc/EQIQc6ywg6LAJ4EowoLXIADJBXFqhq8H06M7hlAecAF2sJi2WxXTrbnIrrGdYS/YUA1d9n8PBHpWY0ptba/Lzzbpm+GJah1jW9iBkUZAQpYfDJwdOjut1nhS3rCmhU4ipVO90l1o0AHa840BIniXOg7fjoHEj0/Fpw/ND4rrfcWYYGXXZ4OcjBdMxBSJJp x-ms-exchange-antispam-messagedata: EH2GoUIafWZ3jy6WAVmfwIUV6pM2UwhdCSu430szHfriXbeXlcIOnkCjipZO+YwVF5mdO+k2jVeb8MUO+4UcnNCs+Qz0lfHG+LkrtmM3tAF2CJsvwUdlC4rhDX6tP7Qialq0GlRIxltaRJYiczS/Tg== Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB5039 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Phil.Yang@arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT012.eop-EUR03.prod.protection.outlook.com X-Forefront-Antispam-Report: CIP:63.35.35.123; IPV:CAL; SCL:-1; CTRY:IE; EFV:NLI; SFV:NSPM; SFS:(10009020)(4636009)(396003)(136003)(376002)(346002)(39860400002)(46966005)(86362001)(33656002)(8936002)(47076004)(478600001)(356004)(8676002)(54906003)(70586007)(81156014)(70206006)(81166006)(26826003)(26005)(7696005)(52536014)(15650500001)(6506007)(4326008)(186003)(55016002)(2906002)(9686003)(336012)(110136005)(5660300002)(316002)(921003)(1121003); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR08MB3663; H:64aa7808-outbound-1.mta.getcheckrecipient.com; FPR:; SPF:Pass; LANG:en; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; X-MS-Office365-Filtering-Correlation-Id-Prvs: 4b139088-e333-47ce-6066-08d7cfdf53bf X-Forefront-PRVS: 03524FBD26 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SkMLht1AT5EjoRZImf/iN1HhObOgG/9zKckof/W2ZddIStDbytBRt1Ruk+7qrKc4SdjIqewyog7X1CUcqtm0IBivDJ9mUFYmFXlBvQqxp9djSk85yg4swHXH3uUMZSyhuC0f8dJNqDJDth0GMUfLAV3GKFQ+NMQB+z86dRLE7F58AfA1451k2FcTjqcuqClaYcPDSds08thexUyd9UibcfJ1kocQT03a8MLVHdqAAH6BLvTYmrK0tPzuEsvG2Xi7RL2SmODYUtrdjBL4wYUPIFuaVB+2UG4MJNteNOfKA7If8HYNCFp3X+CKF/kclb3kNE5eBjEDjpdeZC6Uj/rIPQoRWBhGO5EyyBOmt3MlHnnUluS/LMEZzwguXixJlSbif/Sbj9pwJmvEpchNxV2wliAEOLykWpPLhrdEWSZTQJNA7P+Mgje3t78F+LTDGWG/GHD+1mSnxi+SWYKbO4rcUKzCg2PiEJLFMkCVI9y/qhHdfBG7IoR5kblG7aVScJHSZPSbL/s4eNgps6ftrRDv1rOevY7TV/ou8/eydINBBjl6Typk0Jaav/4SD0wekYYU X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Mar 2020 10:37:26.1574 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 75409927-4632-4c2a-a896-08d7cfdf5842 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: VI1PR08MB3663 Subject: Re: [dpdk-dev] [PATCH v3 06/12] ipsec: optimize with c11 atomic for sa outbound sqn 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" Hi Konstantin, > > > > > Subject: RE: [PATCH v3 06/12] ipsec: optimize with c11 atomic for sa > outbound > > > sqn update > > > > > > Hi Phil, > > > > > > > > > > > For SA outbound packets, rte_atomic64_add_return is used to > generate > > > > SQN atomically. This introduced an unnecessary full barrier by call= ing > > > > the '__sync' builtin implemented rte_atomic_XX API on aarch64. This > > > > patch optimized it with c11 atomic and eliminated the expensive > > > > barrier for aarch64. > > > > > > > > Signed-off-by: Phil Yang > > > > Reviewed-by: Ruifeng Wang > > > > Reviewed-by: Gavin Hu > > > > --- > > > > lib/librte_ipsec/ipsec_sqn.h | 3 ++- > > > > lib/librte_ipsec/sa.h | 2 +- > > > > 2 files changed, 3 insertions(+), 2 deletions(-) > > > > > > > > diff --git a/lib/librte_ipsec/ipsec_sqn.h > > > > b/lib/librte_ipsec/ipsec_sqn.h index 0c2f76a..e884af7 100644 > > > > --- a/lib/librte_ipsec/ipsec_sqn.h > > > > +++ b/lib/librte_ipsec/ipsec_sqn.h > > > > @@ -128,7 +128,8 @@ esn_outb_update_sqn(struct rte_ipsec_sa *sa, > > > > uint32_t *num) > > > > > > > > n =3D *num; > > > > if (SQN_ATOMIC(sa)) > > > > - sqn =3D (uint64_t)rte_atomic64_add_return(&sa- > > > >sqn.outb.atom, n); > > > > + sqn =3D __atomic_add_fetch(&sa->sqn.outb.atom, n, > > > > + __ATOMIC_RELAXED); > > > > > > One generic thing to note: > > > clang for i686 in some cases will generate a proper function call for= 64-bit > > > __atomic builtins (gcc seems to always generate cmpxchng8b for such > cases). > > > Does anyone consider it as a potential problem? > > > It probably not a big deal, but would like to know broader opinion. > > I had looked at this some time back for GCC. The function call is gener= ated > only if the underlying platform does not support the atomic > > instructions for the operand size. Otherwise, gcc generates the instruc= tions > directly. > > I would think the behavior would be the same for clang. >=20 > From what I see not really. > As an example: >=20 > $ cat tatm11.c > #include >=20 > struct x { > uint64_t v __attribute__((aligned(8))); > }; >=20 > uint64_t > ffxadd1(struct x *x, uint32_t n, uint32_t m) > { > return __atomic_add_fetch(&x->v, n, __ATOMIC_RELAXED); > } >=20 > uint64_t > ffxadd11(uint64_t *v, uint32_t n, uint32_t m) > { > return __atomic_add_fetch(v, n, __ATOMIC_RELAXED); > } >=20 > gcc for i686 will generate code with cmpxchng8b for both cases. > clang will generate cmpxchng8b for ffxadd1() - when data is explicitly 8B > aligned, > but will emit a function call for ffxadd11(). I guess your testbed is an i386 platform. However, what I see here is diff= erent. Testbed i686: Ubuntu 18.04.4 LTS/GCC 8.3/ Clang 9.0.0-2 Both Clang and GCC for i686 generate code with xadd for these two cases. Testbed i386: Ubuntu 16.04 LTS (Installed libatomic)/GCC 5.4.0/ Clang 4.0.= 0 GCC will generate code with cmpxchng8b for both cases. Clang generated code emits a function call for both cases. Thanks, Phil >=20 > > > > > > > > > else { > > > > sqn =3D sa->sqn.outb.raw + n; > > > > sa->sqn.outb.raw =3D sqn; > > > > diff --git a/lib/librte_ipsec/sa.h b/lib/librte_ipsec/sa.h index > > > > d22451b..cab9a2e 100644 > > > > --- a/lib/librte_ipsec/sa.h > > > > +++ b/lib/librte_ipsec/sa.h > > > > @@ -120,7 +120,7 @@ struct rte_ipsec_sa { > > > > */ > > > > union { > > > > union { > > > > - rte_atomic64_t atom; > > > > + uint64_t atom; > > > > uint64_t raw; > > > > } outb; > > > > > > If we don't need rte_atomic64 here anymore, then I think we can > collapse the > > > union to just: > > > uint64_t outb; > > > > > > > struct { > > > > -- > > > > 2.7.4