From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <yuanhan.liu@linux.intel.com>
Received: from mga11.intel.com (mga11.intel.com [192.55.52.93])
 by dpdk.org (Postfix) with ESMTP id C4D082C47
 for <dev@dpdk.org>; Mon,  7 Mar 2016 07:18:52 +0100 (CET)
Received: from orsmga002.jf.intel.com ([10.7.209.21])
 by fmsmga102.fm.intel.com with ESMTP; 06 Mar 2016 22:18:51 -0800
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.22,549,1449561600"; d="scan'208";a="928291414"
Received: from yliu-dev.sh.intel.com (HELO yliu-dev) ([10.239.66.49])
 by orsmga002.jf.intel.com with ESMTP; 06 Mar 2016 22:18:51 -0800
Date: Mon, 7 Mar 2016 14:21:00 +0800
From: Yuanhan Liu <yuanhan.liu@linux.intel.com>
To: Stephen Hemminger <stephen@networkplumber.org>
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
Content-Disposition: inline
In-Reply-To: <20160306202000.68ce5514@xeon-e3>
User-Agent: Mutt/1.5.23 (2014-03-12)
Cc: dev@dpdk.org, Victor Kaplansky <vkaplans@redhat.com>,
 "Michael S. Tsirkin" <mst@redhat.com>
Subject: Re: [dpdk-dev] [PATCH v2 4/7] vhost: do not use rte_memcpy for
 virtio_hdr copy
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: patches and discussions about DPDK <dev.dpdk.org>
List-Unsubscribe: <http://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <http://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Mon, 07 Mar 2016 06:18:53 -0000

On Sun, Mar 06, 2016 at 08:20:00PM -0800, Stephen Hemminger wrote:
> On Thu, 18 Feb 2016 21:49:09 +0800
> Yuanhan Liu <yuanhan.liu@linux.intel.com> 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