From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from dpdk.org (dpdk.org [92.243.14.124])
	by inbox.dpdk.org (Postfix) with ESMTP id B9068A00C4;
	Thu,  4 Jun 2020 20:43:48 +0200 (CEST)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id 2BF531C0D2;
	Thu,  4 Jun 2020 20:43:48 +0200 (CEST)
Received: from EUR05-VI1-obe.outbound.protection.outlook.com
 (mail-vi1eur05on2043.outbound.protection.outlook.com [40.107.21.43])
 by dpdk.org (Postfix) with ESMTP id 33C492C28
 for <dev@dpdk.org>; Thu,  4 Jun 2020 20:43:46 +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=n48rdFPkx8n+iLPy1zZNp80IaYKfg+re/3YIsisHy4Y=;
 b=TQAQDlvhjbO+XCijJIlTikdzeFNDWzMrzqFS4VdaJFG8/ZHpgwWz/afxRWWd5I3u+jxEmByRG5UQALg/tN7DSb5ppTicQ2VRjDNR6oUILg02sX982KUz/g+ge2yqR5e4y16kcttEh1GBVLafZC6q6+t5inbiT7cAiL9ARRxZmUE=
Received: from AM6P193CA0088.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:88::29)
 by DB7PR08MB3547.eurprd08.prod.outlook.com (2603:10a6:10:4f::27) with
 Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3045.19; Thu, 4 Jun
 2020 18:43:44 +0000
Received: from AM5EUR03FT034.eop-EUR03.prod.protection.outlook.com
 (2603:10a6:209:88:cafe::9a) by AM6P193CA0088.outlook.office365.com
 (2603:10a6:209:88::29) 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 18:43:44 +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
 AM5EUR03FT034.mail.protection.outlook.com (10.152.16.81) 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 18:43:44 +0000
Received: ("Tessian outbound 4f5776643448:v59");
 Thu, 04 Jun 2020 18:43:44 +0000
X-CR-MTA-TID: 64aa7808
Received: from 2ed9fe264ea0.1
 by 64aa7808-outbound-1.mta.getcheckrecipient.com id
 6E6695E2-32B8-4BD5-8222-369E277837F3.1; 
 Thu, 04 Jun 2020 18:43:39 +0000
Received: from EUR05-VI1-obe.outbound.protection.outlook.com
 by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 2ed9fe264ea0.1
 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384);
 Thu, 04 Jun 2020 18:43:39 +0000
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;
 b=AF8irbQwjA5tTD2sF0ZepLS3geoRIZcvtQOvHbuRawFlhimVJmXFizDWEODR1XEtHEtJ8dgqoLGKmAI+w28RrJRthCvOxgae5RpY+aGkrX6+EsAaCoBJ9P5tJr5botB9ESg8h7r+q4CaZWU9TxCjROP+5Jvq6Y400sLV9xRRTpU8bE+ssaDpnENOr03BN6/no107xXj9TRx+HJakpe9gmLEFSfGL0zZDYxwyO/iXjp92L6RnqCJ4W2kjAGy2+sT3nXOvF28IXsOo0xoX6LSeXTAOCdIQvDzMbkIUovbnWRLijQH74PUmuAhNSJlDY7m5O8cgwv887YxkDu7Q2g7Cbw==
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=n48rdFPkx8n+iLPy1zZNp80IaYKfg+re/3YIsisHy4Y=;
 b=AlYWsb6HKTOCKSSxI7glDHJBLbBQArClI1YqVQP3HrmPdyhlYjvSp8ztHu9ELZzf2QjSv5p+Oq20HIy5RLQ+dZTiD3cyiQb+Y+PXZL4JQ2JLW8qTbfYWtz1nUfsU3kcqDOmfS5i3f3+UIlKzmBHlaUyJAuRpBkUG4eeHtGuwGBZbPFoIXIv4Xkk16H0ItK7SxNUGeb0aA/6ASbG6y5D/JJMH6t2XRtb7pk/xxTc6NQEusSMIbAqUgJFqt6+Ni3xn/4AnHh0VDddwvNLTl9LHWJGQA7nCCBdCnO5ekTd87om4JIz4epzLHTLxFGvxtbS0e0zOQ8md9N9wW8PXpJr9kQ==
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=n48rdFPkx8n+iLPy1zZNp80IaYKfg+re/3YIsisHy4Y=;
 b=TQAQDlvhjbO+XCijJIlTikdzeFNDWzMrzqFS4VdaJFG8/ZHpgwWz/afxRWWd5I3u+jxEmByRG5UQALg/tN7DSb5ppTicQ2VRjDNR6oUILg02sX982KUz/g+ge2yqR5e4y16kcttEh1GBVLafZC6q6+t5inbiT7cAiL9ARRxZmUE=
