From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3148F42826; Thu, 23 Mar 2023 15:44:50 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0C0F84021E; Thu, 23 Mar 2023 15:44:50 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 1528F4021D for ; Thu, 23 Mar 2023 15:44:47 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1679582687; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=CJzxLkiqN9Y44FcgELM5C5E7SHe69OUzoiX/fgIYfzg=; b=OlwRyuFtLa2XBruqKMys1e+B+AfMLhWk0nNzJHR45143Dp3dlYuO83Sz9NGR3fSAn9o4ql FxBDdPhQV0/fmDQ4I26d1HXG4vvi8gcRzVo17HoB6UslxDVdwZSL5010i3KJj9S9+yazvh OomCgJfYZWJOcVtw6aJIBgsojQiu1jI= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-343-NKgCU1_zPmSKiYjq8ZI2vQ-1; Thu, 23 Mar 2023 10:44:44 -0400 X-MC-Unique: NKgCU1_zPmSKiYjq8ZI2vQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0DCAE857FB7; Thu, 23 Mar 2023 14:44:44 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.63]) by smtp.corp.redhat.com (Postfix) with ESMTP id F389F40CF916; Thu, 23 Mar 2023 14:44:36 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: maxime.coquelin@redhat.com, chenbo.xia@intel.com, yanghliu@redhat.com Subject: [PATCH] vhost: fix deadlock with no multiqueue Date: Thu, 23 Mar 2023 15:44:33 +0100 Message-Id: <20230323144433.3104768-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org This deadlock happens when a guest, that had virtio ports with multi queues configured, does not announce the multi q feature in SET_FEATURES. In such a situation, all vq locks are already taken before calling free_vq(), which itself takes the lock. As mentioned in the code, in this situation, the virtio device is not running yet and no datapath thread is using the vq. So we can release the lock before calling free_vq(). Bugzilla ID: 1196 Fixes: 4b02c2673757 ("vhost: annotate async accesses") Signed-off-by: David Marchand --- lib/vhost/vhost_user.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c index f5edba8548..d60e39b6bc 100644 --- a/lib/vhost/vhost_user.c +++ b/lib/vhost/vhost_user.c @@ -397,6 +397,9 @@ vhost_user_set_features(struct virtio_net **pdev, dev->virtqueue[dev->nr_vring] = NULL; cleanup_vq(vq, 1); cleanup_vq_inflight(dev, vq); + /* vhost_user_lock_all_queue_pairs locked all qps */ + vq_assert_lock(dev, vq); + rte_spinlock_unlock(&vq->access_lock); free_vq(dev, vq); } } -- 2.39.2