From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl0-f65.google.com (mail-pl0-f65.google.com [209.85.160.65]) by dpdk.org (Postfix) with ESMTP id 36E361B74B for ; Thu, 10 May 2018 22:33:59 +0200 (CEST) Received: by mail-pl0-f65.google.com with SMTP id n10-v6so1952936plp.0 for ; Thu, 10 May 2018 13:33:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6Q/dUR1fYOlJk9BP0IqnsphU4d/DeEKd6CANEwtiruk=; b=SDT2QsJqwGOjB+UrKvmWQrpAasEr+nVhuTo8XuZu3aFHVGW+NKFmTA7JKBYw91wR0G bLB24RyrOszkgd8HaAScmDEAvvJndgwKqA6jmODVuC1MvFnP1sN8JbZ5I4Y1hLVS9Aan 6f5Ywt+v5i1r7uRlqrr3pqXDHkmyR9aXYMgO0tHaZCmVP9yTLfTpUzLbBtupySBCNZqo cNaPCkXFiT0VL7Pue4CAw+tmZuMJvqqJ9vfkLqQ64S0oh3dDjIoEPUij006bKhFqH3Fx Z+ywmyVLpwjafLdETcMZtyxAFzYxFIlpHHcDr5c6i/wT3/6bbQ7QLVmfmbne5K0SRDrk 8hjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6Q/dUR1fYOlJk9BP0IqnsphU4d/DeEKd6CANEwtiruk=; b=UM0nJJUvDeVAH5FMfmjr+2ZBugkfmb/0V6jwc8fpSDFM8/bn7w2iQSzEb2E93+ugst Rt5/VPWYiJ5QYR7Qd70QmRhaS6Vq77nAaimX7RrdmIWmglsaHCTQdGT43a/0aD23GHeA Itg1eDTIiEijUI+FoCT3NWGPAYUEM8lPvZobdjtPsai5r2+cYqFZmmkVAquOiRjnKGnd od4Y6tGUb1nO/xcKrlUuXh0ajrQJyDuyBV8ioknIH+5ETBvzJbDpkBXqeh/r3sVbymyb aSTepxKo9+dLNAOKPQ+QgzCvvQCRGAPPyWwZYGYy4UcFgaJT5hw7Yr0FrG7B7WEZAI0E VCKg== X-Gm-Message-State: ALKqPwdbL6zYhB9/nEUhttXD17LoXwF+tvAGwd1hOCkkTjGlCr6TNVEF /x2xkK8z1EdX40HQ4dftOR1fVB4+NhQ= X-Google-Smtp-Source: AB8JxZotVdbzn5htJ/Uve9EhM8yNI9O0VPAd53lIy9kO6Jo+p7VzxXKfLrs2S7tKakuWRcXJeRK5+Q== X-Received: by 2002:a17:902:887:: with SMTP id 7-v6mr2754297pll.319.1525984438320; Thu, 10 May 2018 13:33:58 -0700 (PDT) Received: from xeon-e3 (204-195-35-107.wavecable.com. [204.195.35.107]) by smtp.gmail.com with ESMTPSA id q75-v6sm3541390pfj.94.2018.05.10.13.33.58 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 May 2018 13:33:58 -0700 (PDT) Date: Thu, 10 May 2018 13:33:56 -0700 From: Stephen Hemminger To: Thomas Monjalon Cc: dev@dpdk.org, Matan Azrad , stable@dpdk.org Message-ID: <20180510133356.0c4bacb0@xeon-e3> In-Reply-To: <20180509094337.26112-8-thomas@monjalon.net> References: <20180509094337.26112-1-thomas@monjalon.net> <20180509094337.26112-8-thomas@monjalon.net> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-stable] [dpdk-dev] [PATCH 07/11] ethdev: add lock to port allocation check X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 May 2018 20:33:59 -0000 On Wed, 9 May 2018 11:43:33 +0200 Thomas Monjalon wrote: > > +struct rte_eth_dev * > +rte_eth_dev_allocated(const char *name) > +{ > + struct rte_eth_dev *ethdev; > + > + rte_eth_dev_shared_data_prepare(); > + > + rte_spinlock_lock(&rte_eth_dev_shared_data->ownership_lock); > + > + ethdev = rte_eth_dev_allocated_lock_free(name); > + > + rte_spinlock_unlock(&rte_eth_dev_shared_data->ownership_lock); > + > + return ethdev; > +} > + Not sure about this. The code it self is correct, but it creates a racy semantic. If caller doesn't already hold a lock then there is no guarantee that the device returned won't be destroyed by some other thread or that the name was just allocated by some other process.