DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH v2 0/2] vhost: Fix leaks on migration.
@ 2016-06-16  9:16 Ilya Maximets
  2016-06-16  9:16 ` [dpdk-dev] [PATCH v2 1/2] vhost: fix leak of file descriptors Ilya Maximets
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Ilya Maximets @ 2016-06-16  9:16 UTC (permalink / raw)
  To: dev, Huawei Xie, Yuanhan Liu
  Cc: Dyasly Sergey, Heetae Ahn, Vladimir Shilkin, Victor Kaplansky,
	Ilya Maximets

v2:
	* rebased on top of dpdk-next-virtio/master

Ilya Maximets (2):
  vhost: fix leak of file descriptors.
  vhost: unmap log memory on cleanup.

 lib/librte_vhost/vhost-net.h                  |  1 +
 lib/librte_vhost/vhost_user/virtio-net-user.c | 16 ++++++++++++++--
 2 files changed, 15 insertions(+), 2 deletions(-)

-- 
2.7.4

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

* [dpdk-dev] [PATCH v2 1/2] vhost: fix leak of file descriptors.
  2016-06-16  9:16 [dpdk-dev] [PATCH v2 0/2] vhost: Fix leaks on migration Ilya Maximets
@ 2016-06-16  9:16 ` Ilya Maximets
  2016-06-16  9:16 ` [dpdk-dev] [PATCH v2 2/2] vhost: unmap log memory on cleanup Ilya Maximets
  2016-06-20  5:53 ` [dpdk-dev] [PATCH v2 0/2] vhost: Fix leaks on migration Yuanhan Liu
  2 siblings, 0 replies; 4+ messages in thread
From: Ilya Maximets @ 2016-06-16  9:16 UTC (permalink / raw)
  To: dev, Huawei Xie, Yuanhan Liu
  Cc: Dyasly Sergey, Heetae Ahn, Vladimir Shilkin, Victor Kaplansky,
	Ilya Maximets

While migration of vhost-user device QEMU allocates memfd
to store information about dirty pages and sends fd to
vhost-user process.

File descriptor for this memory should be closed to prevent
"Too many open files" error for vhost-user process after
some amount of migrations.

Ex.:
 # ls /proc/<ovs-vswitchd pid>/fd/ -alh
 total 0
 root qemu  .
 root qemu  ..
 root qemu  0 -> /dev/pts/0
 root qemu  1 -> pipe:[1804353]
 root qemu  10 -> socket:[1782240]
 root qemu  100 -> /memfd:vhost-log (deleted)
 root qemu  1000 -> /memfd:vhost-log (deleted)
 root qemu  1001 -> /memfd:vhost-log (deleted)
 root qemu  1004 -> /memfd:vhost-log (deleted)
 [...]
 root qemu  996 -> /memfd:vhost-log (deleted)
 root qemu  997 -> /memfd:vhost-log (deleted)

 ovs-vswitchd.log:
 |WARN|punix:ovs-vswitchd.ctl: accept failed: Too many open files

Fixes: 54f9e32305d4 ("vhost: handle dirty pages logging request")
Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
---
 lib/librte_vhost/vhost_user/virtio-net-user.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/librte_vhost/vhost_user/virtio-net-user.c b/lib/librte_vhost/vhost_user/virtio-net-user.c
