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

Stephen Hemminger stephen at networkplumber.org
Fri Dec 20 05:59:52 CET 2024


On Fri, 20 Dec 2024 02:17:12 +0000
"Wangyunjian(wangyunjian,TongTu)" <wangyunjian at huawei.com> wrote:

> > -----Original Message-----
> > From: Stephen Hemminger [mailto:stephen at networkplumber.org]
> > Sent: Friday, December 20, 2024 12:16 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:
> >   
> > > -			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));
> > >  		}  
> > 
> > Do not introduce more rte_memcpy of a fixed size.
> > You don't need that many casts!
> > Why can you not use a structure assignment here.  
> 
>  The virtio_hdr is a shared component, and other fields within it are read
> multiple times. This can potentially result in a double fetch scenario.


The point is do a copy, but not with rte_memcpy.
Also you need a rte_compiler_barrier() anyway.


More information about the stable mailing list