From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by dpdk.org (Postfix) with ESMTP id 98EC77E93 for ; Wed, 9 May 2018 14:25:05 +0200 (CEST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 20FB6224F7; Wed, 9 May 2018 08:25:05 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Wed, 09 May 2018 08:25:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=mesmtp; bh=o6h7I5j51p1U1/PplmTLJIetBC 8ZMjsvu5KmMuHHYVQ=; b=cM+AReb+/0g5WL0ba2JQfTuwMEXZkefmkigIvEA1zh TrRKQ04FfajOVsG77l1guh2wVUREFPYlzU/dn4n1LLiwuDKoHsEkRKKDTRr7Gvxq d+FdIkZMfzk/wlkbruagRQFGqPEvxrK3y50vJ3lUj2h7P3+DDrT1hRidNI45kzzX U= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=o6h7I5 j51p1U1/PplmTLJIetBC8ZMjsvu5KmMuHHYVQ=; b=YTrWe4pTd6Je+B9w98+NrN W6fjcBvzkbCdZZjMnlFy0zuNMiYuMg9wCylFMEXyFn1e4BhbQGb9f+lX4cfffRxW 3Kq9fBmVSfSDxBz58f8OItpWQoalLMCHXjk4JcZwiJUiQVCfqPGXq6/+YBpvf6xa HItnksHQK+O/azKR9REKXBq5IYfEFpqjUXbCqMGseuYwBTRyFP7dUn0wtkVuPnix 7HZeg/FC3jdWtJzmiNUuUeUvEGAB1V39GXkqFldHD7uvOOLlTozhlq+WDz7h3TjU FFkHXRADcz1mIvWLJD37oPOOwm3vwOYKsLkDfzldqApwQ0RGFDW06gj3Wk0cuiVw == X-ME-Sender: Received: from xps.localnet (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id 63590E4B94; Wed, 9 May 2018 08:25:04 -0400 (EDT) From: Thomas Monjalon To: =?ISO-8859-1?Q?Ga=EBtan?= Rivet Cc: dev@dpdk.org, Matan Azrad Date: Wed, 09 May 2018 14:25:03 +0200 Message-ID: <2776783.KmHTlbbVux@xps> In-Reply-To: <20180509122116.ljistjpz3dfljdqo@bidouze.vm.6wind.com> References: <20180509094337.26112-1-thomas@monjalon.net> <20180509094337.26112-8-thomas@monjalon.net> <20180509122116.ljistjpz3dfljdqo@bidouze.vm.6wind.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="iso-8859-1" Subject: Re: [dpdk-dev] [PATCH 07/11] ethdev: add lock to port allocation check 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, 09 May 2018 12:25:05 -0000 09/05/2018 14:21, Ga=EBtan Rivet: > Hi, >=20 > On Wed, May 09, 2018 at 11:43:33AM +0200, Thomas Monjalon wrote: > > From: Matan Azrad > >=20 > > When comparing the port name, there can be a race condition with > > a thread allocating a new port and writing the name at the same time. > > It can lead to match with a partial name by error. > >=20 > > The check of the port is now considered as a critical section > > protected with locks. > >=20 > > This fix will be even more required for multi-process when the > > port availability will rely only on the name, in a following patch. > >=20 > > Fixes: 84934303a17c ("ethdev: synchronize port allocation") > > Cc: stable@dpdk.org > >=20 > > Signed-off-by: Matan Azrad > > Acked-by: Thomas Monjalon > > --- > > lib/librte_ethdev/rte_ethdev.c | 22 +++++++++++++++++++--- > > 1 file changed, 19 insertions(+), 3 deletions(-) > >=20 > > diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_eth= dev.c > > index ae86d0ba7..357be2dca 100644 > > --- a/lib/librte_ethdev/rte_ethdev.c > > +++ b/lib/librte_ethdev/rte_ethdev.c > > @@ -227,8 +227,8 @@ rte_eth_dev_shared_data_prepare(void) > > rte_spinlock_unlock(&rte_eth_shared_data_lock); > > } > > =20 > > -struct rte_eth_dev * > > -rte_eth_dev_allocated(const char *name) > > +static struct rte_eth_dev * > > +rte_eth_dev_allocated_lock_free(const char *name) >=20 > A suggestion about the naming here. > Reading subsequent patches, we can see this function being used during > ethdev allocation routines. The _lock_free suffix is a little > misleading, as for an instant one can think that there is something > being freed about an allocated ethdev lock. >=20 > I would suggest >=20 > * rte_eth_dev_allocated_nolock > or > * rte_eth_dev_allocated_lockless > (or even rte_eth_lockless_dev_allocated) >=20 > instead. Good suggestions. I vote for rte_eth_dev_allocated_nolock. Thanks