index 64a6ec4..e6a2aed 100644
--- a/lib/librte_vhost/vhost_user/virtio-net-user.c
+++ b/lib/librte_vhost/vhost_user/virtio-net-user.c
@@ -401,6 +401,7 @@ user_set_log_base(int vid, struct VhostUserMsg *msg)
 	 * fail when offset is not page size aligned.
 	 */
 	addr = mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+	close(fd);
 	if (addr == MAP_FAILED) {
 		RTE_LOG(ERR, VHOST_CONFIG, "mmap log base failed!\n");
 		return -1;
-- 
2.7.4

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

* [dpdk-dev] [PATCH v2 2/2] vhost: unmap log memory on cleanup.
  2016-06-16  9:16 [dpdk-dev] [PATCH v2 0/2] vhost: Fix leaks on migration Ilya Maximets
  2016-06-16  9:16 ` [dpdk-dev] [PATCH v2 1/2] vhost: fix leak of file descriptors Ilya Maximets
@ 2016-06-16  9:16 ` Ilya Maximets
  2016-06-20  5:53 ` [dpdk-dev] [PATCH v2 0/2] vhost: Fix leaks on migration Yuanhan Liu
  2 siblings, 0 replies; 4+ messages in thread
From: Ilya Maximets @ 2016-06-16  9:16 UTC (permalink / raw)
  To: dev, Huawei Xie, Yuanhan Liu
  Cc: Dyasly Sergey, Heetae Ahn, Vladimir Shilkin, Victor Kaplansky,
	Ilya Maximets

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/vhost-net.h                  |  1 +
 lib/librte_vhost/vhost_user/virtio-net-user.c | 15 +++++++++++++--
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/lib/librte_vhost/vhost-net.h b/lib/librte_vhost/vhost-net.h
index ec8f964..38593a2 100644
--- a/lib/librte_vhost/vhost-net.h
+++ b/lib/librte_vhost/vhost-net.h
@@ -134,6 +134,7 @@ struct virtio_net {
 	char			ifname[IF_NAME_SZ];
 	uint64_t		log_size;
 	uint64_t		log_base;
+	uint64_t		log_addr;
 	struct ether_addr	mac;
 
 } __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 e6a2aed..a867a43 100644
--- a/lib/librte_vhost/vhost_user/virtio-net-user.c
+++ b/lib/librte_vhost/vhost_user/virtio-net-user.c
@@ -95,6 +95,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
@@ -407,8 +411,15 @@ user_set_log_base(int vid, struct VhostUserMsg *msg)
 		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

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

* Re: [dpdk-dev] [PATCH v2 0/2] vhost: Fix leaks on migration.
  2016-06-16  9:16 [dpdk-dev] [PATCH v2 0/2] vhost: Fix leaks on migration Ilya Maximets
  2016-06-16  9:16 ` [dpdk-dev] [PATCH v2 1/2] vhost: fix leak of file descriptors Ilya Maximets
  2016-06-16  9:16 ` [dpdk-dev] [PATCH v2 2/2] vhost: unmap log memory on cleanup Ilya Maximets
@ 2016-06-20  5:53 ` Yuanhan Liu
  2 siblings, 0 replies; 4+ messages in thread
From: Yuanhan Liu @ 2016-06-20  5:53 UTC (permalink / raw)
  To: Ilya Maximets
  Cc: dev, Huawei Xie, Dyasly Sergey, Heetae Ahn, Vladimir Shilkin,
	Victor Kaplansky

Applied to dpdk-next-virtio. Thanks!

	--yliu

On Thu, Jun 16, 2016 at 12:16:35PM +0300, Ilya Maximets wrote:
> v2:
> 	* rebased on top of dpdk-next-virtio/master
> 
> Ilya Maximets (2):
>   vhost: fix leak of file descriptors.
>   vhost: unmap log memory on cleanup.
> 
>  lib/librte_vhost/vhost-net.h                  |  1 +
>  lib/librte_vhost/vhost_user/virtio-net-user.c | 16 ++++++++++++++--
>  2 files changed, 15 insertions(+), 2 deletions(-)
> 
> -- 
> 2.7.4

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

end of thread, other threads:[~2016-06-20  5:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-16  9:16 [dpdk-dev] [PATCH v2 0/2] vhost: Fix leaks on migration Ilya Maximets
2016-06-16  9:16 ` [dpdk-dev] [PATCH v2 1/2] vhost: fix leak of file descriptors Ilya Maximets
2016-06-16  9:16 ` [dpdk-dev] [PATCH v2 2/2] vhost: unmap log memory on cleanup Ilya Maximets
2016-06-20  5:53 ` [dpdk-dev] [PATCH v2 0/2] vhost: Fix leaks on migration Yuanhan Liu

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