From: Maxime Coquelin <maxime.coquelin@redhat.com>
To: "Ling, WeiX" <weix.ling@intel.com>,
Balazs Nemeth <bnemeth@redhat.com>, "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH] vhost: fix invalid use of stored last used index
Date: Mon, 17 May 2021 12:46:46 +0200 [thread overview]
Message-ID: <2354823f-241d-37e9-6664-d6cf183f7c60@redhat.com> (raw)
In-Reply-To: <CO1PR11MB50739F10B1AA03A29D1BA6C3EE2D9@CO1PR11MB5073.namprd11.prod.outlook.com>
On 5/17/21 12:07 PM, Ling, WeiX wrote:
>> -----Original Message-----
>> From: Maxime Coquelin <maxime.coquelin@redhat.com>
>> Sent: Monday, May 17, 2021 03:38 PM
>> To: Balazs Nemeth <bnemeth@redhat.com>; dev@dpdk.org; Ling, WeiX
>> <weix.ling@intel.com>
>> 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 <bnemeth@redhat.com>
>>> ---
>>> 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 <maxime.coquelin@redhat.com>
Tested-by: Wei Ling <weix.ling@intel.com>
Thanks,
Maxime
Thanks,
Maxime
> Regards,
> Ling Wei
>
next prev parent reply other threads:[~2021-05-17 10:46 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-14 16:02 Balazs Nemeth
2021-05-15 6:10 ` David Marchand
2021-05-17 7:37 ` Maxime Coquelin
2021-05-17 10:07 ` Ling, WeiX
2021-05-17 10:46 ` Maxime Coquelin [this message]
2021-05-18 8:03 ` Xia, Chenbo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2354823f-241d-37e9-6664-d6cf183f7c60@redhat.com \
--to=maxime.coquelin@redhat.com \
--cc=bnemeth@redhat.com \
--cc=dev@dpdk.org \
--cc=weix.ling@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).