From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl0-f66.google.com (mail-pl0-f66.google.com [209.85.160.66]) by dpdk.org (Postfix) with ESMTP id 3B8441B816 for ; Thu, 10 May 2018 22:33:59 +0200 (CEST) Received: by mail-pl0-f66.google.com with SMTP id c11-v6so1948775plr.5 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=c06mTwix5if1I7tffxs25bV8xTPca+HJQ/olncU1WaI+aIfTAda7k1S4adGfHBV3Lo aUDWFyE1NP17sDN8/ixgEF53IKLBNZFniV+gmAXC3LWMAHKThxDhf6knfKBllBo3Qxem Zzd/PuGb1xyLmATNo0Mfj/3KhshaNnBIQCjE4MPcNOLdHzWm/jMu52sM/mAu+jsTaVtq lkBg0botckaTw7vQm++ncdmIkd071viuI7Lom6CDOlYMNPcVkQhFCAIl5VhXccgtIOIR WmPdYfk7B3Afns3lqK9rj3ZA6fI86R+0pXSCHp/av+p+znl7KIHIgQSRZRDFYwgMAOxk MqiQ== X-Gm-Message-State: ALKqPweOGUJB2E3q700KZFuId24RA5zMyBIxhjXaRsh3aEGrt/Ko04wA 7G/+NmVzVqr0nT1DDZwMuY7MIA== 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-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: 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.