From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yuanhan Liu Subject: Re: [PATCH 1/2] vhost: reference count fix for nb_started_ports Date: Thu, 29 Dec 2016 16:51:32 +0800 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 Cc: dev@dpdk.org, mtetsuyah@gmail.com, Wen Chiu To: "Charles (Chas) Williams" 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) Content-Disposition: inline In-Reply-To: <1482959452-18486-1-git-send-email-ciwillia@brocade.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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