DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] ivshmem: avoid infinite loop when concatenating adjacent segments
@ 2015-12-19 22:39 David Verbeiren
  2016-04-01 14:12 ` Thomas Monjalon
  2016-04-07 11:00 ` [dpdk-dev] [PATCH v2] " Anatoly Burakov
  0 siblings, 2 replies; 6+ messages in thread
From: David Verbeiren @ 2015-12-19 22:39 UTC (permalink / raw)
  To: dev, david.verbeiren

This patch aligns the logic used to check for the presence of
adjacent segments in has_adjacent_segments() with the logic used
in cleanup_segments() when actually deciding to concatenate or
not a pair of segments.

This fixes an infinite loop that happened when segments where
adjacent in their physical or virtual addresses but not in their
ioremap addresses: has_adjacent_segments() reported the presence
of adjacent segments while cleanup_segments() was not considering
them for concatenation, resulting in an infinite loop since the
result of has_adjacent_segments() is used in the decision to
continue looping in cleanup_segments().

Signed-off-by: David Verbeiren <david.verbeiren@intel.com>
---
 lib/librte_eal/linuxapp/eal/eal_ivshmem.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/lib/librte_eal/linuxapp/eal/eal_ivshmem.c b/lib/librte_eal/linuxapp/eal/eal_ivshmem.c
index 589019b..086cafb 100644
--- a/lib/librte_eal/linuxapp/eal/eal_ivshmem.c
+++ b/lib/librte_eal/linuxapp/eal/eal_ivshmem.c
@@ -254,17 +254,18 @@ adjacent(const struct rte_memzone * mz1, const struct rte_memzone * mz2)
 static int
 has_adjacent_segments(struct ivshmem_segment * ms, int len)
 {
-	int i, j, a;
+	int i, j;
 
 	for (i = 0; i < len; i++)
 		for (j = i + 1; j < len; j++) {
-			a = adjacent(&ms[i].entry.mz, &ms[j].entry.mz);
-
-			/* check if segments are adjacent virtually and/or physically but
-			 * not ioremap (since that would indicate that they are from
-			 * different PCI devices and thus don't need to be concatenated.
+			
+			/* check if segments are adjacent virtually and physically.
+			 * They must also be adjacent in ioremap since disjoint
+			 * ioremap segments would be from different PCI devices and
+			 * thus don't need to be concatenated. This is the logic 
+			 * used in cleanup_segments() and must be in sync.
 			 */
-			if ((a & (VIRT|PHYS)) > 0 && (a & IOREMAP) == 0)
+			if (adjacent(&ms[i].entry.mz, &ms[j].entry.mz) == FULL)
 				return 1;
 		}
 	return 0;
-- 
1.9.1

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

end of thread, other threads:[~2016-04-07 17:18 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-19 22:39 [dpdk-dev] [PATCH] ivshmem: avoid infinite loop when concatenating adjacent segments David Verbeiren
2016-04-01 14:12 ` Thomas Monjalon
2016-04-01 14:46   ` Burakov, Anatoly
2016-04-01 15:59     ` Burakov, Anatoly
2016-04-07 11:00 ` [dpdk-dev] [PATCH v2] " Anatoly Burakov
2016-04-07 17:18   ` 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).