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 DF7F4A00E6 for ; Fri, 12 Jul 2019 22:08:43 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 665621B9AA; Fri, 12 Jul 2019 22:08:42 +0200 (CEST) Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-eopbgr140077.outbound.protection.outlook.com [40.107.14.77]) by dpdk.org (Postfix) with ESMTP id C32541B9A7 for ; Fri, 12 Jul 2019 22:08:40 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Tydhslhrb2DTzxvArMFLdTHFnEZ4JaAX6VakQxiUF+aH7t/bwI+8ytZGH+aTtXvEXIVvAu2u74ZufxuBOlybvUPTa+mLLGkYrSSoSx133UFjRaSY2+2Cm2O1xBCBYEdYbG7B2nS5HbKiVGVOUZ/WWpsqqltJyCh2wvQtiv/T4W07qqs157uCmvc+jIU/ruq+9GhOVV4DzQts4cmUYeLEMHaqveOS52y1/e1tsxLshdWFVoNK7kzPJHqEZx+1VjPhUYBu2f9Lw8Bcy3xsYaBjPUjLVaIupVfO3uF4BT/GoTlm+U6wfD6TGgoh8zHf4bJ89FVHFhXYVB1wsOS4TKJAkw== 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=s12V3hPG/JmBogJbi6g+80K7F1BYeNlAFLMSs5T9HJQ=; b=e3Opffo6aFdhvgCAUEnB+SPjF+JYwczLp5TVZVkvHDeDiUvDba4R3ZkOpURLKNIXlNpTkwhynQyvr4y1Lj/kAjNmFunw5t4umRESal7I8hEz3EDusPiewA9dO/+H8B7xcjFE6YHGk3kCW2wFYU9poqV0mZb6NIP6uNsyBRtRNyZIXILFT46i4UOmNLArm8lFSeEoxjYh594Fkf1deMszXEdttJRugPV/z1wO71pL1gkQU55VFMd6HsWZaYTuSKAHqUZPcmAjsaqngEfrLHCgR0mJJhg7eEH+CiQ95dYG/exnvRoHi+k3Y2oVcETN/HXu3OQqOOSkqVmp6aY/Cw6Awg== 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=s12V3hPG/JmBogJbi6g+80K7F1BYeNlAFLMSs5T9HJQ=; b=8AbW9XmH2Fs1ue+nZS8rN/2Ld0YqSvhqkhGfUJ3b0PR+k85lIByb8CxHsX0rgFwM5tx/7qzh+spffwUsQcHX4ImDQAUlIjpTIrDGXlUpSx92uJgp5DCVU1VELPIndSHWGQIfjGxrKFLBiWyLw4ftkZwj0/7fIU/9EZjjCzk3EC8= Received: from VE1PR08MB5149.eurprd08.prod.outlook.com (20.179.30.152) by VE1PR08MB5088.eurprd08.prod.outlook.com (20.179.29.210) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2073.14; Fri, 12 Jul 2019 20:08:38 +0000 Received: from VE1PR08MB5149.eurprd08.prod.outlook.com ([fe80::a89e:33:fbda:ed35]) by VE1PR08MB5149.eurprd08.prod.outlook.com ([fe80::a89e:33:fbda:ed35%4]) with mapi id 15.20.2073.012; Fri, 12 Jul 2019 20:08:38 +0000 From: Honnappa Nagarahalli To: "Ruifeng Wang (Arm Technology China)" , "vladimir.medvedkin@intel.com" , "bruce.richardson@intel.com" CC: "dev@dpdk.org" , "Gavin Hu (Arm Technology China)" , nd , "Ruifeng Wang (Arm Technology China)" , Honnappa Nagarahalli , nd Thread-Topic: [PATCH v5 5/6] lib/lpm: data update optimization for v1604 Thread-Index: AQHVOF9ZtEyH1iJnLkKe0gCT+NJaVqbHagkw Date: Fri, 12 Jul 2019 20:08:38 +0000 Message-ID: References: <20190605055451.30473-1-ruifeng.wang@arm.com> <20190712030923.37832-1-ruifeng.wang@arm.com> <20190712030923.37832-6-ruifeng.wang@arm.com> In-Reply-To: <20190712030923.37832-6-ruifeng.wang@arm.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ts-tracking-id: 746d8005-8276-43a8-bbbe-d65f5bf28e9d.0 x-checkrecipientchecked: true authentication-results: spf=none (sender IP is ) smtp.mailfrom=Honnappa.Nagarahalli@arm.com; x-originating-ip: [217.140.111.135] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: a3230d07-c553-4cea-063d-08d70704ba4e x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(4618075)(2017052603328)(7193020); SRVR:VE1PR08MB5088; x-ms-traffictypediagnostic: VE1PR08MB5088: x-microsoft-antispam-prvs: nodisclaimer: True x-ms-oob-tlc-oobclassifiers: OLM:6108; x-forefront-prvs: 00963989E5 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(396003)(136003)(39860400002)(376002)(366004)(346002)(13464003)(189003)(199004)(5660300002)(2906002)(54906003)(81156014)(110136005)(2501003)(478600001)(305945005)(7736002)(3846002)(68736007)(15650500001)(66946007)(66556008)(74316002)(66476007)(66446008)(64756008)(81166006)(316002)(33656002)(52536014)(6116002)(8676002)(229853002)(8936002)(76116006)(11346002)(99286004)(2201001)(7696005)(446003)(476003)(6436002)(53936002)(6506007)(26005)(486006)(53546011)(186003)(66066001)(4326008)(86362001)(102836004)(71200400001)(14454004)(71190400001)(25786009)(6246003)(9686003)(55016002)(14444005)(256004)(76176011); DIR:OUT; SFP:1101; SCL:1; SRVR:VE1PR08MB5088; H:VE1PR08MB5149.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: YNBGg1KZ9KdH7aEFgP6hyXv1ELQw9DFIVYixQTg5A5BvMRHC8iLjdP54tV2BIfO5IQmnevlrkOZOWbhPjolU88Ovae71vn+e09Lo9Ib5ak37vfyF1A7dIwkLI6TwCoS6/83D8EQxYxmkQrrmlzX/QPqzNlxJBCfOpUsWUL97vb5+c5CSJWIxunjPmgNn6/guHPeP8cjn3YZL/XrA0BVH+Nb0aQmX4SjJRMs7z27zVboct27QgqbuOEhjF3bYcQIbLcyHRFTRFcPVguqzMhhxTNOw8DPcuApBGZNN6u5g9FKaKddBzil2KbURht9YC4pNFP4Bs4Llgkw6pPYAOaHMuZMyQvbqujfuj5e2BrLM8kroIaXaoMNGjNepxrId42o63GE5UfAYQ64rb+EQAQ/OIROOc46lOABw/P2dZQQbVSg= 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: a3230d07-c553-4cea-063d-08d70704ba4e X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Jul 2019 20:08:38.0845 (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: Honnappa.Nagarahalli@arm.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB5088 Subject: Re: [dpdk-dev] [PATCH v5 5/6] lib/lpm: data update optimization for v1604 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" IMO, this can be merged into 4/6. > -----Original Message----- > From: Ruifeng Wang > Sent: Thursday, July 11, 2019 10:09 PM > To: vladimir.medvedkin@intel.com; bruce.richardson@intel.com > Cc: dev@dpdk.org; Honnappa Nagarahalli ; > Gavin Hu (Arm Technology China) ; nd ; > Ruifeng Wang (Arm Technology China) > Subject: [PATCH v5 5/6] lib/lpm: data update optimization for v1604 >=20 > The table entries were updated field by field. There were two issues: > 1. bitwise operations are read-modify-write sequences and not atomic, > nor efficient. > 2. the above non-atomic operations causes entries out of synchronization > and inconsistency. > This patch combines the fields into a one-go 32bit entry update to avoid > inconsistency and as a bonus save CPU cycles. >=20 > Suggested-by: Gavin Hu > Signed-off-by: Ruifeng Wang > Reviewed-by: Gavin Hu > --- > lib/librte_lpm/rte_lpm.c | 34 ++++++++++++++++++++++++---------- > 1 file changed, 24 insertions(+), 10 deletions(-) >=20 > diff --git a/lib/librte_lpm/rte_lpm.c b/lib/librte_lpm/rte_lpm.c index > d35d64448..d86248713 100644 > --- a/lib/librte_lpm/rte_lpm.c > +++ b/lib/librte_lpm/rte_lpm.c > @@ -1035,9 +1035,14 @@ add_depth_big_v1604(struct rte_lpm *lpm, > uint32_t ip_masked, uint8_t depth, >=20 > /* Set tbl8 entry. */ > for (i =3D tbl8_index; i < (tbl8_index + tbl8_range); i++) { > - lpm->tbl8[i].depth =3D depth; > - lpm->tbl8[i].next_hop =3D next_hop; > - lpm->tbl8[i].valid =3D VALID; > + struct rte_lpm_tbl_entry new_tbl8_entry =3D { > + .valid =3D VALID, > + .depth =3D depth, > + .valid_group =3D lpm->tbl8[i].valid_group, > + .next_hop =3D next_hop, > + }; > + __atomic_store(&lpm->tbl8[i], &new_tbl8_entry, > + __ATOMIC_RELAXED); > } >=20 > /* > @@ -1075,19 +1080,28 @@ add_depth_big_v1604(struct rte_lpm *lpm, > uint32_t ip_masked, uint8_t depth, >=20 > /* Populate new tbl8 with tbl24 value. */ > for (i =3D tbl8_group_start; i < tbl8_group_end; i++) { > - lpm->tbl8[i].valid =3D VALID; > - lpm->tbl8[i].depth =3D lpm->tbl24[tbl24_index].depth; > - lpm->tbl8[i].next_hop =3D > - lpm->tbl24[tbl24_index].next_hop; > + struct rte_lpm_tbl_entry new_tbl8_entry =3D { > + .valid =3D VALID, > + .depth =3D lpm->tbl24[tbl24_index].depth, > + .valid_group =3D lpm->tbl8[i].valid_group, > + .next_hop =3D lpm- > >tbl24[tbl24_index].next_hop, > + }; > + __atomic_store(&lpm->tbl8[i], &new_tbl8_entry, > + __ATOMIC_RELAXED); > } >=20 > tbl8_index =3D tbl8_group_start + (ip_masked & 0xFF); >=20 > /* Insert new rule into the tbl8 entry. */ > for (i =3D tbl8_index; i < tbl8_index + tbl8_range; i++) { > - lpm->tbl8[i].valid =3D VALID; > - lpm->tbl8[i].depth =3D depth; > - lpm->tbl8[i].next_hop =3D next_hop; > + struct rte_lpm_tbl_entry new_tbl8_entry =3D { > + .valid =3D VALID, > + .depth =3D depth, > + .valid_group =3D lpm->tbl8[i].valid_group, > + .next_hop =3D next_hop, > + }; > + __atomic_store(&lpm->tbl8[i], &new_tbl8_entry, > + __ATOMIC_RELAXED); > } >=20 > /* > -- > 2.17.1