From: Ilya Maximets <i.maximets@samsung.com>
To: dev@dpdk.org, Huawei Xie <huawei.xie@intel.com>,
Yuanhan Liu <yuanhan.liu@linux.intel.com>
Cc: Dyasly Sergey <s.dyasly@samsung.com>,
Heetae Ahn <heetae82.ahn@samsung.com>,
Vladimir Shilkin <v.shilkin@samsung.com>,
Victor Kaplansky <victork@redhat.com>,
Ilya Maximets <i.maximets@samsung.com>
Subject: [dpdk-dev] [PATCH 2/2] vhost: unmap log memory on cleanup.
Date: Thu, 16 Jun 2016 11:32:05 +0300 [thread overview]
Message-ID: <1466065925-2736-3-git-send-email-i.maximets@samsung.com> (raw)
In-Reply-To: <1466065925-2736-1-git-send-email-i.maximets@samsung.com>
Fixes memory leak on QEMU migration.
Fixes: 54f9e32305d4 ("vhost: handle dirty pages logging request")
Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
---
lib/librte_vhost/rte_virtio_net.h | 3 ++-
lib/librte_vhost/vhost_user/virtio-net-user.c | 15 +++++++++++++--
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/lib/librte_vhost/rte_virtio_net.h b/lib/librte_vhost/rte_virtio_net.h
index 600b20b..5ae5d58 100644
--- a/lib/librte_vhost/rte_virtio_net.h
+++ b/lib/librte_vhost/rte_virtio_net.h
@@ -143,7 +143,8 @@ struct virtio_net {
uint64_t log_base; /**< Where dirty pages are logged */
struct ether_addr mac; /**< MAC address */
rte_atomic16_t broadcast_rarp; /**< A flag to tell if we need broadcast rarp packet */
- uint64_t reserved[61]; /**< Reserve some spaces for future extension. */
+ uint64_t log_addr; /**< Where log mapped. */
+ uint64_t reserved[60]; /**< Reserve some spaces for future extension. */
struct vhost_virtqueue *virtqueue[VHOST_MAX_QUEUE_PAIRS * 2]; /**< Contains all virtqueue information. */
} __rte_cache_aligned;
diff --git a/lib/librte_vhost/vhost_user/virtio-net-user.c b/lib/librte_vhost/vhost_user/virtio-net-user.c
index a4e20b5..e765ce7 100644
--- a/lib/librte_vhost/vhost_user/virtio-net-user.c
+++ b/lib/librte_vhost/vhost_user/virtio-net-user.c
@@ -96,6 +96,10 @@ vhost_backend_cleanup(struct virtio_net *dev)
free(dev->mem);
dev->mem = NULL;
}
+ if (dev->log_addr) {
+ munmap((void *)(uintptr_t)dev->log_addr, dev->log_size);
+ dev->log_addr = 0;
+ }
}
int
@@ -403,8 +407,15 @@ user_set_log_base(struct vhost_device_ctx ctx,
return -1;
}
- /* TODO: unmap on stop */
- dev->log_base = (uint64_t)(uintptr_t)addr + off;
+ /*
+ * Free previously mapped log memory on occasionally
+ * multiple VHOST_USER_SET_LOG_BASE.
+ */
+ if (dev->log_addr) {
+ munmap((void *)(uintptr_t)dev->log_addr, dev->log_size);
+ }
+ dev->log_addr = (uint64_t)(uintptr_t)addr;
+ dev->log_base = dev->log_addr + off;
dev->log_size = size;
return 0;
--
2.7.4
next prev parent reply other threads:[~2016-06-16 8:32 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-16 8:32 [dpdk-dev] [PATCH 0/2] vhost: Fix leaks on migration Ilya Maximets
2016-06-16 8:32 ` [dpdk-dev] [PATCH 1/2] vhost: fix leak of file descriptors Ilya Maximets
2016-06-16 8:32 ` Ilya Maximets [this message]
2016-06-16 8:42 ` [dpdk-dev] [PATCH 0/2] vhost: Fix leaks on migration Yuanhan Liu
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=1466065925-2736-3-git-send-email-i.maximets@samsung.com \
--to=i.maximets@samsung.com \
--cc=dev@dpdk.org \
--cc=heetae82.ahn@samsung.com \
--cc=huawei.xie@intel.com \
--cc=s.dyasly@samsung.com \
--cc=v.shilkin@samsung.com \
--cc=victork@redhat.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).