From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by dpdk.org (Postfix) with ESMTP id 860901B1B4 for ; Wed, 24 Jan 2018 16:36:27 +0100 (CET) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 3A2B722374; Wed, 24 Jan 2018 10:36:27 -0500 (EST) Received: from frontend1 ([10.202.2.160]) by compute1.internal (MEProxy); Wed, 24 Jan 2018 10:36:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fridaylinux.org; h=cc:date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=c9xHCPaNfhh5z56Mp 75hFXkEGQvFFd138bsxe32UbjI=; b=eD/mcsufsX6ajkidiz8uthokCfRltkjvk wpBwD+3Hb+374PbltaMRpcCsKMtu+IWcLY2ORjwH3a8La0x0K7RDyZZstSkxUyxD w8J47fR1bF7mAnfZxiYBeYjH4D41eXkpBxDLzVFlDSWUWCdx5ZuzjN+nuTy9+1fZ FJCI23PyEI++wqtxHhcJHaMSMj8NPMn3VfPEw7Fl7XoB97jTrnNw+dlsH7Wb8Jla qDUQhEHTKNO6QBRfCcXY2M5ooomOXb2G5e1HOzcXmENLe5MekAqbhwr9tUk2eo/q 4sTyvekCQORMqgjL2kXsszznlAJx9Hci9U0CTIjl7Mu4xtbZbd2Xg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=c9xHCPaNfhh5z56Mp75hFXkEGQvFFd138bsxe32UbjI=; b=bJ1LVtZH rbBisccM74lrchmx2kFKHw/GfT4/Y4lczp5IgKjgv77dUNOnjn3VRTqyNFIm4UOj 4neiOSJZa/zrfgCmeWbP+zU5bYxhMDRXAegmML0fkee9tzHzKSQVbhc+/EPGTWC7 pB+WT9q8QnKsKkw5K78ERttETIf2kl1U27e3EW5h67/rq/eYikGRh4LnahRFMUet KdudcxjQfX5DdbXHyn49TZLvSWZRlucjYUykkVDXdSzBH+VlOHLOJiWatLGS6zTa 18DHukP24KvhS/X0STXiCxW8V3krJa+TCVqukQEVlTyLosK8BfyLEWK7vk6xKJqL T8gqQkmr+HMz8g== X-ME-Sender: Received: from localhost.localdomain (unknown [115.150.27.206]) by mail.messagingengine.com (Postfix) with ESMTPA id 74D2D7E3D4; Wed, 24 Jan 2018 10:36:25 -0500 (EST) From: Yuanhan Liu To: Anatoly Burakov Cc: dpdk stable Date: Wed, 24 Jan 2018 23:31:22 +0800 Message-Id: <1516808026-25523-14-git-send-email-yliu@fridaylinux.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516808026-25523-1-git-send-email-yliu@fridaylinux.org> References: <1516808026-25523-1-git-send-email-yliu@fridaylinux.org> Subject: [dpdk-stable] patch 'malloc: fix end for bounded elements' has been queued to LTS release 17.11.1 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 24 Jan 2018 15:36:27 -0000 Hi, FYI, your patch has been queued to LTS release 17.11.1 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 01/26/18. So please shout if anyone has objections. Thanks. --yliu --- >>From 8430a91880bda9831451b2644b6ac905194e78fa Mon Sep 17 00:00:00 2001 From: Anatoly Burakov Date: Thu, 21 Dec 2017 16:54:24 +0000 Subject: [PATCH] malloc: fix end for bounded elements [ upstream commit 20d2159d4640a1844a5856d8d8df86cf0b24b7c1 ] 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") Signed-off-by: Anatoly Burakov --- lib/librte_eal/common/malloc_elem.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/librte_eal/common/malloc_elem.c b/lib/librte_eal/common/malloc_elem.c index 98bcd37..f6cbc42 100644 --- a/lib/librte_eal/common/malloc_elem.c +++ b/lib/librte_eal/common/malloc_elem.c @@ -98,6 +98,7 @@ elem_start_pt(struct malloc_elem *elem, size_t size, unsigned align, if ((new_data_start & bmask) != ((end_pt - 1) & bmask)) { end_pt = RTE_ALIGN_FLOOR(end_pt, bound); new_data_start = RTE_ALIGN_FLOOR((end_pt - size), align); + end_pt = new_data_start + size; if (((end_pt - 1) & bmask) != (new_data_start & bmask)) return NULL; } -- 2.7.4