From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 3E7A38E5A for ; Tue, 14 Jun 2016 14:42:29 +0200 (CEST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP; 14 Jun 2016 05:42:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,470,1459839600"; d="scan'208";a="987159604" Received: from yliu-dev.sh.intel.com (HELO yliu-dev) ([10.239.67.162]) by fmsmga001.fm.intel.com with ESMTP; 14 Jun 2016 05:42:25 -0700 Date: Tue, 14 Jun 2016 20:44:32 +0800 From: Yuanhan Liu To: Jianfeng Tan Cc: dev@dpdk.org, huawei.xie@intel.com Message-ID: <20160614124432.GZ10038@yliu-dev.sh.intel.com> References: <1465741782-126976-1-git-send-email-jianfeng.tan@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1465741782-126976-1-git-send-email-jianfeng.tan@intel.com> User-Agent: Mutt/1.5.23 (2014-03-12) Subject: Re: [dpdk-dev] [PATCH] virtio: fix allocating virtnet_rx not mem aligned X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Jun 2016 12:42:29 -0000 On Sun, Jun 12, 2016 at 02:29:42PM +0000, Jianfeng Tan wrote: > Compile DPDK with clang, below line in virtio_rxtx.c could be > optimized with four "VMOVAPS ymm, m256". > memset(&rxvq->fake_mbuf, 0, sizeof(rxvq->fake_mbuf)); > > This instruction requires memory address is 32-byte aligned. > Or, it leads to segfault. Although only tested with Clang 3.6.0, > it can be reproduced in any compilers, which do aggressive > optimization, aka, change memset of known length to VMOVAPS. > > The fact that struct rte_mbuf is cache line aligned, can only make > sure fake_mbuf is aligned compared to the start address of struct > virtnet_rx. Unfortunately, this address is not necessarily aligned > because it's allocated by: > rxvq = (struct virtnet_rx *)RTE_PTR_ADD(vq, sz_vq); > > When sz_vq is not aligned, then rxvq cannot be allocated with an > aligned address, and then rxvq->fake_mbuf (addr of rxvq + cache line > size) is not an aligned address. > > The fix is very simple that making sz_vq 32-byte aligned. Here we > make it cache line aligned for future optimization. > > Fixes: a900472aedef ("virtio: split virtio Rx/Tx queue") Folded this fix (and the other fix) to above commit, so that we could have a clean working tree. Thanks for good catch! --yliu