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 1412542826; Thu, 23 Mar 2023 15:48:52 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EA0CE4021E; Thu, 23 Mar 2023 15:48:51 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id C370F4021D for ; Thu, 23 Mar 2023 15:48:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1679582929; 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: in-reply-to:in-reply-to:references:references; bh=SwUS3uxv+V1XAV+5ves9Z671vxXkHWElMcaQ9Ae4zgo=; b=NReVMumzTEtu9A3B2zgKwJpYqJRNjjvD0KA7gP3pOWMnSI6pWpWPjiYsUJMyreDck3CupH Npl0+VVRqotOG8eQgq04U9Cyp49iv7OhKpmYyd/MHUJY4nma84ot5g1aCnATaLrVgiv2h6 EkK9fAN4t+PggWWeOWNmp7qz0FkiSbk= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-450-JnOE_2nZPfGLgpVTSQkzCA-1; Thu, 23 Mar 2023 10:48:46 -0400 X-MC-Unique: JnOE_2nZPfGLgpVTSQkzCA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AA1B32808E76; Thu, 23 Mar 2023 14:48:45 +0000 (UTC) Received: from [10.39.208.25] (unknown [10.39.208.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CFA5C2166B29; Thu, 23 Mar 2023 14:48:44 +0000 (UTC) Message-ID: <36444f7a-78b6-0874-9f16-39328f2d2ef8@redhat.com> Date: Thu, 23 Mar 2023 15:48:42 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: Re: [PATCH] vhost: fix deadlock with no multiqueue To: David Marchand , dev@dpdk.org Cc: chenbo.xia@intel.com, yanghliu@redhat.com References: <20230323144433.3104768-1-david.marchand@redhat.com> From: Maxime Coquelin In-Reply-To: <20230323144433.3104768-1-david.marchand@redhat.com> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 On 3/23/23 15:44, David Marchand wrote: > 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); > } > } Reviewed-by: Maxime Coquelin Thanks, Maxime