From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Hemminger Subject: vhost memory hotplug deadlock Date: Wed, 19 Sep 2018 12:10:27 -0700 Message-ID: <20180919121027.57857295@xeon-e3> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit To: dev@dpdk.org Return-path: Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) by dpdk.org (Postfix) with ESMTP id 6FCB01B114 for ; Wed, 19 Sep 2018 21:10:35 +0200 (CEST) Received: by mail-pf1-f182.google.com with SMTP id k21-v6so3134499pff.11 for ; Wed, 19 Sep 2018 12:10:35 -0700 (PDT) Received: from xeon-e3 (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id 8-v6sm25501646pgu.10.2018.09.19.12.10.34 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 19 Sep 2018 12:10:34 -0700 (PDT) List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 --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; }