* [dpdk-dev] [PATCH 0/2] Fix Vhost PMD setup
@ 2020-02-18 14:35 Maxime Coquelin
2020-02-18 14:35 ` [dpdk-dev] [PATCH 1/2] net/vhost: fix Vhost setup error path Maxime Coquelin
` (2 more replies)
0 siblings, 3 replies; 14+ messages in thread
From: Maxime Coquelin @ 2020-02-18 14:35 UTC (permalink / raw)
To: dev, oda, yinan.wang, tiwei.bie, amorenoz; +Cc: Maxime Coquelin
This series fixes regression introduced in v20.02-rc3.
First patch fixes the error path, and second one fix
Vhost device reconfigure issue reported by Yinan.
Maxime Coquelin (2):
net/vhost: fix Vhost setup error path
net/vhost: prevent multiple setup on reconfig
drivers/net/vhost/rte_eth_vhost.c | 26 +++++++++++++++++++-------
1 file changed, 19 insertions(+), 7 deletions(-)
--
2.24.1
^ permalink raw reply [flat|nested] 14+ messages in thread
* [dpdk-dev] [PATCH 1/2] net/vhost: fix Vhost setup error path
2020-02-18 14:35 [dpdk-dev] [PATCH 0/2] Fix Vhost PMD setup Maxime Coquelin
@ 2020-02-18 14:35 ` Maxime Coquelin
2020-02-18 16:15 ` David Marchand
2020-02-18 14:35 ` [dpdk-dev] [PATCH 2/2] net/vhost: prevent multiple setup on reconfig Maxime Coquelin
2020-02-18 15:24 ` [dpdk-dev] [PATCH 0/2] Fix Vhost PMD setup Wang, Yinan
2 siblings, 1 reply; 14+ messages in thread
From: Maxime Coquelin @ 2020-02-18 14:35 UTC (permalink / raw)
To: dev, oda, yinan.wang, tiwei.bie, amorenoz; +Cc: Maxime Coquelin
If for some reason vhost_driver_setup() fails, the list
element for the device may be freed without being removed
from the internal list of devices.
This patch fixes all the error paths, by unregistering the
device from Vhost library it has been registered, remove
the device from the list, reset device vring_state pointer
from the global table and only free vring state if it had
been allocated.
Fixes: 3d01b759d267 ("net/vhost: delay driver setup")
Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
---
drivers/net/vhost/rte_eth_vhost.c | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c
index 90263ae77c..c0056bc8bf 100644
--- a/drivers/net/vhost/rte_eth_vhost.c
+++ b/drivers/net/vhost/rte_eth_vhost.c
@@ -878,12 +878,12 @@ vhost_driver_setup(struct rte_eth_dev *eth_dev)
list = rte_zmalloc_socket(name, sizeof(*list), 0, numa_node);
if (list == NULL)
- goto error;
+ return -1;
vring_state = rte_zmalloc_socket(name, sizeof(*vring_state),
0, numa_node);
if (vring_state == NULL)
- goto error;
+ goto free_list;
list->eth_dev = eth_dev;
pthread_mutex_lock(&internal_list_lock);
@@ -894,30 +894,37 @@ vhost_driver_setup(struct rte_eth_dev *eth_dev)
vring_states[eth_dev->data->port_id] = vring_state;
if (rte_vhost_driver_register(internal->iface_name, internal->flags))
- goto error;
+ goto list_remove;
if (internal->disable_flags) {
if (rte_vhost_driver_disable_features(internal->iface_name,
internal->disable_flags))
- goto error;
+ goto drv_unreg;
}
if (rte_vhost_driver_callback_register(internal->iface_name,
&vhost_ops) < 0) {
VHOST_LOG(ERR, "Can't register callbacks\n");
- goto error;
+ goto drv_unreg;
}
if (rte_vhost_driver_start(internal->iface_name) < 0) {
VHOST_LOG(ERR, "Failed to start driver for %s\n",
internal->iface_name);
- goto error;
+ goto drv_unreg;
}
return 0;
-error:
+drv_unreg:
+ rte_vhost_driver_unregister(internal->iface_name);
+list_remove:
+ pthread_mutex_lock(&internal_list_lock);
+ TAILQ_REMOVE(&internal_list, list, next);
+ pthread_mutex_unlock(&internal_list_lock);
+ vring_states[eth_dev->data->port_id] = NULL;
rte_free(vring_state);
+free_list:
rte_free(list);
return -1;
--
2.24.1
^ permalink raw reply [flat|nested] 14+ messages in thread
* [dpdk-dev] [PATCH 2/2] net/vhost: prevent multiple setup on reconfig
2020-02-18 14:35 [dpdk-dev] [PATCH 0/2] Fix Vhost PMD setup Maxime Coquelin
2020-02-18 14:35 ` [dpdk-dev] [PATCH 1/2] net/vhost: fix Vhost setup error path Maxime Coquelin
@ 2020-02-18 14:35 ` Maxime Coquelin
2020-02-18 15:26 ` Maxime Coquelin
` (2 more replies)
2020-02-18 15:24 ` [dpdk-dev] [PATCH 0/2] Fix Vhost PMD setup Wang, Yinan
2 siblings, 3 replies; 14+ messages in thread
From: Maxime Coquelin @ 2020-02-18 14:35 UTC (permalink / raw)
To: dev, oda, yinan.wang, tiwei.bie, amorenoz; +Cc: Maxime Coquelin
Ethdev's .dev_configure callback can be called multiple
time during a device life-time, but Vhost makes the
wrong assumption that it is not the case and try to
setup again the device on reconfiguration.
This patch ensures the device hasn't been already setup
before proceeding.
Fixes: 3d01b759d267 ("net/vhost: delay driver setup")
Reported-by: Yinan Wang <yinan.wang@intel.com>
Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
---
drivers/net/vhost/rte_eth_vhost.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c
index c0056bc8bf..c4643da120 100644
--- a/drivers/net/vhost/rte_eth_vhost.c
+++ b/drivers/net/vhost/rte_eth_vhost.c
@@ -876,6 +876,11 @@ vhost_driver_setup(struct rte_eth_dev *eth_dev)
unsigned int numa_node = eth_dev->device->numa_node;
const char *name = eth_dev->device->name;
+ /* Don't try to setup again if it has already been done. */
+ list = find_internal_resource(internal->iface_name);
+ if (list)
+ return 0;
+
list = rte_zmalloc_socket(name, sizeof(*list), 0, numa_node);
if (list == NULL)
return -1;
--
2.24.1
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [dpdk-dev] [PATCH 0/2] Fix Vhost PMD setup
2020-02-18 14:35 [dpdk-dev] [PATCH 0/2] Fix Vhost PMD setup Maxime Coquelin
2020-02-18 14:35 ` [dpdk-dev] [PATCH 1/2] net/vhost: fix Vhost setup error path Maxime Coquelin
2020-02-18 14:35 ` [dpdk-dev] [PATCH 2/2] net/vhost: prevent multiple setup on reconfig Maxime Coquelin
@ 2020-02-18 15:24 ` Wang, Yinan
2020-02-18 15:25 ` Maxime Coquelin
2 siblings, 1 reply; 14+ messages in thread
From: Wang, Yinan @ 2020-02-18 15:24 UTC (permalink / raw)
To: Maxime Coquelin, dev, oda, Bie, Tiwei, amorenoz
This patch set can fix Vhost device reconfigure issue, thanks!
> -----Original Message-----
> From: Maxime Coquelin <maxime.coquelin@redhat.com>
> Sent: 2020年2月18日 22:35
> To: dev@dpdk.org; oda@valinux.co.jp; Wang, Yinan <yinan.wang@intel.com>;
> Bie, Tiwei <tiwei.bie@intel.com>; amorenoz@redhat.com
> Cc: Maxime Coquelin <maxime.coquelin@redhat.com>
> Subject: [PATCH 0/2] Fix Vhost PMD setup
>
> This series fixes regression introduced in v20.02-rc3.
> First patch fixes the error path, and second one fix Vhost device reconfigure
> issue reported by Yinan.
>
> Maxime Coquelin (2):
> net/vhost: fix Vhost setup error path
> net/vhost: prevent multiple setup on reconfig
>
> drivers/net/vhost/rte_eth_vhost.c | 26 +++++++++++++++++++-------
> 1 file changed, 19 insertions(+), 7 deletions(-)
>
> --
> 2.24.1
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [dpdk-dev] [PATCH 0/2] Fix Vhost PMD setup
2020-02-18 15:24 ` [dpdk-dev] [PATCH 0/2] Fix Vhost PMD setup Wang, Yinan
@ 2020-02-18 15:25 ` Maxime Coquelin
0 siblings, 0 replies; 14+ messages in thread
From: Maxime Coquelin @ 2020-02-18 15:25 UTC (permalink / raw)
To: Wang, Yinan, dev, oda, Bie, Tiwei, amorenoz
On 2/18/20 4:24 PM, Wang, Yinan wrote:
> This patch set can fix Vhost device reconfigure issue, thanks!
Thanks for the quick test, I'll ask your Tested-by on patch 2.
Maxime
>
>> -----Original Message-----
>> From: Maxime Coquelin <maxime.coquelin@redhat.com>
>> Sent: 2020年2月18日 22:35
>> To: dev@dpdk.org; oda@valinux.co.jp; Wang, Yinan <yinan.wang@intel.com>;
>> Bie, Tiwei <tiwei.bie@intel.com>; amorenoz@redhat.com
>> Cc: Maxime Coquelin <maxime.coquelin@redhat.com>
>> Subject: [PATCH 0/2] Fix Vhost PMD setup
>>
>> This series fixes regression introduced in v20.02-rc3.
>> First patch fixes the error path, and second one fix Vhost device reconfigure
>> issue reported by Yinan.
>>
>> Maxime Coquelin (2):
>> net/vhost: fix Vhost setup error path
>> net/vhost: prevent multiple setup on reconfig
>>
>> drivers/net/vhost/rte_eth_vhost.c | 26 +++++++++++++++++++-------
>> 1 file changed, 19 insertions(+), 7 deletions(-)
>>
>> --
>> 2.24.1
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [dpdk-dev] [PATCH 2/2] net/vhost: prevent multiple setup on reconfig
2020-02-18 14:35 ` [dpdk-dev] [PATCH 2/2] net/vhost: prevent multiple setup on reconfig Maxime Coquelin
@ 2020-02-18 15:26 ` Maxime Coquelin
2020-02-18 15:27 ` Wang, Yinan
2020-02-18 16:16 ` David Marchand
2 siblings, 0 replies; 14+ messages in thread
From: Maxime Coquelin @ 2020-02-18 15:26 UTC (permalink / raw)
To: dev, oda, yinan.wang, tiwei.bie, amorenoz
On 2/18/20 3:35 PM, Maxime Coquelin wrote:
> Ethdev's .dev_configure callback can be called multiple
> time during a device life-time, but Vhost makes the
> wrong assumption that it is not the case and try to
> setup again the device on reconfiguration.
>
> This patch ensures the device hasn't been already setup
> before proceeding.
>
> Fixes: 3d01b759d267 ("net/vhost: delay driver setup")
>
> Reported-by: Yinan Wang <yinan.wang@intel.com>
> Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
> ---
> drivers/net/vhost/rte_eth_vhost.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c
> index c0056bc8bf..c4643da120 100644
> --- a/drivers/net/vhost/rte_eth_vhost.c
> +++ b/drivers/net/vhost/rte_eth_vhost.c
> @@ -876,6 +876,11 @@ vhost_driver_setup(struct rte_eth_dev *eth_dev)
> unsigned int numa_node = eth_dev->device->numa_node;
> const char *name = eth_dev->device->name;
>
> + /* Don't try to setup again if it has already been done. */
> + list = find_internal_resource(internal->iface_name);
> + if (list)
> + return 0;
> +
> list = rte_zmalloc_socket(name, sizeof(*list), 0, numa_node);
> if (list == NULL)
> return -1;
>
Following Yinan's reply to cover letter:
Tested-by: Yinan Wang <yinan.wang@intel.com>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [dpdk-dev] [PATCH 2/2] net/vhost: prevent multiple setup on reconfig
2020-02-18 14:35 ` [dpdk-dev] [PATCH 2/2] net/vhost: prevent multiple setup on reconfig Maxime Coquelin
2020-02-18 15:26 ` Maxime Coquelin
@ 2020-02-18 15:27 ` Wang, Yinan
2020-02-18 16:16 ` David Marchand
2 siblings, 0 replies; 14+ messages in thread
From: Wang, Yinan @ 2020-02-18 15:27 UTC (permalink / raw)
To: Maxime Coquelin, dev, oda, Bie, Tiwei, amorenoz
Tested-by: Yinan Wang <yinan.wang@intel.com>
> -----Original Message-----
> From: Maxime Coquelin <maxime.coquelin@redhat.com>
> Sent: 2020年2月18日 22:35
> To: dev@dpdk.org; oda@valinux.co.jp; Wang, Yinan <yinan.wang@intel.com>;
> Bie, Tiwei <tiwei.bie@intel.com>; amorenoz@redhat.com
> Cc: Maxime Coquelin <maxime.coquelin@redhat.com>
> Subject: [PATCH 2/2] net/vhost: prevent multiple setup on reconfig
>
> Ethdev's .dev_configure callback can be called multiple time during a device
> life-time, but Vhost makes the wrong assumption that it is not the case and try
> to setup again the device on reconfiguration.
>
> This patch ensures the device hasn't been already setup before proceeding.
>
> Fixes: 3d01b759d267 ("net/vhost: delay driver setup")
>
> Reported-by: Yinan Wang <yinan.wang@intel.com>
> Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
> ---
> drivers/net/vhost/rte_eth_vhost.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/net/vhost/rte_eth_vhost.c
> b/drivers/net/vhost/rte_eth_vhost.c
> index c0056bc8bf..c4643da120 100644
> --- a/drivers/net/vhost/rte_eth_vhost.c
> +++ b/drivers/net/vhost/rte_eth_vhost.c
> @@ -876,6 +876,11 @@ vhost_driver_setup(struct rte_eth_dev *eth_dev)
> unsigned int numa_node = eth_dev->device->numa_node;
> const char *name = eth_dev->device->name;
>
> + /* Don't try to setup again if it has already been done. */
> + list = find_internal_resource(internal->iface_name);
> + if (list)
> + return 0;
> +
> list = rte_zmalloc_socket(name, sizeof(*list), 0, numa_node);
> if (list == NULL)
> return -1;
> --
> 2.24.1
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [dpdk-dev] [PATCH 1/2] net/vhost: fix Vhost setup error path
2020-02-18 14:35 ` [dpdk-dev] [PATCH 1/2] net/vhost: fix Vhost setup error path Maxime Coquelin
@ 2020-02-18 16:15 ` David Marchand
2020-02-18 16:25 ` Maxime Coquelin
0 siblings, 1 reply; 14+ messages in thread
From: David Marchand @ 2020-02-18 16:15 UTC (permalink / raw)
To: Maxime Coquelin; +Cc: dev, oda, yinan.wang, Tiwei Bie, Adrian Moreno Zapata
On Tue, Feb 18, 2020 at 3:35 PM Maxime Coquelin
<maxime.coquelin@redhat.com> wrote:
>
> If for some reason vhost_driver_setup() fails, the list
> element for the device may be freed without being removed
> from the internal list of devices.
>
> This patch fixes all the error paths, by unregistering the
> device from Vhost library it has been registered, remove
> the device from the list, reset device vring_state pointer
> from the global table and only free vring state if it had
> been allocated.
>
> Fixes: 3d01b759d267 ("net/vhost: delay driver setup")
>
> Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
> ---
> drivers/net/vhost/rte_eth_vhost.c | 21 ++++++++++++++-------
> 1 file changed, 14 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c
> index 90263ae77c..c0056bc8bf 100644
> --- a/drivers/net/vhost/rte_eth_vhost.c
> +++ b/drivers/net/vhost/rte_eth_vhost.c
> @@ -878,12 +878,12 @@ vhost_driver_setup(struct rte_eth_dev *eth_dev)
>
> list = rte_zmalloc_socket(name, sizeof(*list), 0, numa_node);
> if (list == NULL)
> - goto error;
> + return -1;
>
> vring_state = rte_zmalloc_socket(name, sizeof(*vring_state),
> 0, numa_node);
> if (vring_state == NULL)
> - goto error;
> + goto free_list;
>
> list->eth_dev = eth_dev;
> pthread_mutex_lock(&internal_list_lock);
> @@ -894,30 +894,37 @@ vhost_driver_setup(struct rte_eth_dev *eth_dev)
> vring_states[eth_dev->data->port_id] = vring_state;
>
> if (rte_vhost_driver_register(internal->iface_name, internal->flags))
> - goto error;
> + goto list_remove;
>
> if (internal->disable_flags) {
> if (rte_vhost_driver_disable_features(internal->iface_name,
> internal->disable_flags))
> - goto error;
> + goto drv_unreg;
> }
>
> if (rte_vhost_driver_callback_register(internal->iface_name,
> &vhost_ops) < 0) {
> VHOST_LOG(ERR, "Can't register callbacks\n");
> - goto error;
> + goto drv_unreg;
> }
>
> if (rte_vhost_driver_start(internal->iface_name) < 0) {
> VHOST_LOG(ERR, "Failed to start driver for %s\n",
> internal->iface_name);
> - goto error;
> + goto drv_unreg;
> }
>
> return 0;
>
> -error:
> +drv_unreg:
> + rte_vhost_driver_unregister(internal->iface_name);
> +list_remove:
> + pthread_mutex_lock(&internal_list_lock);
> + TAILQ_REMOVE(&internal_list, list, next);
> + pthread_mutex_unlock(&internal_list_lock);
> + vring_states[eth_dev->data->port_id] = NULL;
We allocate/store in vring_states after inserting list in &internal_list.
Probably nitpicking but I would expect the opposite order on cleanup.
> rte_free(vring_state);
> +free_list:
> rte_free(list);
>
> return -1;
> --
> 2.24.1
>
In any case,
Reviewed-by: David Marchand <david.marchand@redhat.com>
--
David Marchand
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [dpdk-dev] [PATCH 2/2] net/vhost: prevent multiple setup on reconfig
2020-02-18 14:35 ` [dpdk-dev] [PATCH 2/2] net/vhost: prevent multiple setup on reconfig Maxime Coquelin
2020-02-18 15:26 ` Maxime Coquelin
2020-02-18 15:27 ` Wang, Yinan
@ 2020-02-18 16:16 ` David Marchand
2 siblings, 0 replies; 14+ messages in thread
From: David Marchand @ 2020-02-18 16:16 UTC (permalink / raw)
To: Maxime Coquelin; +Cc: dev, oda, yinan.wang, Tiwei Bie, Adrian Moreno Zapata
On Tue, Feb 18, 2020 at 3:35 PM Maxime Coquelin
<maxime.coquelin@redhat.com> wrote:
>
> Ethdev's .dev_configure callback can be called multiple
> time during a device life-time, but Vhost makes the
> wrong assumption that it is not the case and try to
> setup again the device on reconfiguration.
>
> This patch ensures the device hasn't been already setup
> before proceeding.
>
> Fixes: 3d01b759d267 ("net/vhost: delay driver setup")
>
> Reported-by: Yinan Wang <yinan.wang@intel.com>
> Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
> ---
> drivers/net/vhost/rte_eth_vhost.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c
> index c0056bc8bf..c4643da120 100644
> --- a/drivers/net/vhost/rte_eth_vhost.c
> +++ b/drivers/net/vhost/rte_eth_vhost.c
> @@ -876,6 +876,11 @@ vhost_driver_setup(struct rte_eth_dev *eth_dev)
> unsigned int numa_node = eth_dev->device->numa_node;
> const char *name = eth_dev->device->name;
>
> + /* Don't try to setup again if it has already been done. */
> + list = find_internal_resource(internal->iface_name);
> + if (list)
> + return 0;
> +
> list = rte_zmalloc_socket(name, sizeof(*list), 0, numa_node);
> if (list == NULL)
> return -1;
> --
> 2.24.1
>
Reviewed-by: David Marchand <david.marchand@redhat.com>
--
David Marchand
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [dpdk-dev] [PATCH 1/2] net/vhost: fix Vhost setup error path
2020-02-18 16:15 ` David Marchand
@ 2020-02-18 16:25 ` Maxime Coquelin
0 siblings, 0 replies; 14+ messages in thread
From: Maxime Coquelin @ 2020-02-18 16:25 UTC (permalink / raw)
To: David Marchand; +Cc: dev, oda, yinan.wang, Tiwei Bie, Adrian Moreno Zapata
On 2/18/20 5:15 PM, David Marchand wrote:
> On Tue, Feb 18, 2020 at 3:35 PM Maxime Coquelin
> <maxime.coquelin@redhat.com> wrote:
>>
>> If for some reason vhost_driver_setup() fails, the list
>> element for the device may be freed without being removed
>> from the internal list of devices.
>>
>> This patch fixes all the error paths, by unregistering the
>> device from Vhost library it has been registered, remove
>> the device from the list, reset device vring_state pointer
>> from the global table and only free vring state if it had
>> been allocated.
>>
>> Fixes: 3d01b759d267 ("net/vhost: delay driver setup")
>>
>> Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
>> ---
>> drivers/net/vhost/rte_eth_vhost.c | 21 ++++++++++++++-------
>> 1 file changed, 14 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c
>> index 90263ae77c..c0056bc8bf 100644
>> --- a/drivers/net/vhost/rte_eth_vhost.c
>> +++ b/drivers/net/vhost/rte_eth_vhost.c
>> @@ -878,12 +878,12 @@ vhost_driver_setup(struct rte_eth_dev *eth_dev)
>>
>> list = rte_zmalloc_socket(name, sizeof(*list), 0, numa_node);
>> if (list == NULL)
>> - goto error;
>> + return -1;
>>
>> vring_state = rte_zmalloc_socket(name, sizeof(*vring_state),
>> 0, numa_node);
>> if (vring_state == NULL)
>> - goto error;
>> + goto free_list;
>>
>> list->eth_dev = eth_dev;
>> pthread_mutex_lock(&internal_list_lock);
>> @@ -894,30 +894,37 @@ vhost_driver_setup(struct rte_eth_dev *eth_dev)
>> vring_states[eth_dev->data->port_id] = vring_state;
>>
>> if (rte_vhost_driver_register(internal->iface_name, internal->flags))
>> - goto error;
>> + goto list_remove;
>>
>> if (internal->disable_flags) {
>> if (rte_vhost_driver_disable_features(internal->iface_name,
>> internal->disable_flags))
>> - goto error;
>> + goto drv_unreg;
>> }
>>
>> if (rte_vhost_driver_callback_register(internal->iface_name,
>> &vhost_ops) < 0) {
>> VHOST_LOG(ERR, "Can't register callbacks\n");
>> - goto error;
>> + goto drv_unreg;
>> }
>>
>> if (rte_vhost_driver_start(internal->iface_name) < 0) {
>> VHOST_LOG(ERR, "Failed to start driver for %s\n",
>> internal->iface_name);
>> - goto error;
>> + goto drv_unreg;
>> }
>>
>> return 0;
>>
>> -error:
>> +drv_unreg:
>> + rte_vhost_driver_unregister(internal->iface_name);
>> +list_remove:
>> + pthread_mutex_lock(&internal_list_lock);
>> + TAILQ_REMOVE(&internal_list, list, next);
>> + pthread_mutex_unlock(&internal_list_lock);
>> + vring_states[eth_dev->data->port_id] = NULL;
>
> We allocate/store in vring_states after inserting list in &internal_list.
> Probably nitpicking but I would expect the opposite order on cleanup.
No nitpicking, it is a good practice to cleanup in opposite order.
I will post a v2.
>
>> rte_free(vring_state);
>> +free_list:
>> rte_free(list);
>>
>> return -1;
>> --
>> 2.24.1
>>
>
> In any case,
> Reviewed-by: David Marchand <david.marchand@redhat.com>
>
Thanks!
Maxime
>
> --
> David Marchand
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [dpdk-dev] [PATCH 2/2] net/vhost: prevent multiple setup on reconfig
2020-02-19 8:17 ` Maxime Coquelin
@ 2020-02-19 22:17 ` Itsuro ODA
0 siblings, 0 replies; 14+ messages in thread
From: Itsuro ODA @ 2020-02-19 22:17 UTC (permalink / raw)
To: Maxime Coquelin; +Cc: Tiwei Bie, dev, yinan.wang, amorenoz, david.marchand
Hi Maxime, Tiewi,
On Wed, 19 Feb 2020 09:17:41 +0100
Maxime Coquelin <maxime.coquelin@redhat.com> wrote:
> Hi Tiwei,
>
> On 2/19/20 4:44 AM, Tiwei Bie wrote:
> > On Tue, Feb 18, 2020 at 06:22:40PM +0100, Maxime Coquelin wrote:
> >> Ethdev's .dev_configure callback can be called multiple
> >> time during a device life-time, but Vhost makes the
> >> wrong assumption that it is not the case and try to
> >> setup again the device on reconfiguration.
> >>
> >> This patch ensures the device hasn't been already setup
> >> before proceeding.
> >>
> >> Fixes: 3d01b759d267 ("net/vhost: delay driver setup")
> >>
> >> Reported-by: Yinan Wang <yinan.wang@intel.com>
> >> Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
> >> Tested-by: Yinan Wang <yinan.wang@intel.com>
> >> Reviewed-by: David Marchand <david.marchand@redhat.com>
> >> ---
> >> drivers/net/vhost/rte_eth_vhost.c | 5 +++++
> >> 1 file changed, 5 insertions(+)
> >>
> >> diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c
> >> index 4a7b1b608c..458ed58f5f 100644
> >> --- a/drivers/net/vhost/rte_eth_vhost.c
> >> +++ b/drivers/net/vhost/rte_eth_vhost.c
> >> @@ -876,6 +876,11 @@ vhost_driver_setup(struct rte_eth_dev *eth_dev)
> >> unsigned int numa_node = eth_dev->device->numa_node;
> >> const char *name = eth_dev->device->name;
> >>
> >> + /* Don't try to setup again if it has already been done. */
> >> + list = find_internal_resource(internal->iface_name);
> >> + if (list)
> >> + return 0;
> >> +
> >> list = rte_zmalloc_socket(name, sizeof(*list), 0, numa_node);
> >> if (list == NULL)
> >> return -1;
> >> --
> >> 2.24.1
> >
> > Thanks Maxime for the fix!
> >
> > Reviewed-by: Tiwei Bie <tiwei.bie@intel.com>
> >
> > Not related to this fix, it seems there is a potential leak after
> > delaying the driver setup to _configure, as the list won't be
> > registered until users configure the device. So internal->iface_name
> > allocated in _create will leak if the device is released without
> > doing _configure first.
> >
> > https://github.com/DPDK/dpdk/blob/e6c78e736d77/drivers/net/vhost/rte_eth_vhost.c#L1058
> > https://github.com/DPDK/dpdk/blob/e6c78e736d77/drivers/net/vhost/rte_eth_vhost.c#L1075
> >
> > It's not a common case and it's quite late in this release,
> > probably it's fine to fix it later.
>
> That's a valid point, and I also agree there is no urgency for v20.02.
> Itsuro, would you take care of fixing it for v20.05?
Sure, I will do it.
Thanks.
Itsuro Oda
> Thanks,
> Maxime
> > Thanks,
> > Tiwei
> >
--
Itsuro ODA <oda@valinux.co.jp>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [dpdk-dev] [PATCH 2/2] net/vhost: prevent multiple setup on reconfig
2020-02-19 3:44 ` Tiwei Bie
@ 2020-02-19 8:17 ` Maxime Coquelin
2020-02-19 22:17 ` Itsuro ODA
0 siblings, 1 reply; 14+ messages in thread
From: Maxime Coquelin @ 2020-02-19 8:17 UTC (permalink / raw)
To: Tiwei Bie, oda; +Cc: dev, yinan.wang, amorenoz, david.marchand
Hi Tiwei,
On 2/19/20 4:44 AM, Tiwei Bie wrote:
> On Tue, Feb 18, 2020 at 06:22:40PM +0100, Maxime Coquelin wrote:
>> Ethdev's .dev_configure callback can be called multiple
>> time during a device life-time, but Vhost makes the
>> wrong assumption that it is not the case and try to
>> setup again the device on reconfiguration.
>>
>> This patch ensures the device hasn't been already setup
>> before proceeding.
>>
>> Fixes: 3d01b759d267 ("net/vhost: delay driver setup")
>>
>> Reported-by: Yinan Wang <yinan.wang@intel.com>
>> Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
>> Tested-by: Yinan Wang <yinan.wang@intel.com>
>> Reviewed-by: David Marchand <david.marchand@redhat.com>
>> ---
>> drivers/net/vhost/rte_eth_vhost.c | 5 +++++
>> 1 file changed, 5 insertions(+)
>>
>> diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c
>> index 4a7b1b608c..458ed58f5f 100644
>> --- a/drivers/net/vhost/rte_eth_vhost.c
>> +++ b/drivers/net/vhost/rte_eth_vhost.c
>> @@ -876,6 +876,11 @@ vhost_driver_setup(struct rte_eth_dev *eth_dev)
>> unsigned int numa_node = eth_dev->device->numa_node;
>> const char *name = eth_dev->device->name;
>>
>> + /* Don't try to setup again if it has already been done. */
>> + list = find_internal_resource(internal->iface_name);
>> + if (list)
>> + return 0;
>> +
>> list = rte_zmalloc_socket(name, sizeof(*list), 0, numa_node);
>> if (list == NULL)
>> return -1;
>> --
>> 2.24.1
>
> Thanks Maxime for the fix!
>
> Reviewed-by: Tiwei Bie <tiwei.bie@intel.com>
>
> Not related to this fix, it seems there is a potential leak after
> delaying the driver setup to _configure, as the list won't be
> registered until users configure the device. So internal->iface_name
> allocated in _create will leak if the device is released without
> doing _configure first.
>
> https://github.com/DPDK/dpdk/blob/e6c78e736d77/drivers/net/vhost/rte_eth_vhost.c#L1058
> https://github.com/DPDK/dpdk/blob/e6c78e736d77/drivers/net/vhost/rte_eth_vhost.c#L1075
>
> It's not a common case and it's quite late in this release,
> probably it's fine to fix it later.
That's a valid point, and I also agree there is no urgency for v20.02.
Itsuro, would you take care of fixing it for v20.05?
Thanks,
Maxime
> Thanks,
> Tiwei
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [dpdk-dev] [PATCH 2/2] net/vhost: prevent multiple setup on reconfig
2020-02-18 17:22 ` [dpdk-dev] [PATCH 2/2] net/vhost: prevent multiple setup on reconfig Maxime Coquelin
@ 2020-02-19 3:44 ` Tiwei Bie
2020-02-19 8:17 ` Maxime Coquelin
0 siblings, 1 reply; 14+ messages in thread
From: Tiwei Bie @ 2020-02-19 3:44 UTC (permalink / raw)
To: Maxime Coquelin, oda; +Cc: dev, yinan.wang, amorenoz, david.marchand
On Tue, Feb 18, 2020 at 06:22:40PM +0100, Maxime Coquelin wrote:
> Ethdev's .dev_configure callback can be called multiple
> time during a device life-time, but Vhost makes the
> wrong assumption that it is not the case and try to
> setup again the device on reconfiguration.
>
> This patch ensures the device hasn't been already setup
> before proceeding.
>
> Fixes: 3d01b759d267 ("net/vhost: delay driver setup")
>
> Reported-by: Yinan Wang <yinan.wang@intel.com>
> Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
> Tested-by: Yinan Wang <yinan.wang@intel.com>
> Reviewed-by: David Marchand <david.marchand@redhat.com>
> ---
> drivers/net/vhost/rte_eth_vhost.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c
> index 4a7b1b608c..458ed58f5f 100644
> --- a/drivers/net/vhost/rte_eth_vhost.c
> +++ b/drivers/net/vhost/rte_eth_vhost.c
> @@ -876,6 +876,11 @@ vhost_driver_setup(struct rte_eth_dev *eth_dev)
> unsigned int numa_node = eth_dev->device->numa_node;
> const char *name = eth_dev->device->name;
>
> + /* Don't try to setup again if it has already been done. */
> + list = find_internal_resource(internal->iface_name);
> + if (list)
> + return 0;
> +
> list = rte_zmalloc_socket(name, sizeof(*list), 0, numa_node);
> if (list == NULL)
> return -1;
> --
> 2.24.1
Thanks Maxime for the fix!
Reviewed-by: Tiwei Bie <tiwei.bie@intel.com>
Not related to this fix, it seems there is a potential leak after
delaying the driver setup to _configure, as the list won't be
registered until users configure the device. So internal->iface_name
allocated in _create will leak if the device is released without
doing _configure first.
https://github.com/DPDK/dpdk/blob/e6c78e736d77/drivers/net/vhost/rte_eth_vhost.c#L1058
https://github.com/DPDK/dpdk/blob/e6c78e736d77/drivers/net/vhost/rte_eth_vhost.c#L1075
It's not a common case and it's quite late in this release,
probably it's fine to fix it later.
Thanks,
Tiwei
^ permalink raw reply [flat|nested] 14+ messages in thread
* [dpdk-dev] [PATCH 2/2] net/vhost: prevent multiple setup on reconfig
2020-02-18 17:22 Maxime Coquelin
@ 2020-02-18 17:22 ` Maxime Coquelin
2020-02-19 3:44 ` Tiwei Bie
0 siblings, 1 reply; 14+ messages in thread
From: Maxime Coquelin @ 2020-02-18 17:22 UTC (permalink / raw)
To: dev, oda, yinan.wang, tiwei.bie, amorenoz, david.marchand; +Cc: Maxime Coquelin
Ethdev's .dev_configure callback can be called multiple
time during a device life-time, but Vhost makes the
wrong assumption that it is not the case and try to
setup again the device on reconfiguration.
This patch ensures the device hasn't been already setup
before proceeding.
Fixes: 3d01b759d267 ("net/vhost: delay driver setup")
Reported-by: Yinan Wang <yinan.wang@intel.com>
Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Tested-by: Yinan Wang <yinan.wang@intel.com>
Reviewed-by: David Marchand <david.marchand@redhat.com>
---
drivers/net/vhost/rte_eth_vhost.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c
index 4a7b1b608c..458ed58f5f 100644
--- a/drivers/net/vhost/rte_eth_vhost.c
+++ b/drivers/net/vhost/rte_eth_vhost.c
@@ -876,6 +876,11 @@ vhost_driver_setup(struct rte_eth_dev *eth_dev)
unsigned int numa_node = eth_dev->device->numa_node;
const char *name = eth_dev->device->name;
+ /* Don't try to setup again if it has already been done. */
+ list = find_internal_resource(internal->iface_name);
+ if (list)
+ return 0;
+
list = rte_zmalloc_socket(name, sizeof(*list), 0, numa_node);
if (list == NULL)
return -1;
--
2.24.1
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2020-02-19 22:17 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-18 14:35 [dpdk-dev] [PATCH 0/2] Fix Vhost PMD setup Maxime Coquelin
2020-02-18 14:35 ` [dpdk-dev] [PATCH 1/2] net/vhost: fix Vhost setup error path Maxime Coquelin
2020-02-18 16:15 ` David Marchand
2020-02-18 16:25 ` Maxime Coquelin
2020-02-18 14:35 ` [dpdk-dev] [PATCH 2/2] net/vhost: prevent multiple setup on reconfig Maxime Coquelin
2020-02-18 15:26 ` Maxime Coquelin
2020-02-18 15:27 ` Wang, Yinan
2020-02-18 16:16 ` David Marchand
2020-02-18 15:24 ` [dpdk-dev] [PATCH 0/2] Fix Vhost PMD setup Wang, Yinan
2020-02-18 15:25 ` Maxime Coquelin
2020-02-18 17:22 Maxime Coquelin
2020-02-18 17:22 ` [dpdk-dev] [PATCH 2/2] net/vhost: prevent multiple setup on reconfig Maxime Coquelin
2020-02-19 3:44 ` Tiwei Bie
2020-02-19 8:17 ` Maxime Coquelin
2020-02-19 22:17 ` Itsuro ODA
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).