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 0C8F0A0A02; Mon, 17 May 2021 12:46:55 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C5AE84014E; Mon, 17 May 2021 12:46:54 +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 8312740041 for ; Mon, 17 May 2021 12:46:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621248413; 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=x6UyE81twmW9yUcZ62+u2olV2GwBQBymAqUTvA+06jE=; b=PuQvq1giHVKVhE8IXuOtAUCAoQYFXKOGVvsuqvIAFc90mruWRitd/RrKmP3DHbiADElcFU hlZuSURLrAaQWiDC301xw/jsBdaKp55z/4svediSEtDSHZU54Dw3rTQNVKihlIlMy4HW/M lkViSwHL7KFnPPuHjd30hGw5sImwyyA= 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-604-gesrkfq9PpGyTu-CgoP3Rw-1; Mon, 17 May 2021 06:46:50 -0400 X-MC-Unique: gesrkfq9PpGyTu-CgoP3Rw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3147F8015F4; Mon, 17 May 2021 10:46:49 +0000 (UTC) Received: from [10.36.110.30] (unknown [10.36.110.30]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4E104100AE43; Mon, 17 May 2021 10:46:48 +0000 (UTC) To: "Ling, WeiX" , Balazs Nemeth , "dev@dpdk.org" References: <83fa6253725a7bc69bccb7897f380422354a2898.1621008025.git.bnemeth@redhat.com> <977757b2-e32a-242d-26ff-c81f27a3b25e@redhat.com> From: Maxime Coquelin Message-ID: <2354823f-241d-37e9-6664-d6cf183f7c60@redhat.com> Date: Mon, 17 May 2021 12:46:46 +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: X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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" On 5/17/21 12:07 PM, Ling, WeiX wrote: >> -----Original Message----- >> From: Maxime Coquelin >> Sent: Monday, May 17, 2021 03:38 PM >> To: Balazs Nemeth ; dev@dpdk.org; Ling, WeiX >> >> Subject: Re: [dpdk-dev] [PATCH] vhost: fix invalid use of stored last used >> index >> >> 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 > > Hi Maxime, > > Apply your patch https://patches.dpdk.org/project/dpdk/patch/83fa6253725a7bc69bccb7897f380422354a2898.1621008025.git.bnemeth@redhat.com/ based on DPDK-21.05-rc3(7989b7e7da9b), tested PASSED. Thanks for testing with the patch. Reviewed-by: Maxime Coquelin Tested-by: Wei Ling Thanks, Maxime Thanks, Maxime > Regards, > Ling Wei >