On Fri, 20 Dec 2024 02:17:12 +0000 "Wangyunjian(wangyunjian,TongTu)" <wangyunj...@huawei.com> wrote:
> > -----Original Message----- > > From: Stephen Hemminger [mailto:step...@networkplumber.org] > > Sent: Friday, December 20, 2024 12:16 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: > > > > > - 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.