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 937A9A0032 for ; Fri, 21 Oct 2022 10:17:28 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 89BD142BB7; Fri, 21 Oct 2022 10:17:28 +0200 (CEST) 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 0229E42BB6 for ; Fri, 21 Oct 2022 10:17:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666340246; 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=BrN9tztD1onBAU+pAeYXQTbWlyPQgBH0ADtV6/t+BsA=; b=jTLyfA4sNZZjDJ7qED2/TSzV+XD97boTwnZg86cD4L5i/zZpZwu9mKFO31WKm3TrMJsinW Nw/2xRhUtvhyJn0cGr4SslbB2GVmFhHKk7ZVU1otEjVqVEBsNzirk5/XCaETgUh+fS85+5 adrJPIQVgfNnTPUNE1rVntox/CCA15s= 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-317-sZQa4cPwNuyzRfnbo0NIwg-1; Fri, 21 Oct 2022 04:17:23 -0400 X-MC-Unique: sZQa4cPwNuyzRfnbo0NIwg-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7E61C806017; Fri, 21 Oct 2022 08:17:22 +0000 (UTC) Received: from [10.39.208.30] (unknown [10.39.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5BA5749BB60; Fri, 21 Oct 2022 08:17:10 +0000 (UTC) Message-ID: <239ec86b-55ce-803a-805b-a1364485aadc@redhat.com> Date: Fri, 21 Oct 2022 10:17:07 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.1 Subject: Re: [PATCH v2 2/2] vhost: fix slot index calculation in async vhost To: Cheng Jiang , chenbo.xia@intel.com Cc: dev@dpdk.org, jiayu.hu@intel.com, xuan.ding@intel.com, wenwux.ma@intel.com, yuanx.wang@intel.com, yvonnex.yang@intel.com, xingguang.he@intel.com, stable@dpdk.org References: <20220822043126.19340-1-cheng1.jiang@intel.com> <20221011030803.16746-1-cheng1.jiang@intel.com> <20221011030803.16746-3-cheng1.jiang@intel.com> From: Maxime Coquelin In-Reply-To: <20221011030803.16746-3-cheng1.jiang@intel.com> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org On 10/11/22 05:08, Cheng Jiang wrote: > When the packet receiving failure and the DMA ring full occur > simultaneously in the asynchronous vhost, the slot_idx needs to be > decreased by 1. For packed virtqueue, the slot index should be > ring_size - 1, if the slot_idx is currently 0, since the ring size is > not necessarily the power of 2. > > Fixes: 84d5204310d7 ("vhost: support async dequeue for split ring") > Fixes: fe8477ebbd94 ("vhost: support async packed ring dequeue") > Cc: stable@dpdk.org > > Signed-off-by: Cheng Jiang > --- > lib/vhost/virtio_net.c | 16 ++++++++++++++-- > 1 file changed, 14 insertions(+), 2 deletions(-) > > diff --git a/lib/vhost/virtio_net.c b/lib/vhost/virtio_net.c > index 457ac2e92a..efebd063d7 100644 > --- a/lib/vhost/virtio_net.c > +++ b/lib/vhost/virtio_net.c > @@ -3457,6 +3457,7 @@ virtio_dev_tx_async_split(struct virtio_net *dev, struct vhost_virtqueue *vq, > allocerr_warned = true; > } > dropped = true; > + slot_idx--; > break; > } > > @@ -3647,6 +3648,12 @@ virtio_dev_tx_async_packed(struct virtio_net *dev, struct vhost_virtqueue *vq, > if (unlikely(virtio_dev_tx_async_single_packed(dev, vq, mbuf_pool, pkt, > slot_idx, legacy_ol_flags))) { > rte_pktmbuf_free_bulk(&pkts_prealloc[pkt_idx], count - pkt_idx); > + > + if (slot_idx == 0) > + slot_idx = vq->size - 1; > + else > + slot_idx--; > + > break; > } > > @@ -3674,8 +3681,13 @@ virtio_dev_tx_async_packed(struct virtio_net *dev, struct vhost_virtqueue *vq, > async->buffer_idx_packed += vq->size - pkt_err; > > while (pkt_err-- > 0) { > - rte_pktmbuf_free(pkts_info[slot_idx % vq->size].mbuf); > - slot_idx--; > + rte_pktmbuf_free(pkts_info[slot_idx].mbuf); > + descs_err += pkts_info[slot_idx].descs; > + > + if (slot_idx == 0) > + slot_idx = vq->size - 1; > + else > + slot_idx--; > } > > /* recover available ring */ Reviewed-by: Maxime Coquelin Thanks, Maxime