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 82A27A00C3; Mon, 3 Oct 2022 12:10:19 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 356AC40DFB; Mon, 3 Oct 2022 12:10:19 +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 D0A5E40695 for ; Mon, 3 Oct 2022 12:10:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664791817; 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=V5w04GFS+fYz9Xhn+JHbLTAAA/RQrgertJQuROir5jk=; b=gsTKk4k078ofArIckBPBfVpFlrx+SObWUER2L7e4rCmToywChMVCjaSjXTsjEbHQnvi8Jr hE0mJvKMZxkvJMxgyLM/poUBit8vtRG3YO9iYK5bNuWrUxa4H+lwvprfRzhHHQ6/R6Oe6Y sdMXi0eSN772Qpdj8c+jc7J9O9fp8Eg= 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-346--TW_zZc9OKOcoZcueHk3WA-1; Mon, 03 Oct 2022 06:10:16 -0400 X-MC-Unique: -TW_zZc9OKOcoZcueHk3WA-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D726F1C05139; Mon, 3 Oct 2022 10:10:15 +0000 (UTC) Received: from [10.39.208.19] (unknown [10.39.208.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1BA00492B04; Mon, 3 Oct 2022 10:10:13 +0000 (UTC) Message-ID: <049b9b7e-c818-6544-2673-149fc5d5af42@redhat.com> Date: Mon, 3 Oct 2022 12:10:12 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.0 Subject: Re: [PATH 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 References: <20220822043126.19340-1-cheng1.jiang@intel.com> <20220822043126.19340-3-cheng1.jiang@intel.com> From: Maxime Coquelin In-Reply-To: <20220822043126.19340-3-cheng1.jiang@intel.com> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 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 8/22/22 06:31, 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 > reduced by 1. For packed virtqueue, the slot index should be s/reduced/decreased/ > ring_size - 1, if the slot_idx is currently 0, since the ring size is > not necessarily the power of 2. This is a fix, so fixes tag and stable@dpdk.org is required. > 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 bfc6d65b7c..f804bce0bd 100644 > --- a/lib/vhost/virtio_net.c > +++ b/lib/vhost/virtio_net.c > @@ -3462,6 +3462,7 @@ virtio_dev_tx_async_split(struct virtio_net *dev, struct vhost_virtqueue *vq, > allocerr_warned = true; > } > dropped = true; > + slot_idx--; > break; > } > > @@ -3652,6 +3653,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; > } > > @@ -3679,8 +3686,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 */