DPDK patches and discussions
 help / color / mirror / Atom feed
From: Yuanhan Liu <yuanhan.liu@linux.intel.com>
To: dev@dpdk.org
Cc: Tan Jianfeng <jianfeng.tan@intel.com>,
	Wang Zhihong <zhihong.wang@intel.com>,
	Yuanhan Liu <yuanhan.liu@linux.intel.com>,
	Maxime Coquelin <maxime.coquelin@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	stable@dpdk.org
Subject: [dpdk-dev] [PATCH 2/2] net/virtio: optimize header reset on any layout
Date: Wed, 11 Jan 2017 12:27:12 +0800	[thread overview]
Message-ID: <1484108832-19907-3-git-send-email-yuanhan.liu@linux.intel.com> (raw)
In-Reply-To: <1484108832-19907-1-git-send-email-yuanhan.liu@linux.intel.com>

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: Maxime Coquelin <maxime.coquelin@redhat.com>
Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: stable@dpdk.org
Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
---
 drivers/net/virtio/virtio_rxtx.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c
index 8ec2f1a..5ca3a88 100644
--- a/drivers/net/virtio/virtio_rxtx.c
+++ b/drivers/net/virtio/virtio_rxtx.c
@@ -292,8 +292,14 @@
 		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.
-- 
1.9.0

  parent reply	other threads:[~2017-01-11  4:25 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-11  4:27 [dpdk-dev] [PATCH 0/2] net/virtio: optimize virtio net header reset Yuanhan Liu
2017-01-11  4:27 ` [dpdk-dev] [PATCH 1/2] net/virtio: fix performance regression due to TSO enabling Yuanhan Liu
2017-01-11  7:59   ` Maxime Coquelin
2017-01-11  8:08     ` Yuanhan Liu
2017-01-11  8:22     ` Olivier MATZ
2017-01-11 14:51   ` [dpdk-dev] [dpdk-stable] " Thomas Monjalon
2017-01-12  2:30     ` Yuanhan Liu
2017-01-12 15:02       ` Jan Viktorin
2017-01-13  6:13         ` Yuanhan Liu
2017-01-16  7:12           ` Yuanhan Liu
     [not found]             ` <46569522-b2c3-2a33-9111-049b73c79760@stud.fit.vutbr.cz>
     [not found]               ` <20170116111256.GA11439@yliu-dev.sh.intel.com>
     [not found]                 ` <8e8178c6-caa2-1b6e-10a0-c83820868db5@stud.fit.vutbr.cz>
2017-01-16 11:21                   ` Yuanhan Liu
     [not found]                     ` <a12848b4-76ef-29bc-f512-81bd8c1b9b76@stud.fit.vutbr.cz>
2017-01-30 13:30                       ` Yuanhan Liu
2017-01-30 13:54                         ` Maxime Coquelin
2017-01-30 14:10                           ` Yuanhan Liu
2017-01-11  4:27 ` Yuanhan Liu [this message]
2017-01-11  8:01   ` [dpdk-dev] [PATCH 2/2] net/virtio: optimize header reset on any layout Maxime Coquelin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1484108832-19907-3-git-send-email-yuanhan.liu@linux.intel.com \
    --to=yuanhan.liu@linux.intel.com \
    --cc=dev@dpdk.org \
    --cc=jianfeng.tan@intel.com \
    --cc=maxime.coquelin@redhat.com \
    --cc=mst@redhat.com \
    --cc=stable@dpdk.org \
    --cc=zhihong.wang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).