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 84FCAA00C4; Thu, 4 Jun 2020 19:51:55 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 35EF21D5D8; Thu, 4 Jun 2020 19:51:54 +0200 (CEST) Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-eopbgr40079.outbound.protection.outlook.com [40.107.4.79]) by dpdk.org (Postfix) with ESMTP id D24C21D5CE for ; Thu, 4 Jun 2020 19:51:52 +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=9Lf8/Qr8RM+ZdXkMBDah0DoEm4MyymxsKcRUKDujYNQ=; b=Gcnq9mYNSncyFBeBonhDBnhYPqjzRHDHANb0xwn7RElcVnKxzrUISPCG1AXDdsQejUt9UvVrWCbQwXEWbQbcgj0wwNiWpfQB5JpdkrqrHI4/6OyioC+JEDEow4MROFONY7rSAJXdMg8cw50KwmB96n582mlQyfGX9oDpjQJSS34= Received: from DB8PR09CA0015.eurprd09.prod.outlook.com (2603:10a6:10:a0::28) by AM5PR0802MB2482.eurprd08.prod.outlook.com (2603:10a6:203:98::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.18; Thu, 4 Jun 2020 17:51:51 +0000 Received: from DB5EUR03FT014.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:a0:cafe::97) by DB8PR09CA0015.outlook.office365.com (2603:10a6:10:a0::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.19 via Frontend Transport; Thu, 4 Jun 2020 17:51:51 +0000 X-MS-Exchange-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 DB5EUR03FT014.mail.protection.outlook.com (10.152.20.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.18 via Frontend Transport; Thu, 4 Jun 2020 17:51:51 +0000 Received: ("Tessian outbound 56dbe829191e:v59"); Thu, 04 Jun 2020 17:51:51 +0000 X-CR-MTA-TID: 64aa7808 Received: from c57e3a16c4c7.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 9F40E92C-995E-4BC4-952E-BD99FBA0C03B.1; Thu, 04 Jun 2020 17:51:46 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id c57e3a16c4c7.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 04 Jun 2020 17:51:46 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gh7/Xm8uC5HbDraiWVWIjfA7DCvSYP3DI32oZF8UWXtbPKY5ipui7Sg3awPDp4Qo8fQ79QRK3hXsj5AdjtRrLhCwTk072L/dvztatTvWcD2A5tseVDsDVNRNZWHJm7wYxQEOAikmCxjwa87uCG3AAT7tUxYyR8pa3trD4B/G70D56GWc3ZaChbMQTNJCtfbLnPfcXbwzJ7cc0Vpf8mgaSsPMic3gs6oOvvmCMy9W6XIr0xiXju5F2sKyoer20uRYc9gi65wcG5Jx38T9Q/tGgbj8HKMdM0ojVbakFR1DVM7zAGP3EI6XlsPviZwJ4pxMejwBZVsA8NEoIMbyCflblg== 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=9Lf8/Qr8RM+ZdXkMBDah0DoEm4MyymxsKcRUKDujYNQ=; b=WdJQxLrwOHzMzHUP1JZz20ZG+9AQj9Y4W9j8ZwhqBzxaWQOnd5iBodrnDJMj9lmwRQJKV1mmZIMIt5AcGYaxIV7fKoE4zzveBX/MXBCRLIXbATPaJREtu2hH0QyPYTUmfXh5DhjrV5FPo5cT/7Yzx03WLNJ1NzxuEKW8Gf2eZQr8tExfbM4OWAabI9vlEZPzpQZNllMDuMK5K7+/Ru7pXFAWxGboTythS1j5miJKHjg+YKTxewgxy6hSYLoXEuX91a9VXsaFe3lSM3/84Y5WtcrjI7icOx8AeLDA8R14lCDtwXh+dCC1caABYRftm7ULKI4YhJc90xcWjim8bmeIEQ== 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=9Lf8/Qr8RM+ZdXkMBDah0DoEm4MyymxsKcRUKDujYNQ=; b=Gcnq9mYNSncyFBeBonhDBnhYPqjzRHDHANb0xwn7RElcVnKxzrUISPCG1AXDdsQejUt9UvVrWCbQwXEWbQbcgj0wwNiWpfQB5JpdkrqrHI4/6OyioC+JEDEow4MROFONY7rSAJXdMg8cw50KwmB96n582mlQyfGX9oDpjQJSS34= Received: from DB6PR0802MB2216.eurprd08.prod.outlook.com (2603:10a6:4:85::9) by DB6PR0802MB2343.eurprd08.prod.outlook.com (2603:10a6:4:85::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.20; Thu, 4 Jun 2020 17:51:44 +0000 Received: from DB6PR0802MB2216.eurprd08.prod.outlook.com ([fe80::1128:b7e7:e832:310f]) by DB6PR0802MB2216.eurprd08.prod.outlook.com ([fe80::1128:b7e7:e832:310f%9]) with mapi id 15.20.3045.024; Thu, 4 Jun 2020 17:51:44 +0000 From: Honnappa Nagarahalli To: Stephen Hemminger , Yipeng Wang , Sameh Gobriel , Bruce Richardson CC: "dev@dpdk.org" , "pablo.de.lara.guarch@intel.com" , nd , nd Thread-Topic: [PATCH] hash: document breakage with multi-writer thread Thread-Index: AQHWOpQbSbTXGH7QCEO1ao+t3FmiRajIuzHA Date: Thu, 4 Jun 2020 17:51:43 +0000 Message-ID: References: <20200604171731.6738-1-stephen@networkplumber.org> In-Reply-To: <20200604171731.6738-1-stephen@networkplumber.org> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ts-tracking-id: 1486c232-51db-4e1b-8263-58412d8e7660.0 x-checkrecipientchecked: true Authentication-Results-Original: networkplumber.org; dkim=none (message not signed) header.d=none;networkplumber.org; dmarc=none action=none header.from=arm.com; x-originating-ip: [70.113.25.165] x-ms-publictraffictype: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: accb401c-50a0-4f49-d8cd-08d808aff5fb x-ms-traffictypediagnostic: DB6PR0802MB2343:|AM5PR0802MB2482: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true nodisclaimer: true x-ms-oob-tlc-oobclassifiers: OLM:6790;OLM:6790; x-forefront-prvs: 04244E0DC5 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: SNUQXf9+XhNyEtuK7nOHuaoYfhHw8FiQ97oIOD+iiXLiQIpKHy6IQPJc1ntRO/lE9Nmhv14NEl/FOBuNhRb1IWHwhoKEhYzKNSYwxKJ1xLnHNfsDTJok8YYbL5aPa/XZQSGoGiTf82UAuRHbZgHaXfMWine1sdLY845nzdWEJ6inKH0r1xtSfjeklTnSzd+1NtmnILsTKSdpRrf5sDCvF99/kRuJdixdK77s0ITy8LkXhWKk4zZphl7M6pIXEYMIk0zzPlCZ+TfcoaJzPCjhrsSbmGSy9xLP6TQv0JbpUSlt83uojNH2VOxDywD5rU6LZ/CZtb3aMHQptbpRnQHzKA== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB6PR0802MB2216.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(396003)(366004)(136003)(346002)(376002)(39860400002)(4326008)(76116006)(86362001)(66476007)(8936002)(66556008)(66446008)(66946007)(71200400001)(64756008)(8676002)(316002)(7696005)(186003)(110136005)(54906003)(478600001)(33656002)(26005)(9686003)(6506007)(55016002)(2906002)(5660300002)(83380400001)(52536014); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata: C5bUghrVtUgsvqdG4VJwx9dcWE496QrhYB2N68SuvLb54cQnyKBM5pN6h7571T/STgZ5At48RJSrNqkTZrFHl1Q0AqDC9O4DNjwFCBUyBiHECmc4WQ/J4nuYK22MuxRR9Zk9JzW8+rvn594DNlXJP3g+0X0GwehfpWVo58guijVwC8+rPssaIyDSXzFMYmsEOFtAvt8Q5J0j2IzLzp/Kzo8bHSgjGLwdIzjn5FQmTQ3jv4CbVfAB4L8o4LkqPo9xzbY+bomoXbhi9Xctk40jorFXeYkW51wFsKsyvEcy2fXuAe6eThbsrnunea8eXFaghpNHSnH3n+wc6ofYz3fSjtZpJcnpo09SLFaeARufzM5Zu9RKKWQ4U82rBbHg1bxEgdVxxpbAR5VWbPjZFb7+yZxpHp+usnmOuDFMo6yPBI0HjQv6KwGC0ZetlXPWVcC+UcXNAL46Zf7LZ+kQ1Xp4F6z7UXLHN0mJeDy6R2EqCNs= x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0802MB2343 Original-Authentication-Results: networkplumber.org; dkim=none (message not signed) header.d=none; networkplumber.org; dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT014.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:(4636009)(396003)(136003)(39860400002)(346002)(376002)(46966005)(186003)(33656002)(26005)(316002)(6506007)(478600001)(70206006)(70586007)(4326008)(336012)(2906002)(8676002)(82310400002)(8936002)(55016002)(86362001)(47076004)(83380400001)(110136005)(54906003)(81166007)(52536014)(82740400003)(5660300002)(7696005)(9686003)(356005); DIR:OUT; SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: 4a7ed6aa-3450-4cb9-dd94-08d808aff1bd X-Forefront-PRVS: 04244E0DC5 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AYt8GBdB6NpC6LBsTyrJ1ULmTFxtR0ceKAPHWlI+JRJxpjj//9U1DxZk73h8CKDqAYB68uLkULqQ4zbpdkukWdcDLupubMq1u1pE5HpbC8pr8CSLrcg9yv5A5ehun895gK/I/M8DplaBDV1yIocgzOK+b9BwvsOUOevKuRoWBw91dA9HkzsIHKqGqIPmBlXSz7WrLdHofApB/dzV8v7yciNI+ZuLa+AXU7JHSu4zImZa3e557vuFwJK8MU5jVqqRshSXcTP5KXAfdbGp7v6JVBLHfV5aI/LsXTZwYTa1857e4SsznWKFlEbqpD+5uLUjhORDvhwI0sBQ09bof2NpmPw7y5nQ/AW0/Zldaj5TrhldrxPuApMRUhMN9D5GCwSG4beYAidRDADpubBe2mfkUw== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Jun 2020 17:51:51.1987 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: accb401c-50a0-4f49-d8cd-08d808aff5fb 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: AM5PR0802MB2482 Subject: Re: [dpdk-dev] [PATCH] hash: document breakage with multi-writer thread 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" > Subject: [PATCH] hash: document breakage with multi-writer thread >=20 > The code in rte_cuckoo_hash multi-writer support is broken if write > operations are called from a non-EAL thread. >=20 > rte_lcore_id() wil return LCORE_ID_ANY (UINT32_MAX) for non EAL thread > and that leads to using wrong local cache. >=20 > Add error checks and document the restriction. Having multiple non-EAL writer threads is a valid use case. Should we fix t= he issue instead? >=20 > Fixes: 9d033dac7d7c ("hash: support no free on delete") > Fixes: 5915699153d7 ("hash: fix scaling by reducing contention") > Signed-off-by: Stephen Hemminger > Cc: honnappa.nagarahalli@arm.com > Cc: pablo.de.lara.guarch@intel.com > --- > doc/guides/prog_guide/hash_lib.rst | 1 + lib/librte_hash/rte_cuckoo_has= h.c > | 9 +++++++++ > 2 files changed, 10 insertions(+) >=20 > diff --git a/doc/guides/prog_guide/hash_lib.rst > b/doc/guides/prog_guide/hash_lib.rst > index d06c7de2ead1..29b41a425a43 100644 > --- a/doc/guides/prog_guide/hash_lib.rst > +++ b/doc/guides/prog_guide/hash_lib.rst > @@ -85,6 +85,7 @@ For concurrent writes, and concurrent reads and writes > the following flag values >=20 > * If the multi-writer flag (RTE_HASH_EXTRA_FLAGS_MULTI_WRITER_ADD) is > set, multiple threads writing to the table is allowed. > Key add, delete, and table reset are protected from other writer thre= ads. > With only this flag set, readers are not protected from ongoing writes. > + The writer threads must be EAL threads, it is not safe to write to a = multi- > writer hash table from an interrupt, control or other threads. >=20 > * If the read/write concurrency > (RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY) is set, multithread > read/write operation is safe > (i.e., application does not need to stop the readers from accessing t= he hash > table until writers finish their updates. Readers and writers can operate= on > the table concurrently). > diff --git a/lib/librte_hash/rte_cuckoo_hash.c > b/lib/librte_hash/rte_cuckoo_hash.c > index 90cb99b0eef8..79c94107a582 100644 > --- a/lib/librte_hash/rte_cuckoo_hash.c > +++ b/lib/librte_hash/rte_cuckoo_hash.c > @@ -979,6 +979,9 @@ __rte_hash_add_key_with_hash(const struct > rte_hash *h, const void *key, > /* Did not find a match, so get a new slot for storing the new key */ > if (h->use_local_cache) { > lcore_id =3D rte_lcore_id(); > + if (lcore_id =3D=3D LCORE_ID_ANY) > + return -EINVAL; > + > cached_free_slots =3D &h->local_free_slots[lcore_id]; > /* Try to get a free slot from the local cache */ > if (cached_free_slots->len =3D=3D 0) { > @@ -1382,6 +1385,10 @@ remove_entry(const struct rte_hash *h, struct > rte_hash_bucket *bkt, unsigned i) >=20 > if (h->use_local_cache) { > lcore_id =3D rte_lcore_id(); > + ERR_IF_TRUE((lcore_id =3D=3D LCORE_ID_ANY), > + "%s: attempt to remove entry from non EAL > thread\n", > + __func__); > + > cached_free_slots =3D &h->local_free_slots[lcore_id]; > /* Cache full, need to free it. */ > if (cached_free_slots->len =3D=3D LCORE_CACHE_SIZE) { @@ - > 1637,6 +1644,8 @@ rte_hash_free_key_with_position(const struct rte_hash > *h, >=20 > if (h->use_local_cache) { > lcore_id =3D rte_lcore_id(); > + RETURN_IF_TRUE((lcore_id =3D=3D LCORE_ID_ANY), -EINVAL); > + > cached_free_slots =3D &h->local_free_slots[lcore_id]; > /* Cache full, need to free it. */ > if (cached_free_slots->len =3D=3D LCORE_CACHE_SIZE) { > -- > 2.26.2