Received: from AM4PR0802MB2212.eurprd08.prod.outlook.com (2603:10a6:200:59::8)
 by AM4PR0802MB2323.eurprd08.prod.outlook.com (2603:10a6:200:61::20)
 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 18:43:37 +0000
Received: from AM4PR0802MB2212.eurprd08.prod.outlook.com
 ([fe80::9130:1e61:ef03:c4e1]) by AM4PR0802MB2212.eurprd08.prod.outlook.com
 ([fe80::9130:1e61:ef03:c4e1%3]) with mapi id 15.20.3066.019; Thu, 4 Jun 2020
 18:43:37 +0000
From: Honnappa Nagarahalli <Honnappa.Nagarahalli@arm.com>
To: Stephen Hemminger <stephen@networkplumber.org>
CC: Yipeng Wang <yipeng1.wang@intel.com>, Sameh Gobriel
 <sameh.gobriel@intel.com>, Bruce Richardson <bruce.richardson@intel.com>,
 "dev@dpdk.org" <dev@dpdk.org>, "pablo.de.lara.guarch@intel.com"
 <pablo.de.lara.guarch@intel.com>, nd <nd@arm.com>, Honnappa Nagarahalli
 <Honnappa.Nagarahalli@arm.com>, nd <nd@arm.com>
Thread-Topic: [PATCH] hash: document breakage with multi-writer thread
Thread-Index: AQHWOpQbSbTXGH7QCEO1ao+t3FmiRajIuzHAgAADGYCAAAbIYA==
Date: Thu, 4 Jun 2020 18:43:36 +0000
Message-ID: <AM4PR0802MB22129FFB7504E7161E68B6B998890@AM4PR0802MB2212.eurprd08.prod.outlook.com>
References: <20200604171731.6738-1-stephen@networkplumber.org>
 <DB6PR0802MB221691379E0AAD8CAC76F3C398890@DB6PR0802MB2216.eurprd08.prod.outlook.com>
 <20200604105817.1a3a2749@hermes.lan>
In-Reply-To: <20200604105817.1a3a2749@hermes.lan>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
x-ts-tracking-id: cad015a9-119d-43db-9398-534b3fa538ce.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: a7db160e-9410-4f02-ff8e-08d808b735bc
x-ms-traffictypediagnostic: AM4PR0802MB2323:|DB7PR08MB3547:
x-ms-exchange-transport-forked: True
X-Microsoft-Antispam-PRVS: <DB7PR08MB35473C00C23866F93C7F648398890@DB7PR08MB3547.eurprd08.prod.outlook.com>
x-checkrecipientrouted: true
nodisclaimer: true
x-ms-oob-tlc-oobclassifiers: OLM:9508;OLM:9508;
x-forefront-prvs: 04244E0DC5
X-MS-Exchange-SenderADCheck: 1
X-Microsoft-Antispam-Untrusted: BCL:0;
X-Microsoft-Antispam-Message-Info-Original: 2E4PsJnrLwZM02nhPlAmLMAf9x69VkyncjLnPK18fqAeyQGSlL3qkF8gdVqaoFxpFq0zQOtGBXrgYSLLJWMrApXKuh/h4I/TPm57g0klYkVooqxZmlmcgfXsmuvVtuA7NaSpv/Is2oq3KiKsDWv0tfI87W0Rm39HxeELae7f79WsXwSpiU7BWy1a75PzdEn8Ggfns8DPGMTlWWawICvF5HmFjEzMShy92fOy1RLqj8oO99bQoZ8IucrFbue5SgJmskZoVziIqdowGwnALOE8rYH5vz4lpp8wE3vBQSSH5poGYXZstWGjfQXQt/GnLCI0BRe6YFAHTAkPkqhRGy3J9w==
X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en;
 SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM4PR0802MB2212.eurprd08.prod.outlook.com;
 PTR:; CAT:NONE; SFTY:;
 SFS:(4636009)(376002)(346002)(366004)(39860400002)(136003)(396003)(5660300002)(76116006)(86362001)(66946007)(66476007)(83380400001)(66556008)(6916009)(55016002)(8676002)(64756008)(52536014)(9686003)(66446008)(7696005)(54906003)(316002)(8936002)(26005)(2906002)(186003)(478600001)(6506007)(33656002)(71200400001)(4326008);
 DIR:OUT; SFP:1101; 
