[PATCH 1/1] vhost: fix a double fetch when dequeue offloading

Wangyunjian(wangyunjian,TongTu) wangyunjian at huawei.com
Mon Dec 23 03:45:48 CET 2024



> -----Original Message-----
> From: Stephen Hemminger [mailto:stephen at networkplumber.org]
> Sent: Saturday, December 21, 2024 12:36 AM
> To: Wangyunjian(wangyunjian,TongTu) <wangyunjian at huawei.com>
> Cc: dev at dpdk.org; maxime.coquelin at redhat.com; chenbox at nvidia.com;
> Lilijun (Jerry) <jerry.lilijun at huawei.com>; xiawei (H) <xiawei40 at huawei.com>;
> wangzengyuan <wangzengyuan at huawei.com>; stable at 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 <wangyunjian at 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


More information about the stable mailing list