From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Hemminger Subject: Re: [PATCH v2 4/7] vhost: do not use rte_memcpy for virtio_hdr copy Date: Sun, 6 Mar 2016 20:20:00 -0800 Message-ID: <20160306202000.68ce5514@xeon-e3> 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> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: dev@dpdk.org, Victor Kaplansky , "Michael S. Tsirkin" To: Yuanhan Liu Return-path: Received: from mail-pf0-f169.google.com (mail-pf0-f169.google.com [209.85.192.169]) by dpdk.org (Postfix) with ESMTP id 5E7842142 for ; Mon, 7 Mar 2016 05:19:47 +0100 (CET) Received: by mail-pf0-f169.google.com with SMTP id 124so72800300pfg.0 for ; Sun, 06 Mar 2016 20:19:47 -0800 (PST) In-Reply-To: <1455803352-5518-5-git-send-email-yuanhan.liu@linux.intel.com> 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 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. Since you are doing all this casting, why not just use regular old memcpy which will be inlined by Gcc into same instructions anyway. And since are always casting the desc_addr, why not pass a type that doesn't need the additional cast (like void *)