From: "Charles (Chas) Williams" <ciwillia@brocade.com>
To: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Cc: <dev@dpdk.org>, <mtetsuyah@gmail.com>, Wen Chiu <wchiu@brocade.com>
Subject: Re: [dpdk-dev] [PATCH 1/2] vhost: reference count fix for nb_started_ports
Date: Thu, 29 Dec 2016 10:49:08 -0500 [thread overview]
Message-ID: <a3b976d6-8fe7-733d-4a40-7c5d21d04b25@brocade.com> (raw)
In-Reply-To: <20161229085132.GC21789@yliu-dev.sh.intel.com>
On 12/29/2016 03:51 AM, Yuanhan Liu wrote:
> On Wed, Dec 28, 2016 at 04:10:51PM -0500, Charles (Chas) Williams wrote:
>> From: Wen Chiu <wchiu@brocade.com>
>>
>> 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?
No, we aren't using multiple threads for control. But eth_dev_stop()
is called in rte_pmd_vhost_remove():
static int
rte_pmd_vhost_remove(const char *name)
{
...
pthread_mutex_lock(&internal_list_lock);
TAILQ_REMOVE(&internal_list, list, next);
pthread_mutex_unlock(&internal_list_lock);
rte_free(list);
eth_dev_stop(eth_dev);
...
So, if we .dev_stop() and deatch the virtual device, eth_dev_stop()
gets called twice. Calling .dev_stop() when you are about to detach
the device seems completely reasonable. It also seems reasonable to
call eth_dev_stop() inside rte_pmd_vhost_remove() in case the end
user didn't do a .dev_stop().
prev parent reply other threads:[~2016-12-29 15:49 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-28 21:10 Charles (Chas) Williams
2016-12-28 21:10 ` [dpdk-dev] [PATCH 2/2] vhost: start vhost servers once Charles (Chas) Williams
2016-12-29 8:52 ` Yuanhan Liu
2016-12-29 15:58 ` Charles (Chas) Williams
2016-12-30 3:15 ` Yuanhan Liu
2016-12-30 21:26 ` Charles (Chas) Williams
2017-01-03 8:16 ` Yuanhan Liu
2016-12-29 8:51 ` [dpdk-dev] [PATCH 1/2] vhost: reference count fix for nb_started_ports Yuanhan Liu
2016-12-29 15:49 ` Charles (Chas) Williams [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a3b976d6-8fe7-733d-4a40-7c5d21d04b25@brocade.com \
--to=ciwillia@brocade.com \
--cc=dev@dpdk.org \
--cc=mtetsuyah@gmail.com \
--cc=wchiu@brocade.com \
--cc=yuanhan.liu@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).