From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id 4E2AD592C; Wed, 11 Jan 2017 09:01:27 +0100 (CET) Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9DE8B61B85; Wed, 11 Jan 2017 08:01:27 +0000 (UTC) Received: from [10.36.116.159] (ovpn-116-159.ams2.redhat.com [10.36.116.159]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v0B81NTV010302 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 11 Jan 2017 03:01:25 -0500 To: Yuanhan Liu , dev@dpdk.org References: <1484108832-19907-1-git-send-email-yuanhan.liu@linux.intel.com> <1484108832-19907-3-git-send-email-yuanhan.liu@linux.intel.com> Cc: Tan Jianfeng , Wang Zhihong , "Michael S. Tsirkin" , stable@dpdk.org From: Maxime Coquelin Message-ID: <5df60187-ced5-56d0-9894-3e6783209c3b@redhat.com> Date: Wed, 11 Jan 2017 09:01:21 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <1484108832-19907-3-git-send-email-yuanhan.liu@linux.intel.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 11 Jan 2017 08:01:27 +0000 (UTC) Subject: Re: [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 08:01:27 -0000 On 01/11/2017 05:27 AM, Yuanhan Liu wrote: > 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. > Reviewed-by: Maxime Coquelin Thanks! Maxime