From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yuanhan Liu Subject: Re: [PATCH v2 4/7] vhost: do not use rte_memcpy for virtio_hdr copy Date: Mon, 7 Mar 2016 14:21:00 +0800 Message-ID: <20160307062100.GA14300@yliu-dev.sh.intel.com> References: <1449122773-25510-1-git-send-email-yuanhan.liu@linux.intel.com> <1455803352-5518-1-git-send-email-yuanhan.liu@linux.intel.com> <1455803352-5518-5-git-send-email-yuanhan.liu@linux.intel.com> <20160306202000.68ce5514@xeon-e3> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: dev@dpdk.org, Victor Kaplansky , "Michael S. Tsirkin" To: Stephen Hemminger Return-path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id C4D082C47 for ; Mon, 7 Mar 2016 07:18:52 +0100 (CET) Content-Disposition: inline In-Reply-To: <20160306202000.68ce5514@xeon-e3> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Sun, Mar 06, 2016 at 08:20:00PM -0800, Stephen Hemminger wrote: > On Thu, 18 Feb 2016 21:49:09 +0800 > Yuanhan Liu wrote: > > > +static inline void > > +copy_virtio_net_hdr(struct vhost_virtqueue *vq, uint64_t desc_addr, > > + struct virtio_net_hdr_mrg_rxbuf hdr) > > +{ > > + if (vq->vhost_hlen == sizeof(struct virtio_net_hdr_mrg_rxbuf)) { > > + *(struct virtio_net_hdr_mrg_rxbuf *)(uintptr_t)desc_addr = hdr; > > + } else { > > + *(struct virtio_net_hdr *)(uintptr_t)desc_addr = hdr.hdr; > > + } > > +} > > + > > Don't use {} around single statements. Oh, I was thinking that it's a personal preference. Okay, I will remove them. > Since you are doing all this casting, why not just use regular old memcpy > which will be inlined by Gcc into same instructions anyway. I thought there are some (tiny) differences: memcpy() is not an inlined function. And I was thinking it generates some slightly more complicated instructions. > And since are always casting the desc_addr, why not pass a type that > doesn't need the additional cast (like void *) You have to cast it from "uint64_t" to "void *" as well while call it. So, that makes no difference. --yliu