From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Hemminger Subject: Re: [PATCH 1/5] vhost: refactor rte_vhost_dequeue_burst Date: Wed, 2 Dec 2015 23:02:44 -0800 Message-ID: <20151202230244.5e4ca3fb@xeon-e3> References: <1449122773-25510-1-git-send-email-yuanhan.liu@linux.intel.com> <1449122773-25510-2-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-pa0-f50.google.com (mail-pa0-f50.google.com [209.85.220.50]) by dpdk.org (Postfix) with ESMTP id 48CB237A6 for ; Thu, 3 Dec 2015 08:02:35 +0100 (CET) Received: by pacdm15 with SMTP id dm15so62846064pac.3 for ; Wed, 02 Dec 2015 23:02:34 -0800 (PST) In-Reply-To: <1449122773-25510-2-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, 3 Dec 2015 14:06:09 +0800 Yuanhan Liu wrote: > +#define COPY(dst, src) do { \ > + cpy_len = RTE_MIN(desc_avail, mbuf_avail); \ > + rte_memcpy((void *)(uintptr_t)(dst), \ > + (const void *)(uintptr_t)(src), cpy_len); \ > + \ > + mbuf_avail -= cpy_len; \ > + mbuf_offset += cpy_len; \ > + desc_avail -= cpy_len; \ > + desc_offset += cpy_len; \ > +} while(0) > + I see lots of issues here. All those void * casts are unnecessary, C casts arguements already. rte_memcpy is slower for constant size values than memcpy() This macro violates the rule that ther should be no hidden variables in a macro. I.e you are assuming cpy_len, desc_avail, and mbuf_avail are defined in all code using the macro. Why use an un-typed macro when an inline function would be just as fast and give type safety?