DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] malloc: fix adjacency check to also include segment list
@ 2018-11-14 14:51 Anatoly Burakov
  0 siblings, 0 replies; only message in thread
From: Anatoly Burakov @ 2018-11-14 14:51 UTC (permalink / raw)
  To: dev; +Cc: yuwei1.zhang, stable

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>
 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;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2018-11-14 14:51 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-14 14:51 [dpdk-dev] [PATCH] malloc: fix adjacency check to also include segment list Anatoly Burakov

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git