diff mbox series

vhost memory hotplug deadlock

Message ID 20180919121027.57857295@xeon-e3 (mailing list archive)
State Rejected, archived
Delegated to: Maxime Coquelin
Headers show
Series vhost memory hotplug deadlock | expand

Checks

Context Check Description
ci/Intel-compilation fail apply issues

Commit Message

Stephen Hemminger Sept. 19, 2018, 7:10 p.m. UTC
The Vhost memory handling will self deadlock.

The sequence is:
	rte_zmalloc
		malloc_heap_alloc
			heap_alloc_on_socket
				alloc_more_mem_on_socket
					try_expand_heap_primary

Acquires memory_hotplug_lock for write

	eal_memalloc_mem_event_notify
		vhost_user_mem_event_cb
			vhost_kernel_ioctl
				rte_memseg_contig_walk

Deadlocks acquiring memory_hotplug_lock for read

The following may fix it.
diff mbox series

Patch

diff --git a/drivers/net/virtio/virtio_user/vhost_kernel.c b/drivers/net/virtio/virtio_user/vhost_kernel.c
index d1be82162609..549235df0ca2 100644
--- a/drivers/net/virtio/virtio_user/vhost_kernel.c
+++ b/drivers/net/virtio/virtio_user/vhost_kernel.c
@@ -115,7 +115,8 @@  prepare_vhost_memory_kernel(void)
        wa.region_nr = 0;
        wa.vm = vm;
 
-       if (rte_memseg_contig_walk(add_memory_region, &wa) < 0) {
+       /* memory_hotplug_lock already held  */
+       if (rte_memseg_contig_walk_thread_unsafe(add_memory_region, &wa) < 0) {
                free(vm);
                return NULL;
        }