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 EF963A0501; Thu, 31 Mar 2022 10:00:38 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D9F1342853; Thu, 31 Mar 2022 10:00:38 +0200 (CEST) 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 7275B42854 for ; Thu, 31 Mar 2022 10:00:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1648713637; 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=31PjYkvzEtMA4nTx9vrA04UW5D8YURdiW9M7jZhI1Ho=; b=M+yXPk8bLsGJAR+AUIsa+o1xAZX7LZQpZATZSly+ICMAtXF1mUBHrrfd5APBYXcambw4+1 13MzspcDaaoKQ/auE74UORLTigPy+3WFf18uNB6WoslFJEISmfj4kFUv4zDnXjBXRMMQ2I Rimc6FnddCl/Pafdcz2cLV5sqq8/mWM= 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-262-2S0m5dr7ORSfhtpdUERqyg-1; Thu, 31 Mar 2022 04:00:31 -0400 X-MC-Unique: 2S0m5dr7ORSfhtpdUERqyg-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 1174E1C05AA8; Thu, 31 Mar 2022 08:00:31 +0000 (UTC) Received: from [10.39.208.2] (unknown [10.39.208.2]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9906940CFD02; Thu, 31 Mar 2022 08:00:29 +0000 (UTC) Message-ID: <4c729841-7599-d94b-4104-2a4f78f2e961@redhat.com> Date: Thu, 31 Mar 2022 10:00:27 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [RFC PATCH v2 4/9] vhost: fix async access To: David Marchand , dev@dpdk.org Cc: chenbo.xia@intel.com, jiayu.hu@intel.com, yuanx.wang@intel.com, xuan.ding@intel.com, stable@dpdk.org, Patrick Fu References: <20220328121758.26632-1-david.marchand@redhat.com> <20220330134956.18927-1-david.marchand@redhat.com> <20220330134956.18927-5-david.marchand@redhat.com> From: Maxime Coquelin In-Reply-To: <20220330134956.18927-5-david.marchand@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=maxime.coquelin@redhat.com 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 Hi Jiayu, On 3/30/22 15:49, David Marchand wrote: > vq->async accesses must be protected with vq->access_lock. > > Fixes: eb666d24085f ("vhost: fix async unregister deadlock") > Fixes: 0c0935c5f794 ("vhost: allow to check in-flight packets for async vhost") > Cc: stable@dpdk.org > > Signed-off-by: David Marchand > --- > lib/vhost/vhost.c | 25 ++++++++++--------------- > 1 file changed, 10 insertions(+), 15 deletions(-) Could you please test and review below patch? We may want to apply it early, before the annotation series is applied. Thanks! Maxime > diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c > index 2f96a28dac..a93e41f314 100644 > --- a/lib/vhost/vhost.c > +++ b/lib/vhost/vhost.c > @@ -1753,27 +1753,23 @@ rte_vhost_async_channel_unregister(int vid, uint16_t queue_id) > if (vq == NULL) > return ret; > > - ret = 0; > - > - if (!vq->async) > - return ret; > - > if (!rte_spinlock_trylock(&vq->access_lock)) { > VHOST_LOG_CONFIG(ERR, "(%s) failed to unregister async channel, virtqueue busy.\n", > dev->ifname); > - return -1; > + return ret; > } > > - if (vq->async->pkts_inflight_n) { > + if (!vq->async) { > + ret = 0; > + } else if (vq->async->pkts_inflight_n) { > VHOST_LOG_CONFIG(ERR, "(%s) failed to unregister async channel.\n", dev->ifname); > VHOST_LOG_CONFIG(ERR, "(%s) inflight packets must be completed before unregistration.\n", > dev->ifname); > - ret = -1; > - goto out; > + } else { > + vhost_free_async_mem(vq); > + ret = 0; > } > > - vhost_free_async_mem(vq); > -out: > rte_spinlock_unlock(&vq->access_lock); > > return ret; > @@ -1891,9 +1887,6 @@ rte_vhost_async_get_inflight(int vid, uint16_t queue_id) > if (vq == NULL) > return ret; > > - if (!vq->async) > - return ret; > - > if (!rte_spinlock_trylock(&vq->access_lock)) { > VHOST_LOG_CONFIG(DEBUG, > "(%s) failed to check in-flight packets. virtqueue busy.\n", > @@ -1901,7 +1894,9 @@ rte_vhost_async_get_inflight(int vid, uint16_t queue_id) > return ret; > } > > - ret = vq->async->pkts_inflight_n; > + if (vq->async) > + ret = vq->async->pkts_inflight_n; > + > rte_spinlock_unlock(&vq->access_lock); > > return ret;