On Fri, 20 Dec 2024 02:17:12 +0000 "Wangyunjian(wangyunjian,TongTu)" <[email protected]> wrote:
> > -----Original Message----- > > From: Stephen Hemminger [mailto:[email protected]] > > Sent: Friday, December 20, 2024 12:16 AM > > To: Wangyunjian(wangyunjian,TongTu) <[email protected]> > > Cc: [email protected]; [email protected]; [email protected]; > > Lilijun (Jerry) <[email protected]>; xiawei (H) > > <[email protected]>; > > wangzengyuan <[email protected]>; [email protected] > > Subject: Re: [PATCH 1/1] vhost: fix a double fetch when dequeue offloading > > > > On Thu, 19 Dec 2024 14:38:28 +0800 > > Yunjian Wang <[email protected]> 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.

