From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-eopbgr30070.outbound.protection.outlook.com [40.107.3.70]) by dpdk.org (Postfix) with ESMTP id CDA661B14C for ; Wed, 26 Sep 2018 16:36:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector1-arm-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+zWqpblWgnrRebC7nLH9k7gLYmRdbyjbjPuDJpU5CsQ=; b=TxkYRE5lUwzMXpUj5Y7CNIq3/LCtSE81MjFYVD/EHwcE1TFl9ZSnWAisx/QSehsqfHnU4C96zMtLfikIt94UGNNxxcwWvG7i95soBQbSOlUmVPlbg5NRrOhNkGLhKZhhlVwRlGKu+aAYDXxZvHA7IlAX04w8zrdA3uV2ebnqinw= Received: from AM6PR08MB3672.eurprd08.prod.outlook.com (20.177.115.29) by AM6PR08MB3384.eurprd08.prod.outlook.com (20.177.112.221) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1164.22; Wed, 26 Sep 2018 14:36:44 +0000 Received: from AM6PR08MB3672.eurprd08.prod.outlook.com ([fe80::589e:d3cf:9777:5ff9]) by AM6PR08MB3672.eurprd08.prod.outlook.com ([fe80::589e:d3cf:9777:5ff9%2]) with mapi id 15.20.1164.024; Wed, 26 Sep 2018 14:36:44 +0000 From: Honnappa Nagarahalli To: Honnappa Nagarahalli , "bruce.richardson@intel.com" , "pablo.de.lara.guarch@intel.com" CC: "dev@dpdk.org" , honnappa.nagarahalli , "Gavin Hu (Arm Technology China)" , Steve Capper , Ola Liljedahl , nd , "yipeng1.wang@intel.com" , Michel Machado , "sameh.gobriel@intel.com" Thread-Topic: [PATCH 0/4] Address reader-writer concurrency in rte_hash Thread-Index: AQHURgTKqGcS9ICsZUeJFhcyzG1braTwU7bwgBJsctA= Date: Wed, 26 Sep 2018 14:36:43 +0000 Message-ID: References: <1536253938-192391-1-git-send-email-honnappa.nagarahalli@arm.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: 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-microsoft-exchange-diagnostics: 1; AM6PR08MB3384; 6:prgAKUFCm8gFNqHGPwYlsRlhKduAlTZa7FifpGi37E6CYh5fZ5kit+MQmq51HhPEDNCvZwaa3DjU6sYYqg5mUpJxqRrX/Qa0petkeFxOKtluhp+c47kLzlpGYJnRuiQrC6/GP/PHIWW21LFo62mcKbd6f2ronsC4vdAY2Uv7iCc5Kthm7o+5JDkNrc4z4Fio9+FfPnds5g7DOxEIsJLmDFi9giLfl0ArP7dy2rPT1IyAZSwfG9Zc6s5h8EB/J6+VLfBheeRfXflMt3DtdjijeI3vHoOOFYnAPkhPDhbtMF699o27bR1P6e3JE6vac04bmcM4gbCPuNHgS1EakSzsxiMwRpRrzVleeQ2HEetAaCxnyTfsA0/7f3ubDkJdvWUG4LBWk8yY+Vr3D8Y8ZdTHwi6YGIgkj7W0aKW+eQ2oO2s/EXAyiBmPTo8d8ijIjWVdn6qN0TbY37/fAEvNK2WckA==; 5:yUHFVH1Osn9UcbTbr28NU/HoLUswKLfE3gMhbG9BniDcJxBY0KXgUuH0AQSYMJSjDd5EtS+q4YK3yhdzL+S2LZJInGZFlbpO+ESBLGmI9XQnSgmlFfXGym51AMnbD4RamA2ngdxFnTvySig+1gQOJwPY9BdyVBvxPVlG5Z7kTMU=; 7:4e+IHxkrKcfVllGYc5lBuvCy2s9H1SJD0DqlMBS6HpeDienzV/HpmDEYIWX0cwxekzE9y2H5wC7qx/mnBPt+5OlYwaSwbGe39kZ3F3NQrg2hQi02rjehn/zHZx6SMTX8w9gTh8LCSvVFx2BhrZb9xlR12aJw1Uz1KBmDKdMvql3dvR7QemBGDyysau8Ctngy+IK903IjPJnlKm458dixmQgyLrenXb+F2gkeM+O4ujRZ8w+q91OD+SRP+BJQPEnW x-ms-exchange-antispam-srfa-diagnostics: SOS;SOR; x-ms-office365-filtering-correlation-id: 229afefa-8965-4dfa-0405-08d623bd7b1d x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:AM6PR08MB3384; x-ms-traffictypediagnostic: AM6PR08MB3384: nodisclaimer: True x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(228905959029699)(180628864354917)(166494164430575); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3002001)(93006095)(93001095)(3231355)(944501410)(52105095)(10201501046)(6055026)(149066)(150057)(6041310)(20161123564045)(20161123558120)(20161123560045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051); SRVR:AM6PR08MB3384; BCL:0; PCL:0; RULEID:; SRVR:AM6PR08MB3384; x-forefront-prvs: 08076ABC99 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(39860400002)(136003)(376002)(396003)(366004)(346002)(13464003)(189003)(199004)(2501003)(105586002)(25786009)(8676002)(5250100002)(33656002)(5660300001)(106356001)(2201001)(486006)(476003)(11346002)(86362001)(7696005)(446003)(76176011)(6436002)(99286004)(66066001)(97736004)(8936002)(110136005)(54906003)(9686003)(316002)(53936002)(6306002)(71190400001)(71200400001)(55016002)(68736007)(34290500001)(6116002)(3846002)(2906002)(2900100001)(4326008)(6246003)(26005)(14444005)(102836004)(256004)(966005)(6506007)(14454004)(74316002)(478600001)(53546011)(81166006)(81156014)(229853002)(7736002)(305945005)(72206003)(21314002); DIR:OUT; SFP:1101; SCL:1; SRVR:AM6PR08MB3384; H:AM6PR08MB3672.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-microsoft-antispam-message-info: sMHWHDyOKfW+WqHCRX8D1HvSF9/l0UwBNMIK9eejVLEfsGt+JB9ETz7HnpN7cZuNS/S1CXDaWQGWnn3wjqwRFJoprR/OUfudkpeW0fN4l/1iJpHcF9GOCV3q7+tzkXvp92aEvdHgfa7m4vzKjhoBeanokUBvMv/TD2I9oZvQTy1ZMm4Ntqre7a124W4QC/0UsAAavtgY3cOGrW8CO7vyF4mfoG7APXyy4oF5MpIXR8ZbsgmTAR3sV6tmmYS5Vy/+aHRN7ywBtHhojp/MQWpo/TVcyhCh0b70j9wYa30fAXRhJvf1pldUZsNLHKQ1MswdqntWejqv/YKd3r6tnwZgkZa2SCLrgX9VStYqAjAER8s= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM 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: 229afefa-8965-4dfa-0405-08d623bd7b1d X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Sep 2018 14:36:43.9673 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3384 Subject: Re: [dpdk-dev] [PATCH 0/4] Address reader-writer concurrency in rte_hash 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: , X-List-Received-Date: Wed, 26 Sep 2018 14:36:46 -0000 Hi Bruce/Pablo, I need to get this into 18.11, appreciate any review/feedback soon. Thank you, Honnappa > -----Original Message----- > From: Honnappa Nagarahalli > Sent: Friday, September 14, 2018 4:19 PM > To: Honnappa Nagarahalli ; > bruce.richardson@intel.com; pablo.de.lara.guarch@intel.com > Cc: dev@dpdk.org; honnappa.nagarahalli; Gavin Hu (Arm Technology China) > ; Steve Capper ; Ola Liljedahl > ; nd ; yipeng1.wang@intel.com; > Michel Machado ; sameh.gobriel@intel.com > Subject: RE: [PATCH 0/4] Address reader-writer concurrency in rte_hash >=20 > I have added the memory ordering ladder diagrams to the DPDK summit slide= s > to help understand the changes. The slides are available at: > https://dpdkuserspace2018.sched.com/event/G44w/lock-free-read-write- > concurrency-in-rtehash. Please look at the backup slides. >=20 > Thank you, > Honnappa >=20 > -----Original Message----- > From: Honnappa Nagarahalli > Sent: Thursday, September 6, 2018 12:12 PM > To: bruce.richardson@intel.com; pablo.de.lara.guarch@intel.com > Cc: dev@dpdk.org; honnappa.nagarahalli; Gavin Hu (Arm Technology China) > ; Steve Capper ; Ola Liljedahl > ; nd ; Honnappa Nagarahalli > > Subject: [PATCH 0/4] Address reader-writer concurrency in rte_hash >=20 > Currently, reader-writer concurrency problems in rte_hash are > addressed using reader-writer locks. Use of reader-writer locks > results in following issues: >=20 > 1) In many of the use cases for the hash table, writer threads > are running on control plane. If the writer is preempted while > holding the lock, it will block the readers for an extended period > resulting in packet drops. This problem seems to apply for platfor= ms > with transactional memory support as well because of the algorithm > used for rte_rwlock_write_lock_tm: >=20 > static inline void > rte_rwlock_write_lock_tm(rte_rwlock_t *rwl) > { > if (likely(rte_try_tm(&rwl->cnt))) > return; > rte_rwlock_write_lock(rwl); > } >=20 > i.e. there is a posibility of using rte_rwlock_write_lock in > failure cases. > 2) Reader-writer lock based solution does not address the following > issue. > rte_hash_lookup_xxx APIs return the index of the element in > the key store. Application(reader) can use that index to reference > other data structures in its scope. Because of this, the > index should not be freed till the application completes > using the index. > 3) Since writer blocks all the readers, the hash lookup > rate comes down significantly when there is activity on the writer= . > This happens even for unrelated entries. Performance numbers > given below clearly indicate this. >=20 > Lock-free solution is required to solve these problems. This patch > series adds the lock-free capabilities in the following steps: >=20 > 1) Correct the alignment for the key store entry to prep for > memory ordering. > 2) Add memory ordering to prevent race conditions when a new key > is added to the table. >=20 > 3) Reader-writer concurrency issue, caused by moving the keys > to their alternate locations during key insert, is solved > by introducing an atomic global counter indicating a change > in table. >=20 > 4) This solution also has to solve the issue of readers using > key store element even after the key is deleted from > control plane. > To solve this issue, the hash_del_key_xxx APIs do not free > the key store element. The key store element has to be freed > using the newly introduced rte_hash_free_key_with_position API. > It needs to be called once all the readers have stopped using > the key store element. How this is determined is outside > the scope of this patch (RCU is one such mechanism that the > application can use). >=20 > 4) Finally, a lock free reader-writer concurrency flag is added > to enable this feature at run time. >=20 > Performance numbers: > Scenario: Equal number of writer/reader threads for concurrent > writers and readers. For readers only test, the > entries are added upfront. >=20 > Current code: > Cores Lookup Lookup > with add > 2 474 246 > 4 935 579 > 6 1387 1048 > 8 1766 1480 > 10 2119 1951 > 12 2546 2441 >=20 > With this patch: > Cores Lookup Lookup > with add > 2 291 211 > 4 297 196 > 6 304 198 > 8 309 202 > 10 315 205 > 12 319 209 >=20 > Honnappa Nagarahalli (4): > hash: correct key store element alignment > hash: add memory ordering to avoid race conditions > hash: fix rw concurrency while moving keys > hash: enable lock-free reader-writer concurrency >=20 > lib/librte_hash/rte_cuckoo_hash.c | 445 +++++++++++++++++++++++++----= --- > --- > lib/librte_hash/rte_cuckoo_hash.h | 6 +- > lib/librte_hash/rte_hash.h | 63 ++++- > lib/librte_hash/rte_hash_version.map | 7 + > 4 files changed, 393 insertions(+), 128 deletions(-) >=20 > -- > 2.7.4