From patchwork Wed Nov 14 15:00:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anatoly Burakov X-Patchwork-Id: 48080 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 788C51B147; Wed, 14 Nov 2018 16:01:19 +0100 (CET) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id CAC231B130; Wed, 14 Nov 2018 16:01:17 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Nov 2018 07:01:16 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,232,1539673200"; d="scan'208";a="108519817" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga002.jf.intel.com with ESMTP; 14 Nov 2018 07:00:59 -0800 Received: from sivswdev01.ir.intel.com (sivswdev01.ir.intel.com [10.237.217.45]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id wAEF0xML002605; Wed, 14 Nov 2018 15:00:59 GMT Received: from sivswdev01.ir.intel.com (localhost [127.0.0.1]) by sivswdev01.ir.intel.com with ESMTP id wAEF0x3u013978; Wed, 14 Nov 2018 15:00:59 GMT Received: (from aburakov@localhost) by sivswdev01.ir.intel.com with LOCAL id wAEF0was013974; Wed, 14 Nov 2018 15:00:58 GMT From: Anatoly Burakov To: dev@dpdk.org Cc: yuwei1.zhang@intel.com, stable@dpdk.org Date: Wed, 14 Nov 2018 15:00:58 +0000 Message-Id: <6a0a1a54d58a7c72380860c1da9e36d512c0ccd2.1542207435.git.anatoly.burakov@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: <8533ab3a49f63e9700764ead8b9147a098911b41.1542204687.git.anatoly.burakov@intel.com> References: <8533ab3a49f63e9700764ead8b9147a098911b41.1542204687.git.anatoly.burakov@intel.com> Subject: [dpdk-dev] [PATCH v2] malloc: fix adjacency check to also include segment list 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" It may so happen that two memory locations may be adjacent in virtual memory, but belong to different segment lists. With current code, such segments will be concatenated. Fix the adjacency checking code to also check if the adjacent malloc elements belong to the same memseg list. Fixes: 66cc45e293ed ("mem: replace memseg with memseg lists") Cc: stable@dpdk.org Signed-off-by: Anatoly Burakov --- Notes: v2: fixed typo in second comparison lib/librte_eal/common/malloc_elem.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/librte_eal/common/malloc_elem.c b/lib/librte_eal/common/malloc_elem.c index 1a74660de..9d3dcb6a9 100644 --- a/lib/librte_eal/common/malloc_elem.c +++ b/lib/librte_eal/common/malloc_elem.c @@ -316,13 +316,15 @@ remove_elem(struct malloc_elem *elem) static int next_elem_is_adjacent(struct malloc_elem *elem) { - return elem->next == RTE_PTR_ADD(elem, elem->size); + return elem->next == RTE_PTR_ADD(elem, elem->size) && + elem->next->msl == elem->msl; } static int prev_elem_is_adjacent(struct malloc_elem *elem) { - return elem == RTE_PTR_ADD(elem->prev, elem->prev->size); + return elem == RTE_PTR_ADD(elem->prev, elem->prev->size) && + elem->prev->msl == elem->msl; } /*