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 0251DA0548; Mon, 17 May 2021 09:37:49 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 76F4F40041; Mon, 17 May 2021 09:37:49 +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 94E9C4003C for ; Mon, 17 May 2021 09:37:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621237067; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uSwCSENTYlfYBs2j3T0jDkMC05C4qa7Pr31bEBfuLws=; b=V699/TvQHxGSgB2P3O69Q4hyZo0vCnIJTfI8LLFaaK8l6rZIc7mVv+AUKWNvPxszdP0nRR ruv+ljzi979FHu1lTPsUnoReHohM3G0qpskADsVpDn8gzogSyE6Ovl9DKo0Xg7HzluTbge nX6VIAVPnipek6i2bVGQd/jMPBta6uI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-188-ZTZaKgpzOwOc4YZ2X6dDEg-1; Mon, 17 May 2021 03:37:45 -0400 X-MC-Unique: ZTZaKgpzOwOc4YZ2X6dDEg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 870F1501F7; Mon, 17 May 2021 07:37:44 +0000 (UTC) Received: from [10.36.110.30] (unknown [10.36.110.30]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5DB4319704; Mon, 17 May 2021 07:37:42 +0000 (UTC) To: Balazs Nemeth , dev@dpdk.org, weix.ling@intel.com References: <83fa6253725a7bc69bccb7897f380422354a2898.1621008025.git.bnemeth@redhat.com> From: Maxime Coquelin Message-ID: <977757b2-e32a-242d-26ff-c81f27a3b25e@redhat.com> Date: Mon, 17 May 2021 09:37:39 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <83fa6253725a7bc69bccb7897f380422354a2898.1621008025.git.bnemeth@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH] vhost: fix invalid use of stored last used index 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 Sender: "dev" Hi Ling, On 5/14/21 6:02 PM, Balazs Nemeth wrote: > The optimization introduced by commit d18db8049c7c ("vhost: read last > used index once") didn't account for the fact that > vhost_flush_enqueue_shadow_packed increments the last_used_idx. For this > reason, store last_used_idx after the potential call to > vhost_flush_enqueue_shadow_packed. > > Fixes: d18db8049c7c ("vhost: read last used index once") > Signed-off-by: Balazs Nemeth > --- > lib/vhost/virtio_net.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/lib/vhost/virtio_net.c b/lib/vhost/virtio_net.c > index abfd67d38c..8da8a86a10 100644 > --- a/lib/vhost/virtio_net.c > +++ b/lib/vhost/virtio_net.c > @@ -218,14 +218,17 @@ vhost_flush_enqueue_batch_packed(struct virtio_net *dev, > { > uint16_t i; > uint16_t flags; > - uint16_t last_used_idx = vq->last_used_idx; > - struct vring_packed_desc *desc_base = &vq->desc_packed[last_used_idx]; > + uint16_t last_used_idx; > + struct vring_packed_desc *desc_base; > > if (vq->shadow_used_idx) { > do_data_copy_enqueue(dev, vq); > vhost_flush_enqueue_shadow_packed(dev, vq); > } > > + last_used_idx = vq->last_used_idx; > + desc_base = &vq->desc_packed[last_used_idx]; > + > flags = PACKED_DESC_ENQUEUE_USED_FLAG(vq->used_wrap_counter); > > vhost_for_each_try_unroll(i, 0, PACKED_BATCH_SIZE) { > Could you please confirm the patch fixes the issue you reported? Thanks, Maxime