patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [PATCH 19.11] vhost: utilize dynamic memory allocator
@ 2021-08-30  3:09 Chenbo Xia
  2021-08-30  6:19 ` Christian Ehrhardt
  0 siblings, 1 reply; 2+ messages in thread
From: Chenbo Xia @ 2021-08-30  3:09 UTC (permalink / raw)
  To: stable; +Cc: maxime.coquelin, christian.ehrhardt, Marvin Liu

[ upstream commit 20fd2f91cf2fb45ffc66abd4ca8ab26906cd0d1f ]

Replace dynamic memory allocator with dpdk memory allocator.

Bugzilla ID: 794
Fixes: 57589cdfd784 ("vhost: fix missing guest pages table NUMA realloc")
Cc: stable@dpdk.org

Signed-off-by: Marvin Liu <yong.liu@intel.com>
Signed-off-by: Chenbo Xia <chenbo.xia@intel.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
---
 lib/librte_vhost/vhost_user.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
index b1c0bef7b6..f35b6423d7 100644
--- a/lib/librte_vhost/vhost_user.c
+++ b/lib/librte_vhost/vhost_user.c
@@ -198,7 +198,7 @@ vhost_backend_cleanup(struct virtio_net *dev)
 		dev->mem = NULL;
 	}
 
-	free(dev->guest_pages);
+	rte_free(dev->guest_pages);
 	dev->guest_pages = NULL;
 
 	if (dev->log_addr) {
@@ -939,11 +939,12 @@ add_one_guest_page(struct virtio_net *dev, uint64_t guest_phys_addr,
 	if (dev->nr_guest_pages == dev->max_guest_pages) {
 		dev->max_guest_pages *= 2;
 		old_pages = dev->guest_pages;
-		dev->guest_pages = realloc(dev->guest_pages,
-					dev->max_guest_pages * sizeof(*page));
-		if (!dev->guest_pages) {
+		dev->guest_pages = rte_realloc(dev->guest_pages,
+					dev->max_guest_pages * sizeof(*page),
+					RTE_CACHE_LINE_SIZE);
+		if (dev->guest_pages == NULL) {
 			RTE_LOG(ERR, VHOST_CONFIG, "cannot realloc guest_pages\n");
-			free(old_pages);
+			rte_free(old_pages);
 			return -1;
 		}
 	}
@@ -1097,10 +1098,12 @@ vhost_user_set_mem_table(struct virtio_net **pdev, struct VhostUserMsg *msg,
 			vhost_user_iotlb_flush_all(dev->virtqueue[i]);
 
 	dev->nr_guest_pages = 0;
-	if (!dev->guest_pages) {
+	if (dev->guest_pages == NULL) {
 		dev->max_guest_pages = 8;
-		dev->guest_pages = malloc(dev->max_guest_pages *
-						sizeof(struct guest_page));
+		dev->guest_pages = rte_zmalloc(NULL,
+					dev->max_guest_pages *
+					sizeof(struct guest_page),
+					RTE_CACHE_LINE_SIZE);
 		if (dev->guest_pages == NULL) {
 			RTE_LOG(ERR, VHOST_CONFIG,
 				"(%d) failed to allocate memory "
-- 
2.17.1


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

* Re: [dpdk-stable] [PATCH 19.11] vhost: utilize dynamic memory allocator
  2021-08-30  3:09 [dpdk-stable] [PATCH 19.11] vhost: utilize dynamic memory allocator Chenbo Xia
@ 2021-08-30  6:19 ` Christian Ehrhardt
  0 siblings, 0 replies; 2+ messages in thread
From: Christian Ehrhardt @ 2021-08-30  6:19 UTC (permalink / raw)
  To: Chenbo Xia; +Cc: dpdk stable, Maxime Coquelin, Marvin Liu

On Mon, Aug 30, 2021 at 5:22 AM Chenbo Xia <chenbo.xia@intel.com> wrote:
>
> [ upstream commit 20fd2f91cf2fb45ffc66abd4ca8ab26906cd0d1f ]

Thanks, applied!

> Replace dynamic memory allocator with dpdk memory allocator.
>
> Bugzilla ID: 794
> Fixes: 57589cdfd784 ("vhost: fix missing guest pages table NUMA realloc")
> Cc: stable@dpdk.org
>
> Signed-off-by: Marvin Liu <yong.liu@intel.com>
> Signed-off-by: Chenbo Xia <chenbo.xia@intel.com>
> Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
> ---
>  lib/librte_vhost/vhost_user.c | 19 +++++++++++--------
>  1 file changed, 11 insertions(+), 8 deletions(-)
>
> diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
> index b1c0bef7b6..f35b6423d7 100644
> --- a/lib/librte_vhost/vhost_user.c
> +++ b/lib/librte_vhost/vhost_user.c
> @@ -198,7 +198,7 @@ vhost_backend_cleanup(struct virtio_net *dev)
>                 dev->mem = NULL;
>         }
>
> -       free(dev->guest_pages);
> +       rte_free(dev->guest_pages);
>         dev->guest_pages = NULL;
>
>         if (dev->log_addr) {
> @@ -939,11 +939,12 @@ add_one_guest_page(struct virtio_net *dev, uint64_t guest_phys_addr,
>         if (dev->nr_guest_pages == dev->max_guest_pages) {
>                 dev->max_guest_pages *= 2;
>                 old_pages = dev->guest_pages;
> -               dev->guest_pages = realloc(dev->guest_pages,
> -                                       dev->max_guest_pages * sizeof(*page));
> -               if (!dev->guest_pages) {
> +               dev->guest_pages = rte_realloc(dev->guest_pages,
> +                                       dev->max_guest_pages * sizeof(*page),
> +                                       RTE_CACHE_LINE_SIZE);
> +               if (dev->guest_pages == NULL) {
>                         RTE_LOG(ERR, VHOST_CONFIG, "cannot realloc guest_pages\n");
> -                       free(old_pages);
> +                       rte_free(old_pages);
>                         return -1;
>                 }
>         }
> @@ -1097,10 +1098,12 @@ vhost_user_set_mem_table(struct virtio_net **pdev, struct VhostUserMsg *msg,
>                         vhost_user_iotlb_flush_all(dev->virtqueue[i]);
>
>         dev->nr_guest_pages = 0;
> -       if (!dev->guest_pages) {
> +       if (dev->guest_pages == NULL) {
>                 dev->max_guest_pages = 8;
> -               dev->guest_pages = malloc(dev->max_guest_pages *
> -                                               sizeof(struct guest_page));
> +               dev->guest_pages = rte_zmalloc(NULL,
> +                                       dev->max_guest_pages *
> +                                       sizeof(struct guest_page),
> +                                       RTE_CACHE_LINE_SIZE);
>                 if (dev->guest_pages == NULL) {
>                         RTE_LOG(ERR, VHOST_CONFIG,
>                                 "(%d) failed to allocate memory "
> --
> 2.17.1
>


-- 
Christian Ehrhardt
Staff Engineer, Ubuntu Server
Canonical Ltd

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

end of thread, other threads:[~2021-08-30  6:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-30  3:09 [dpdk-stable] [PATCH 19.11] vhost: utilize dynamic memory allocator Chenbo Xia
2021-08-30  6:19 ` Christian Ehrhardt

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