From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 23DE72C4F for ; Thu, 29 Dec 2016 09:49:47 +0100 (CET) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP; 29 Dec 2016 00:49:46 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,425,1477983600"; d="scan'208";a="1105545879" Received: from yliu-dev.sh.intel.com (HELO yliu-dev) ([10.239.67.162]) by fmsmga002.fm.intel.com with ESMTP; 29 Dec 2016 00:49:45 -0800 Date: Thu, 29 Dec 2016 16:51:32 +0800 From: Yuanhan Liu To: "Charles (Chas) Williams" Cc: dev@dpdk.org, mtetsuyah@gmail.com, Wen Chiu Message-ID: <20161229085132.GC21789@yliu-dev.sh.intel.com> References: <1482959452-18486-1-git-send-email-ciwillia@brocade.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1482959452-18486-1-git-send-email-ciwillia@brocade.com> User-Agent: Mutt/1.5.23 (2014-03-12) Subject: Re: [dpdk-dev] [PATCH 1/2] vhost: reference count fix for nb_started_ports 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, 29 Dec 2016 08:49:48 -0000 On Wed, Dec 28, 2016 at 04:10:51PM -0500, Charles (Chas) Williams wrote: > From: Wen Chiu > > Only increment and decrement nb_started_ports on the first and last > device start and stop. Otherwise, nb_started_ports can become negative > if a device is stopped multiple times. How could you be able to stop dev (precisely, invoke eth_dev_stop) multiple times, judging that eth_dev_stop() will be invoked once only? void rte_eth_dev_stop(uint8_t port_id) { struct rte_eth_dev *dev; RTE_ETH_VALID_PORTID_OR_RET(port_id); dev = &rte_eth_devices[port_id]; RTE_FUNC_PTR_OR_RET(*dev->dev_ops->dev_stop); ==> if (dev->data->dev_started == 0) { RTE_PMD_DEBUG_TRACE("Device with port_id=%" PRIu8 " already stopped\n", port_id); return; } ==> dev->data->dev_started = 0; (*dev->dev_ops->dev_stop)(dev); } Multiple threads? --yliu