From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yuanhan Liu Subject: Re: [PATCH] virtio: fix allocating virtnet_rx not mem aligned Date: Tue, 14 Jun 2016 20:44:32 +0800 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 Cc: dev@dpdk.org, huawei.xie@intel.com To: Jianfeng Tan 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) Content-Disposition: inline In-Reply-To: <1465741782-126976-1-git-send-email-jianfeng.tan@intel.com> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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