DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] memalloc: check for contiguousness in external segments
@ 2018-11-14 14:51 Anatoly Burakov
  2018-11-14 15:00 ` [dpdk-dev] [PATCH v2] malloc: fix adjacency check to also include segment list Anatoly Burakov
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Anatoly Burakov @ 2018-11-14 14:51 UTC (permalink / raw)
  To: dev; +Cc: yuwei1.zhang

For IOVA as VA mode, we assume that memory is contiguous. However,
for external segments that assumption may not necessarily hold.
Fix the code to not assume that external memory segments are
contiguous even in IOVA as VA mode.

Fixes: 5282bb1c3695 ("mem: allow memseg lists to be marked as external")

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 lib/librte_eal/common/eal_common_memalloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_eal/common/eal_common_memalloc.c b/lib/librte_eal/common/eal_common_memalloc.c
index 1d41ea112..371271979 100644
--- a/lib/librte_eal/common/eal_common_memalloc.c
+++ b/lib/librte_eal/common/eal_common_memalloc.c
@@ -77,7 +77,7 @@ eal_memalloc_is_contig(const struct rte_memseg_list *msl, void *start,
 	const struct rte_memseg *ms;
 
 	/* for IOVA_VA, it's always contiguous */
-	if (rte_eal_iova_mode() == RTE_IOVA_VA)
+	if (rte_eal_iova_mode() == RTE_IOVA_VA && !msl->external)
 		return true;
 
 	/* for legacy memory, it's always contiguous */
-- 
2.17.1

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [dpdk-dev] [PATCH v2] malloc: fix adjacency check to also include segment list
  2018-11-14 14:51 [dpdk-dev] [PATCH] memalloc: check for contiguousness in external segments Anatoly Burakov
@ 2018-11-14 15:00 ` Anatoly Burakov
  2018-11-14 16:04   ` 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
  2 siblings, 2 replies; 6+ messages in thread
From: Anatoly Burakov @ 2018-11-14 15:00 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>
---

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-dev] [PATCH v2] malloc: fix adjacency check to also include segment list
  2018-11-14 15:00 ` [dpdk-dev] [PATCH v2] malloc: fix adjacency check to also include segment list Anatoly Burakov
@ 2018-11-14 16:04   ` Burakov, Anatoly
  2018-11-18 13:15   ` Thomas Monjalon
  1 sibling, 0 replies; 6+ messages in thread
From: Burakov, Anatoly @ 2018-11-14 16:04 UTC (permalink / raw)
  To: dev; +Cc: yuwei1.zhang, stable

On 14-Nov-18 3:00 PM, Anatoly Burakov wrote:
> 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>
> ---

Oops, reply tag was set wrong.

-- 
Thanks,
Anatoly

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-dev] [PATCH] memalloc: check for contiguousness in external segments
  2018-11-14 14:51 [dpdk-dev] [PATCH] memalloc: check for contiguousness in external segments Anatoly Burakov
  2018-11-14 15:00 ` [dpdk-dev] [PATCH v2] malloc: fix adjacency check to also include segment list Anatoly Burakov
@ 2018-11-18 13:05 ` Thomas Monjalon
  2018-11-18 16:21 ` Thomas Monjalon
  2 siblings, 0 replies; 6+ messages in thread
From: Thomas Monjalon @ 2018-11-18 13:05 UTC (permalink / raw)
  To: Anatoly Burakov; +Cc: dev, yuwei1.zhang

14/11/2018 15:51, Anatoly Burakov:
> For IOVA as VA mode, we assume that memory is contiguous. However,
> for external segments that assumption may not necessarily hold.
> Fix the code to not assume that external memory segments are
> contiguous even in IOVA as VA mode.
> 
> Fixes: 5282bb1c3695 ("mem: allow memseg lists to be marked as external")
> 
> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>

Applied, thanks

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-dev] [PATCH v2] malloc: fix adjacency check to also include segment list
  2018-11-14 15:00 ` [dpdk-dev] [PATCH v2] malloc: fix adjacency check to also include segment list Anatoly Burakov
  2018-11-14 16:04   ` Burakov, Anatoly
@ 2018-11-18 13:15   ` Thomas Monjalon
  1 sibling, 0 replies; 6+ messages in thread
From: Thomas Monjalon @ 2018-11-18 13:15 UTC (permalink / raw)
  To: Anatoly Burakov; +Cc: dev, yuwei1.zhang, stable

14/11/2018 16:00, Anatoly Burakov:
> 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>

Applied, thanks

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-dev] [PATCH] memalloc: check for contiguousness in external segments
  2018-11-14 14:51 [dpdk-dev] [PATCH] memalloc: check for contiguousness in external segments Anatoly Burakov
  2018-11-14 15:00 ` [dpdk-dev] [PATCH v2] malloc: fix adjacency check to also include segment list Anatoly Burakov
  2018-11-18 13:05 ` [dpdk-dev] [PATCH] memalloc: check for contiguousness in external segments Thomas Monjalon
@ 2018-11-18 16:21 ` Thomas Monjalon
  2 siblings, 0 replies; 6+ messages in thread
From: Thomas Monjalon @ 2018-11-18 16:21 UTC (permalink / raw)
  To: Anatoly Burakov; +Cc: dev, yuwei1.zhang

14/11/2018 15:51, Anatoly Burakov:
> For IOVA as VA mode, we assume that memory is contiguous. However,
> for external segments that assumption may not necessarily hold.
> Fix the code to not assume that external memory segments are
> contiguous even in IOVA as VA mode.
> 
> Fixes: 5282bb1c3695 ("mem: allow memseg lists to be marked as external")
> 
> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>

Applied, thanks

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-11-18 16:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-14 14:51 [dpdk-dev] [PATCH] memalloc: check for contiguousness in external segments Anatoly Burakov
2018-11-14 15:00 ` [dpdk-dev] [PATCH v2] malloc: fix adjacency check to also include segment list Anatoly Burakov
2018-11-14 16:04   ` 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

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).