From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,URIBL_SBL,URIBL_SBL_A autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EEFABC43613 for ; Mon, 24 Jun 2019 15:43:58 +0000 (UTC) Received: from dpdk.org (dpdk.org [92.243.14.124]) by mail.kernel.org (Postfix) with ESMTP id 808052054F for ; Mon, 24 Jun 2019 15:43:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=armh.onmicrosoft.com header.i=@armh.onmicrosoft.com header.b="Q+ngOH/r" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 808052054F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dev-bounces@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 720FE1BB42; Mon, 24 Jun 2019 17:43:57 +0200 (CEST) Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50086.outbound.protection.outlook.com [40.107.5.86]) by dpdk.org (Postfix) with ESMTP id 409381B9FC for ; Mon, 24 Jun 2019 17:43:56 +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=wjwCQQieOPAqjh4ZrtARipNIkjiULiThNHzwyWO+Q4Y=; b=Q+ngOH/rqkdKqB6kEI5eGufp7zLWeI913I0Dyc5UmcttHoJLJmARooyrADr/z9z+cwv6oEl0+eXz8iIVt532c6iaRjYJjfW+3f5b8I5NpACVO6i0TBKwy6NChAbpxtYT/8BAijc66T6mRevtzgQ6yhxEggXjEGN08ztzHWByY64= Received: from VE1PR08MB4640.eurprd08.prod.outlook.com (10.255.27.75) by VE1PR08MB5054.eurprd08.prod.outlook.com (10.255.159.219) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2008.16; Mon, 24 Jun 2019 15:43:54 +0000 Received: from VE1PR08MB4640.eurprd08.prod.outlook.com ([fe80::d411:12c1:65b9:874f]) by VE1PR08MB4640.eurprd08.prod.outlook.com ([fe80::d411:12c1:65b9:874f%3]) with mapi id 15.20.2008.014; Mon, 24 Jun 2019 15:43:54 +0000 From: "Phil Yang (Arm Technology China)" To: "jerinj@marvell.com" , "dev@dpdk.org" CC: "thomas@monjalon.net" , "hemant.agrawal@nxp.com" , Honnappa Nagarahalli , "Gavin Hu (Arm Technology China)" , nd , "gage.eads@intel.com" , nd Thread-Topic: [PATCH v2 1/3] eal/arm64: add 128-bit atomic compare exchange Thread-Index: AdUqVpABcLyZ0lTxQfaR61ir9fMMZQAS9vkA Date: Mon, 24 Jun 2019 15:43:54 +0000 Message-ID: References: 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: c5a52954-45ce-4fb3-9a57-77d023213fe9.1 x-checkrecipientchecked: true authentication-results: 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-correlation-id: 13b61f87-6437-4e40-38af-08d6f8bac3a2 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(4618075)(2017052603328)(7193020); SRVR:VE1PR08MB5054; x-ms-traffictypediagnostic: VE1PR08MB5054: x-ms-exchange-purlcount: 1 x-ld-processed: f34e5979-57d9-4aaa-ad4d-b122a662184d,ExtAddr nodisclaimer: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:8273; x-forefront-prvs: 007814487B x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(376002)(366004)(346002)(39860400002)(136003)(396003)(13464003)(189003)(199004)(256004)(52536014)(14444005)(53546011)(6506007)(7696005)(478600001)(55236004)(76176011)(9686003)(6306002)(316002)(7736002)(8676002)(74316002)(55016002)(305945005)(76116006)(66446008)(64756008)(99286004)(186003)(66556008)(66066001)(5660300002)(66946007)(102836004)(86362001)(73956011)(81156014)(66476007)(26005)(2906002)(8936002)(2501003)(25786009)(4326008)(71190400001)(81166006)(229853002)(33656002)(14454004)(966005)(72206003)(110136005)(6436002)(446003)(54906003)(53936002)(11346002)(6116002)(3846002)(6246003)(68736007)(476003)(486006)(71200400001); DIR:OUT; SFP:1101; SCL:1; SRVR:VE1PR08MB5054; H:VE1PR08MB4640.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: f+ucnhrJohlBkl/lPKOqf1G4ABaeW3C2gclv/Suv9wF0rzWGJc68g/O19GS0rrqN8ZVNIg/B0rkUMnbY1sNm8XiuopE+7ydOiPLW9II4otaGtACry8HnQfOKcyms9FPafRO9o2rVLDDk9HNGj1wRDE3gZfgznTuz1Q2wNi4minRbRdnxw8woFs5KWR3QhmRHoGpWlCukfmWACS2oLtfWu13H4RiUuuJ/zpyXZ2nOJwX2zqxAQs5QF1egr2WCas4HQ19hMIm4Otq8PyM8DtzhF99DoNt3hFm0FBaRCklGZZZgz4/I2kyxdETx+sP2+oUJyIcEds5iASKuWgyA1unWpLxDdMfCt6KUB/En7lI6SYGIX2Hj1ckWq0pLXrAOjthqFXB1TcdsZUjsgTGPLIibTW/BHsAJllpE92MaijqYZM0= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-Network-Message-Id: 13b61f87-6437-4e40-38af-08d6f8bac3a2 X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Jun 2019 15:43:54.7578 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: Phil.Yang@arm.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB5054 Subject: Re: [dpdk-dev] [PATCH v2 1/3] eal/arm64: add 128-bit atomic compare exchange 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 Jerin, Thank you for your comments. I will modify these in the next version. Thanks, Phil > -----Original Message----- > From: Jerin Jacob Kollanukkaran > Sent: Monday, June 24, 2019 2:41 PM > To: Phil Yang (Arm Technology China) ; dev@dpdk.org > Cc: thomas@monjalon.net; hemant.agrawal@nxp.com; Honnappa > Nagarahalli ; Gavin Hu (Arm Technology > China) ; nd ; gage.eads@intel.com > Subject: RE: [PATCH v2 1/3] eal/arm64: add 128-bit atomic compare exchang= e >=20 > > -----Original Message----- > > From: Phil Yang > > Sent: Sunday, June 23, 2019 8:46 AM > > To: dev@dpdk.org > > Cc: thomas@monjalon.net; Jerin Jacob Kollanukkaran > > ; hemant.agrawal@nxp.com; > > Honnappa.Nagarahalli@arm.com; gavin.hu@arm.com; nd@arm.com; > > gage.eads@intel.com > > Subject: [EXT] [PATCH v2 1/3] eal/arm64: add 128-bit atomic compare > > exchange > > > > Add 128-bit atomic compare exchange on aarch64. > > > > Signed-off-by: Phil Yang > > Reviewed-by: Honnappa Nagarahalli > > Tested-by: Honnappa Nagarahalli > > --- > > This patch depends on 'eal/stack: fix 'pointer-sign' warning' > > http://patchwork.dpdk.org/patch/54840/ > > > > + > > +#ifdef __ARM_FEATURE_ATOMICS > > +static inline rte_int128_t > > +__rte_casp(rte_int128_t *dst, rte_int128_t old, rte_int128_t updated, > > +int mo) { >=20 > Better to change to "const int mo". >=20 > > + > > + /* caspX instructions register pair must start from even-numbered > > + * register at operand 1. > > + * So, specify registers for local variables here. > > + */ > > + register uint64_t x0 __asm("x0") =3D (uint64_t)old.val[0]; > > + register uint64_t x1 __asm("x1") =3D (uint64_t)old.val[1]; > > + register uint64_t x2 __asm("x2") =3D (uint64_t)updated.val[0]; > > + register uint64_t x3 __asm("x3") =3D (uint64_t)updated.val[1]; > > + > > + if (mo =3D=3D __ATOMIC_RELAXED) { > > + asm volatile( > > + "casp %[old0], %[old1], %[upd0], %[upd1], > > [%[dst]]" > > + : [old0] "+r" (x0), > > + [old1] "+r" (x1) > > + : [upd0] "r" (x2), > > + [upd1] "r" (x3), > > + [dst] "r" (dst) > > + : "memory"); > > + } else if (mo =3D=3D __ATOMIC_ACQUIRE) { > > + asm volatile( > > + "caspa %[old0], %[old1], %[upd0], %[upd1], > > [%[dst]]" > > + : [old0] "+r" (x0), > > + [old1] "+r" (x1) > > + : [upd0] "r" (x2), > > + [upd1] "r" (x3), > > + [dst] "r" (dst) > > + : "memory"); > > + } else if (mo =3D=3D __ATOMIC_ACQ_REL) { > > + asm volatile( > > + "caspal %[old0], %[old1], %[upd0], %[upd1], > > [%[dst]]" > > + : [old0] "+r" (x0), > > + [old1] "+r" (x1) > > + : [upd0] "r" (x2), > > + [upd1] "r" (x3), > > + [dst] "r" (dst) > > + : "memory"); > > + } else if (mo =3D=3D __ATOMIC_RELEASE) { > > + asm volatile( > > + "caspl %[old0], %[old1], %[upd0], %[upd1], > > [%[dst]]" > > + : [old0] "+r" (x0), > > + [old1] "+r" (x1) > > + : [upd0] "r" (x2), > > + [upd1] "r" (x3), > > + [dst] "r" (dst) > > + : "memory"); >=20 > I think, This duplication code can be avoid with macro and > casp/capsa/casal/caspl as argument. >=20 > > + } else { > > + rte_panic("Invalid memory order\n"); >=20 >=20 > rte_panic should be removed from library. In this case, I think, invalid = mo can > go for strongest barrier. >=20 > > + } > > + > > + old.val[0] =3D x0; > > + old.val[1] =3D x1; > > + > > + return old; > > +} > > +#else > > +static inline rte_int128_t > > +__rte_ldx128(const rte_int128_t *src, int mo) { > > + rte_int128_t ret; > > + if (mo =3D=3D __ATOMIC_ACQUIRE) > > + asm volatile( > > + "ldaxp %0, %1, %2" > > + : "=3D&r" (ret.val[0]), > > + "=3D&r" (ret.val[1]) > > + : "Q" (src->val[0]) > > + : "memory"); > > + else if (mo =3D=3D __ATOMIC_RELAXED) > > + asm volatile( > > + "ldxp %0, %1, %2" > > + : "=3D&r" (ret.val[0]), > > + "=3D&r" (ret.val[1]) > > + : "Q" (src->val[0]) > > + : "memory"); >=20 > Same as above comment. >=20 > > + else > > + rte_panic("Invalid memory order\n"); >=20 > Same as above comment. >=20 > > + > > + return ret; > > +} > > + > > +static inline uint32_t > > +__rte_stx128(rte_int128_t *dst, const rte_int128_t src, int mo) { > > + uint32_t ret; > > + if (mo =3D=3D __ATOMIC_RELEASE) > > + asm volatile( > > + "stlxp %w0, %1, %2, %3" > > + : "=3D&r" (ret) > > + : "r" (src.val[0]), > > + "r" (src.val[1]), > > + "Q" (dst->val[0]) > > + : "memory"); > > + else if (mo =3D=3D __ATOMIC_RELAXED) > > + asm volatile( > > + "stxp %w0, %1, %2, %3" > > + : "=3D&r" (ret) > > + : "r" (src.val[0]), > > + "r" (src.val[1]), > > + "Q" (dst->val[0]) > > + : "memory"); > > + else > > + rte_panic("Invalid memory order\n"); >=20 > Same as above comment. >=20 > > + > > + /* Return 0 on success, 1 on failure */ > > + return ret; > > +} > > +#endif > > + > > +static inline int __rte_experimental > > +rte_atomic128_cmp_exchange(rte_int128_t *dst, > > + rte_int128_t *exp, > > + const rte_int128_t *src, > > + unsigned int weak, > > + int success, > > + int failure) > > +{ > > + // Always do strong CAS >=20 > Remove C++ style code comment.