> -----Original Message-----
> From: Stephen Hemminger [mailto:step...@networkplumber.org]
> Sent: Saturday, December 21, 2024 12:36 AM
> To: Wangyunjian(wangyunjian,TongTu) <wangyunj...@huawei.com>
> Cc: dev@dpdk.org; maxime.coque...@redhat.com; chen...@nvidia.com;
> Lilijun (Jerry) <jerry.lili...@huawei.com>; xiawei (H) <xiawe...@huawei.com>;
> wangzengyuan <wangzengy...@huawei.com>; sta...@dpdk.org
> Subject: Re: [PATCH 1/1] vhost: fix a double fetch when dequeue offloading
> 
> On Thu, 19 Dec 2024 14:38:28 +0800
> Yunjian Wang <wangyunj...@huawei.com> wrote:
> 
> > diff --git a/lib/vhost/virtio_net.c b/lib/vhost/virtio_net.c
> > index 69901ab3b5..5c40ae7069 100644
> > --- a/lib/vhost/virtio_net.c
> > +++ b/lib/vhost/virtio_net.c
> > @@ -2914,10 +2914,12 @@ desc_to_mbuf(struct virtio_net *dev, struct
> vhost_virtqueue *vq,
> >                      * in a contiguous virtual area.
> >                      */
> >                     copy_vnet_hdr_from_desc(&tmp_hdr, buf_vec);
> > -                   hdr = &tmp_hdr;
> >             } else {
> > -                   hdr = (struct virtio_net_hdr 
> > *)((uintptr_t)buf_vec[0].buf_addr);
> > +                   rte_memcpy((void *)(uintptr_t)&tmp_hdr,
> > +                           (void *)(uintptr_t)buf_vec[0].buf_addr,
> > +                           sizeof(struct virtio_net_hdr));
> >             }
> > +           hdr = &tmp_hdr;
> 
> Since this if block is just an optimization of the case where vnet header
> is contiguous why not just always use copy_vnet_hdr_from_desc? and inline it?

I also considered using the copy_vnet_hdr_from_desc function directly.
However, in most cases, the vnet header is continuous, and reusing
copy_vnet_hdr_from_desc results in additional operations.

Thanks,
Yunjian

Reply via email to