patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [PATCH] vhost: fix zmbufs array leak after NUMA realloc
       [not found] <CGME20180815145341eucas1p15832e119a9d6f3fc54796675a283c44f@eucas1p1.samsung.com>
@ 2018-08-15 14:54 ` Ilya Maximets
  2018-08-16  5:31   ` Tiwei Bie
  2018-09-10 13:38   ` Maxime Coquelin
  0 siblings, 2 replies; 3+ messages in thread
From: Ilya Maximets @ 2018-08-15 14:54 UTC (permalink / raw)
  To: dev
  Cc: Maxime Coquelin, Tiwei Bie, Zhihong Wang, Junjie Chen,
	Ilya Maximets, stable

'numa_realloc()' allocates 'zmbufs' even if zero copy mode
is not configured. This leads to memory leak, because array
is freed only for zero copy case.

Fixes: 2651726defb7 ("vhost: do deep copy while reallocating queue")
CC: stable@dpdk.org

Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
---
 lib/librte_vhost/vhost_user.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
index a2d4c9ffc..9aa1ce118 100644
--- a/lib/librte_vhost/vhost_user.c
+++ b/lib/librte_vhost/vhost_user.c
@@ -357,11 +357,13 @@ numa_realloc(struct virtio_net *dev, int index)
 		memcpy(vq, old_vq, sizeof(*vq));
 		TAILQ_INIT(&vq->zmbuf_list);
 
-		new_zmbuf = rte_malloc_socket(NULL, vq->zmbuf_size *
-			sizeof(struct zcopy_mbuf), 0, newnode);
-		if (new_zmbuf) {
-			rte_free(vq->zmbufs);
-			vq->zmbufs = new_zmbuf;
+		if (dev->dequeue_zero_copy) {
+			new_zmbuf = rte_malloc_socket(NULL, vq->zmbuf_size *
+					sizeof(struct zcopy_mbuf), 0, newnode);
+			if (new_zmbuf) {
+				rte_free(vq->zmbufs);
+				vq->zmbufs = new_zmbuf;
+			}
 		}
 
 		if (vq_is_packed(dev)) {
-- 
2.17.1

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-stable] [PATCH] vhost: fix zmbufs array leak after NUMA realloc
  2018-08-15 14:54 ` [dpdk-stable] [PATCH] vhost: fix zmbufs array leak after NUMA realloc Ilya Maximets
@ 2018-08-16  5:31   ` Tiwei Bie
  2018-09-10 13:38   ` Maxime Coquelin
  1 sibling, 0 replies; 3+ messages in thread
From: Tiwei Bie @ 2018-08-16  5:31 UTC (permalink / raw)
  To: Ilya Maximets; +Cc: dev, Maxime Coquelin, Zhihong Wang, Junjie Chen, stable

On Wed, Aug 15, 2018 at 05:54:39PM +0300, Ilya Maximets wrote:
> 'numa_realloc()' allocates 'zmbufs' even if zero copy mode
> is not configured. This leads to memory leak, because array
> is freed only for zero copy case.
> 
> Fixes: 2651726defb7 ("vhost: do deep copy while reallocating queue")
> CC: stable@dpdk.org
> 
> Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
> ---
>  lib/librte_vhost/vhost_user.c | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
> index a2d4c9ffc..9aa1ce118 100644
> --- a/lib/librte_vhost/vhost_user.c
> +++ b/lib/librte_vhost/vhost_user.c
> @@ -357,11 +357,13 @@ numa_realloc(struct virtio_net *dev, int index)
>  		memcpy(vq, old_vq, sizeof(*vq));
>  		TAILQ_INIT(&vq->zmbuf_list);
>  
> -		new_zmbuf = rte_malloc_socket(NULL, vq->zmbuf_size *
> -			sizeof(struct zcopy_mbuf), 0, newnode);
> -		if (new_zmbuf) {
> -			rte_free(vq->zmbufs);
> -			vq->zmbufs = new_zmbuf;
> +		if (dev->dequeue_zero_copy) {
> +			new_zmbuf = rte_malloc_socket(NULL, vq->zmbuf_size *
> +					sizeof(struct zcopy_mbuf), 0, newnode);
> +			if (new_zmbuf) {
> +				rte_free(vq->zmbufs);
> +				vq->zmbufs = new_zmbuf;
> +			}
>  		}
>  
>  		if (vq_is_packed(dev)) {
> -- 
> 2.17.1
> 

Reviewed-by: Tiwei Bie <tiwei.bie@intel.com>

Thanks!

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-stable] [PATCH] vhost: fix zmbufs array leak after NUMA realloc
  2018-08-15 14:54 ` [dpdk-stable] [PATCH] vhost: fix zmbufs array leak after NUMA realloc Ilya Maximets
  2018-08-16  5:31   ` Tiwei Bie
@ 2018-09-10 13:38   ` Maxime Coquelin
  1 sibling, 0 replies; 3+ messages in thread
From: Maxime Coquelin @ 2018-09-10 13:38 UTC (permalink / raw)
  To: Ilya Maximets, dev; +Cc: Tiwei Bie, Zhihong Wang, Junjie Chen, stable



On 08/15/2018 04:54 PM, Ilya Maximets wrote:
> 'numa_realloc()' allocates 'zmbufs' even if zero copy mode
> is not configured. This leads to memory leak, because array
> is freed only for zero copy case.
> 
> Fixes: 2651726defb7 ("vhost: do deep copy while reallocating queue")
> CC: stable@dpdk.org
> 
> Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
> ---
>   lib/librte_vhost/vhost_user.c | 12 +++++++-----
>   1 file changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
> index a2d4c9ffc..9aa1ce118 100644
> --- a/lib/librte_vhost/vhost_user.c
> +++ b/lib/librte_vhost/vhost_user.c
> @@ -357,11 +357,13 @@ numa_realloc(struct virtio_net *dev, int index)
>   		memcpy(vq, old_vq, sizeof(*vq));
>   		TAILQ_INIT(&vq->zmbuf_list);
>   
> -		new_zmbuf = rte_malloc_socket(NULL, vq->zmbuf_size *
> -			sizeof(struct zcopy_mbuf), 0, newnode);
> -		if (new_zmbuf) {
> -			rte_free(vq->zmbufs);
> -			vq->zmbufs = new_zmbuf;
> +		if (dev->dequeue_zero_copy) {
> +			new_zmbuf = rte_malloc_socket(NULL, vq->zmbuf_size *
> +					sizeof(struct zcopy_mbuf), 0, newnode);
> +			if (new_zmbuf) {
> +				rte_free(vq->zmbufs);
> +				vq->zmbufs = new_zmbuf;
> +			}
>   		}
>   
>   		if (vq_is_packed(dev)) {
> 

Applied to dpdk-next-virtio/master.

Thanks!
Maxime

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-09-10 13:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20180815145341eucas1p15832e119a9d6f3fc54796675a283c44f@eucas1p1.samsung.com>
2018-08-15 14:54 ` [dpdk-stable] [PATCH] vhost: fix zmbufs array leak after NUMA realloc Ilya Maximets
2018-08-16  5:31   ` Tiwei Bie
2018-09-10 13:38   ` Maxime Coquelin

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).