From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 0FDA0689B; Wed, 11 Jan 2017 05:25:03 +0100 (CET) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga103.fm.intel.com with ESMTP; 10 Jan 2017 20:25:03 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,345,1477983600"; d="scan'208";a="211972514" Received: from yliu-dev.sh.intel.com ([10.239.67.162]) by fmsmga004.fm.intel.com with ESMTP; 10 Jan 2017 20:25:02 -0800 From: Yuanhan Liu To: dev@dpdk.org Cc: Tan Jianfeng , Wang Zhihong , Yuanhan Liu , Maxime Coquelin , "Michael S. Tsirkin" , stable@dpdk.org Date: Wed, 11 Jan 2017 12:27:12 +0800 Message-Id: <1484108832-19907-3-git-send-email-yuanhan.liu@linux.intel.com> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1484108832-19907-1-git-send-email-yuanhan.liu@linux.intel.com> References: <1484108832-19907-1-git-send-email-yuanhan.liu@linux.intel.com> Subject: [dpdk-dev] [PATCH 2/2] net/virtio: optimize header reset on any layout X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Jan 2017 04:25:04 -0000 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 Cc: Michael S. Tsirkin Cc: stable@dpdk.org Signed-off-by: Yuanhan Liu --- 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