[v2] net/vhost: fix redundant queue state event

Message ID 1561012383-306353-1-git-send-email-noae@mellanox.com (mailing list archive)
State Accepted, archived
Delegated to: Maxime Coquelin
Headers
Series [v2] net/vhost: fix redundant queue state event |

Checks

Context Check Description
ci/Intel-compilation fail apply issues
ci/checkpatch success coding style OK

Commit Message

Noa Ezra June 20, 2019, 6:33 a.m. UTC
  In some situations, when a virtual machine is starting,
vring_state_changed can be called while there was no change in the
queue state. This fix makes sure that there was really a change in the
queue state before calling the callback for EVENT_QUEUE_STATE.

Fixes: ee584e9710b9 ("vhost: add driver on top of the library")
Cc: stable@dpdk.org

Signed-off-by: Noa Ezra <noae@mellanox.com>
Reviewed-by: Matan Azrad <matan@mellanox.com>
---
v2 remove checkpatch warnings
---
 drivers/net/vhost/rte_eth_vhost.c | 4 ++++
 1 file changed, 4 insertions(+)
  

Comments

Maxime Coquelin Sept. 27, 2019, 8:49 a.m. UTC | #1
On 6/20/19 8:33 AM, Noa Ezra wrote:
> In some situations, when a virtual machine is starting,
> vring_state_changed can be called while there was no change in the
> queue state. This fix makes sure that there was really a change in the
> queue state before calling the callback for EVENT_QUEUE_STATE.
> 
> Fixes: ee584e9710b9 ("vhost: add driver on top of the library")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Noa Ezra <noae@mellanox.com>
> Reviewed-by: Matan Azrad <matan@mellanox.com>
> ---
> v2 remove checkpatch warnings
> ---
>  drivers/net/vhost/rte_eth_vhost.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c
> index cad1e5c..fbe7a37 100644
> --- a/drivers/net/vhost/rte_eth_vhost.c
> +++ b/drivers/net/vhost/rte_eth_vhost.c
> @@ -855,6 +855,10 @@ struct vhost_xstats_name_off {
>  	/* won't be NULL */
>  	state = vring_states[eth_dev->data->port_id];
>  	rte_spinlock_lock(&state->lock);
> +	if (state->cur[vring] == enable) {
> +		rte_spinlock_unlock(&state->lock);
> +		return 0;
> +	}
>  
>  	state->cur[vring] = enable;
>  	state->max_vring = RTE_MAX(vring, state->max_vring);
> 

Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>

Thanks,
Maxime
  
Maxime Coquelin Sept. 27, 2019, 9:49 a.m. UTC | #2
On 9/27/19 10:49 AM, Maxime Coquelin wrote:
> 
> 
> On 6/20/19 8:33 AM, Noa Ezra wrote:
>> In some situations, when a virtual machine is starting,
>> vring_state_changed can be called while there was no change in the
>> queue state. This fix makes sure that there was really a change in the
>> queue state before calling the callback for EVENT_QUEUE_STATE.
>>
>> Fixes: ee584e9710b9 ("vhost: add driver on top of the library")
>> Cc: stable@dpdk.org
>>
>> Signed-off-by: Noa Ezra <noae@mellanox.com>
>> Reviewed-by: Matan Azrad <matan@mellanox.com>
>> ---
>> v2 remove checkpatch warnings
>> ---
>>  drivers/net/vhost/rte_eth_vhost.c | 4 ++++
>>  1 file changed, 4 insertions(+)
>>
>> diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c
>> index cad1e5c..fbe7a37 100644
>> --- a/drivers/net/vhost/rte_eth_vhost.c
>> +++ b/drivers/net/vhost/rte_eth_vhost.c
>> @@ -855,6 +855,10 @@ struct vhost_xstats_name_off {
>>  	/* won't be NULL */
>>  	state = vring_states[eth_dev->data->port_id];
>>  	rte_spinlock_lock(&state->lock);
>> +	if (state->cur[vring] == enable) {
>> +		rte_spinlock_unlock(&state->lock);
>> +		return 0;
>> +	}
>>  
>>  	state->cur[vring] = enable;
>>  	state->max_vring = RTE_MAX(vring, state->max_vring);
>>
> 
> Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
> 
> Thanks,
> Maxime
> 

Applied to dpdk-next-virtio/master.

Thanks,
Maxime
  

Patch

diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c
index cad1e5c..fbe7a37 100644
--- a/drivers/net/vhost/rte_eth_vhost.c
+++ b/drivers/net/vhost/rte_eth_vhost.c
@@ -855,6 +855,10 @@  struct vhost_xstats_name_off {
 	/* won't be NULL */
 	state = vring_states[eth_dev->data->port_id];
 	rte_spinlock_lock(&state->lock);
+	if (state->cur[vring] == enable) {
+		rte_spinlock_unlock(&state->lock);
+		return 0;
+	}
 
 	state->cur[vring] = enable;
 	state->max_vring = RTE_MAX(vring, state->max_vring);