x-ms-exchange-antispam-messagedata: NSPV61X5+H/RotFdY6sd79YFihDPZfJcSXKe/8xVed+cQWImfJNRVa/6OsajtA/ju3/v+Nw8/GQ0J+HMVIseFc4ukpQUNw9QoyCbKGCsXGoV+xhpysRJ+3JK63CVXzUvKJf2tbjhyLXwMhbdsQIRBMlut3qJ5gRljjUqaYobB8i1uNheye0iUVsDvSAIVmtME2tYSPP78/2yIvikHbz0EUNj5ibpMYJfQzrmP4094lvK/pFXYbxNpztfc+N2VUuvgdQ8PQY4ZeMyx36FNuwB6CFhjfjyVl4Eg/xyxi1otTh15OUtAvvdQ1VQozH8eq1jLyME2OJxNQLz7Nz91mskMJYz1XmUGwShzKYLOzyk8e/akAT1j2RIsgaVCMFXisgzXAoyVWVWIX84De+Us8FBOIVWOic8L9VoFCAfs/HeJzuQdDIEVQB2C7ABZCevVzDM+WLimA9TdwuMDwppKgt6mWVojSk+W6/lKrXcNqjD08I=
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR0802MB2323
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: AM5EUR03FT034.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)(136003)(39860400002)(396003)(376002)(346002)(46966005)(47076004)(8936002)(5660300002)(356005)(82310400002)(8676002)(52536014)(82740400003)(81166007)(70586007)(83380400001)(7696005)(26005)(186003)(478600001)(86362001)(33656002)(336012)(316002)(2906002)(55016002)(36906005)(6506007)(9686003)(70206006)(4326008)(6862004)(54906003);
 DIR:OUT; SFP:1101; 
X-MS-Office365-Filtering-Correlation-Id-Prvs: f7bc85dd-c9e7-47d7-c046-08d808b73140
X-Forefront-PRVS: 04244E0DC5
X-Microsoft-Antispam: BCL:0;
X-Microsoft-Antispam-Message-Info: jyU2R2XmIfnhvn8qFZFbftLICtzxUcqz3GfL/KH4IOtHlBb2Ogf72DOU8/B5IimAU8DCVHyQGCPqTSHs3ewJHbGtqopG0qU1/oTuo/nYCSXQ+WQz8YpPR6VD+UsWjHaNVHG71f6MDvv6wPkkoDV+kzN/v+PTZhLcURzPLy4Q7m+U8hlF/HuVEfT6+rYGO39EiwQD4oH6Nc6G4sS0//j2y6Sszq3VkeVpz7kPbRGnauTHq5l5EOc8mX9eFGvabdsfTKYT3Asc8jVL8J6RDNCseeDd2UqTZK9vvWWffOpTe8Y2zgxuv4iyZiaUL3VwQUZT36dwRWhx/zQpXFZBvWgIfU/Lni+A5Z6VDqsyI5u4myApP7M4yrfkfuWwzgjB6aUsGbAPgppwZe5Y2FOUfysj9A==
X-OriginatorOrg: arm.com
X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Jun 2020 18:43:44.5751 (UTC)
X-MS-Exchange-CrossTenant-Network-Message-Id: a7db160e-9410-4f02-ff8e-08d808b735bc
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: DB7PR08MB3547
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 <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>

> > <snip>
> >
> > > Subject: [PATCH] hash: document breakage with multi-writer thread
> > >
> > > The code in rte_cuckoo_hash multi-writer support is broken if write
> > > operations are called from a non-EAL thread.
> > >
> > > rte_lcore_id() wil return LCORE_ID_ANY (UINT32_MAX) for non EAL
> > > thread and that leads to using wrong local cache.
> > >
> > > Add error checks and document the restriction.
> > Having multiple non-EAL writer threads is a valid use case. Should we f=
ix the
> issue instead?
>=20
> Discovered this the hard way...
>=20
> Fixing is non-trivial. Basically, the local cache has to be take out and =
that
> leads to having to do real locking or atomic operations.
Looking at rte_hash_create function:

        if (params->extra_flag & RTE_HASH_EXTRA_FLAGS_MULTI_WRITER_ADD) {
                use_local_cache =3D 1;
                writer_takes_lock =3D 1;
        }

The writer locks are in place already. The code to handle the case when loc=
al cache is taken out is also there.
What we need is another input flag that says 'multi writer + non-eal thread=
s' which would set 'use_local_cache =3D 0' and 'writer_takes_lock =3D 1'.
Not sure, it would be valuable addition. But looks like this is what you we=
re expecting when you had enabled 'RTE_HASH_EXTRA_FLAGS_MULTI_WRITER_ADD'. =
Many other APIs in DPDK do not provide this kind of MT safety.