From: Yuanhan Liu Date: Wed, 11 Jan 2017 04:27:12 +0000 (+0800) Subject: net/virtio: optimize header reset on any layout X-Git-Tag: spdx-start~4630 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=16994abee215e55dcccf19114b324d5c407b3f56;p=dpdk.git net/virtio: optimize header reset on any layout When any layout is used, the header is stored in the head room of mbuf. mbuf is allocated and filled by user, means there is no gurateen the header is all zero for non TSO case. Therefore, we have to do the reset by ourself: memest(hdr, 0, head_size); The memset has two impacts on performance: - memset could not be inlined, which is a bit costly. - more importantly, it touches the mbuf, which could introduce severe cache issues as described by former patch. Similiary, we could do the same trick: reset just when necessary, when the corresponding field is already 0, which is likely true for a simple l2 forward case. It could boost the performance up to 20+% in micro benchmarking. Cc: stable@dpdk.org Cc: Maxime Coquelin Cc: Michael S. Tsirkin Signed-off-by: Yuanhan Liu Reviewed-by: Maxime Coquelin --- diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c index 21948372db..594b6ffab9 100644 --- a/drivers/net/virtio/virtio_rxtx.c +++ b/drivers/net/virtio/virtio_rxtx.c @@ -301,8 +301,14 @@ virtqueue_enqueue_xmit(struct virtnet_tx *txvq, struct rte_mbuf *cookie, hdr = (struct virtio_net_hdr *) rte_pktmbuf_prepend(cookie, head_size); /* if offload disabled, it is not zeroed below, do it now */ - if (offload == 0) - memset(hdr, 0, head_size); + if (offload == 0) { + ASSIGN_UNLESS_EQUAL(hdr->csum_start, 0); + ASSIGN_UNLESS_EQUAL(hdr->csum_offset, 0); + ASSIGN_UNLESS_EQUAL(hdr->flags, 0); + ASSIGN_UNLESS_EQUAL(hdr->gso_type, 0); + ASSIGN_UNLESS_EQUAL(hdr->gso_size, 0); + ASSIGN_UNLESS_EQUAL(hdr->hdr_len, 0); + } } else if (use_indirect) { /* setup tx ring slot to point to indirect * descriptor list stored in reserved region.