[dpdk-dev] [PATCH 1/5] vhost: refactor rte_vhost_dequeue_burst
Stephen Hemminger
stephen at networkplumber.org
Thu Dec 3 08:02:44 CET 2015
On Thu, 3 Dec 2015 14:06:09 +0800
Yuanhan Liu <yuanhan.liu at linux.intel.com> 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?
More information about the dev
mailing list