DPDK patches and discussions
 help / color / mirror / Atom feed
From: Anatoly Burakov <anatoly.burakov@intel.com>
To: dev@dpdk.org
Cc: yuwei1.zhang@intel.com, stable@dpdk.org
Subject: [dpdk-dev] [PATCH v2] malloc: fix adjacency check to also include segment list
Date: Wed, 14 Nov 2018 15:00:58 +0000	[thread overview]
Message-ID: <6a0a1a54d58a7c72380860c1da9e36d512c0ccd2.1542207435.git.anatoly.burakov@intel.com> (raw)
In-Reply-To: <8533ab3a49f63e9700764ead8b9147a098911b41.1542204687.git.anatoly.burakov@intel.com>

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 <anatoly.burakov@intel.com>
---

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;
 }
 
 /*
-- 
2.17.1

  reply	other threads:[~2018-11-14 15:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-14 14:51 [dpdk-dev] [PATCH] memalloc: check for contiguousness in external segments Anatoly Burakov
2018-11-14 15:00 ` Anatoly Burakov [this message]
2018-11-14 16:04   ` [dpdk-dev] [PATCH v2] malloc: fix adjacency check to also include segment list Burakov, Anatoly
2018-11-18 13:15   ` Thomas Monjalon
2018-11-18 13:05 ` [dpdk-dev] [PATCH] memalloc: check for contiguousness in external segments Thomas Monjalon
2018-11-18 16:21 ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6a0a1a54d58a7c72380860c1da9e36d512c0ccd2.1542207435.git.anatoly.burakov@intel.com \
    --to=anatoly.burakov@intel.com \
    --cc=dev@dpdk.org \
    --cc=stable@dpdk.org \
    --cc=yuwei1.zhang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).