From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by dpdk.org (Postfix) with ESMTP id F03C9A84C; Fri, 12 Jan 2018 15:55:03 +0100 (CET) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 681CE20F3B; Fri, 12 Jan 2018 09:55:03 -0500 (EST) Received: from frontend1 ([10.202.2.160]) by compute1.internal (MEProxy); Fri, 12 Jan 2018 09:55:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=mesmtp; bh=O3mwQxvEhCi+DoIOP44sYnf+OO Pn8y3d/gLgTVvGgKc=; b=I9I8s5yJhvDI30gi16hI0hIFne2ZdiaHilR1jDgJzI qSLshMUE8Qjve7ulWBtVSQpRH3eSP9yU+3hNkGpAUqbLiaePFgb5PHZn2sldNezz drUMATfquACk4io72b76ZBZyX27EpGyJVJkmaUHmR7epWnADyy6ZXtTssQVKjX9C M= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=O3mwQx vEhCi+DoIOP44sYnf+OOPn8y3d/gLgTVvGgKc=; b=EZxoxkXGjF+SZkaRJBeTIi XfAdm9PQk0xl9AIgIkr0MJHfVawNDt0P9r9pGf4SDty9PNnTBS96WLw26hOBUPoW dgBlBAy8Swmzzo8oliOAkVBMzPlTZ/U8AS7aeReDeK+3HUbzT/Hx8vijWCz4eAvF 5dJAH8rXiJQuPyaBDvNWNQiH6Jkw453xwzl+Eq/g8QQU3Q4KEfqC5Ql4bEoO8iF7 A/Rbf/yEBlI9Bn0ThrZjxiE4Sp47EsfsfQZy673V+5cBDzv2V+rJzXjz0fq2gIxD ztm4R83drpJ6C5uPsrGbDAIFXXF4m6GzsAc0jywKu95yblX6pUFiTki/47MBqtrQ == X-ME-Sender: Received: from xps.localnet (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id 1775D7E4C4; Fri, 12 Jan 2018 09:55:03 -0500 (EST) From: Thomas Monjalon To: Anatoly Burakov Cc: dev@dpdk.org, stable@dpdk.org Date: Fri, 12 Jan 2018 15:54:33 +0100 Message-ID: <17429603.yn0ZjX41h2@xps> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Subject: Re: [dpdk-dev] [PATCH] eal: fix end for bounded malloc elements 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: Fri, 12 Jan 2018 14:55:04 -0000 21/12/2017 17:54, Anatoly Burakov: > In cases when alignment is bigger than boundary, we may incorrectly > calculate end of a bounded malloc element. > > Consider this: suppose we are allocating a bounded malloc element > that should be of 128 bytes in size, bounded to 128 bytes and > aligned on a 256-byte boundary. Suppose our malloc element ends > at 0x140 - that is, 256 plus one cacheline. > > So, right at the start, we are aligning our new_data_start to > include the required element size, and to be aligned on a specified > boundary - so new_data_start becomes 0. This fails the following > bounds check, because our element cannot go above 128 bytes from > the start, and we are at 320. So, we enter the bounds handling > branch. > > While we're in there, we are aligning end_pt to our boundedness > requirement of 128 byte, and end up with 0x100 (since 256 is > 128-byte aligned). We recalculate new_data_size and it stays at > 0, however our end is at 0x100, which is beyond the 128 byte > boundary, and we report inability to reserve a bounded element > when we could have. > > This patch adds an end_pt recalculation after new_data_start > adjustment - we already know that size <= bound, so we can do it > safely - and we then correctly report that we can, in fact, try > using this element for bounded malloc allocation. > > Fixes: fafcc11985a2 ("mem: rework memzone to be allocated by malloc") > Cc: sergio.gonzalez.monroy@intel.com > Cc: stable@dpdk.org > Signed-off-by: Anatoly Burakov It looks to be a headache, but as the maintainer of DPDK memory, I trust you :) Applied, thanks