From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id BFD3A1B12B; Wed, 14 Nov 2018 15:51:56 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Nov 2018 06:51:55 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,232,1539673200"; d="scan'208";a="273949955" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga005.jf.intel.com with ESMTP; 14 Nov 2018 06:51:54 -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 wAEEps3F000633; Wed, 14 Nov 2018 14:51:54 GMT Received: from sivswdev01.ir.intel.com (localhost [127.0.0.1]) by sivswdev01.ir.intel.com with ESMTP id wAEEpr9g008480; Wed, 14 Nov 2018 14:51:53 GMT Received: (from aburakov@localhost) by sivswdev01.ir.intel.com with LOCAL id wAEEpriV008472; Wed, 14 Nov 2018 14:51:53 GMT From: Anatoly Burakov To: dev@dpdk.org Cc: yuwei1.zhang@intel.com, stable@dpdk.org Date: Wed, 14 Nov 2018 14:51:53 +0000 Message-Id: X-Mailer: git-send-email 1.7.0.7 Subject: [dpdk-dev] [PATCH] 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: , X-List-Received-Date: Wed, 14 Nov 2018 14:51:57 -0000 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 --- 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..c302be305 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; } /* -- 2.17.1