From: Anatoly Burakov <anatoly.burakov@intel.com>
To: dev@dpdk.org
Cc: david.verbeiren@intel.com, thomas.monjalon@6wind.com
Subject: [dpdk-dev] [PATCH v2] ivshmem: avoid infinite loop when concatenating adjacent segments
Date: Thu, 7 Apr 2016 12:00:00 +0100 [thread overview]
Message-ID: <1460026800-24159-1-git-send-email-anatoly.burakov@intel.com> (raw)
In-Reply-To: <1450564772-20000-1-git-send-email-david.verbeiren@intel.com>
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. Additionally, adjacent segments are
no longer considered overlapping to avoid generating errors for
segments that can happily coexist together.
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>
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
lib/librte_eal/linuxapp/eal/eal_ivshmem.c | 21 +++++++++------------
1 file changed, 9 insertions(+), 12 deletions(-)
diff --git a/lib/librte_eal/linuxapp/eal/eal_ivshmem.c b/lib/librte_eal/linuxapp/eal/eal_ivshmem.c
index 28ddf09..07aec69 100644
--- a/lib/librte_eal/linuxapp/eal/eal_ivshmem.c
+++ b/lib/librte_eal/linuxapp/eal/eal_ivshmem.c
@@ -184,21 +184,21 @@ overlap(const struct rte_memzone * mz1, const struct rte_memzone * mz2)
i_end2 = mz2->ioremap_addr + mz2->len;
/* check for overlap in virtual addresses */
- if (start1 >= start2 && start1 < end2)
+ if (start1 > start2 && start1 < end2)
result |= VIRT;
if (start2 >= start1 && start2 < end1)
result |= VIRT;
/* check for overlap in physical addresses */
- if (p_start1 >= p_start2 && p_start1 < p_end2)
+ if (p_start1 > p_start2 && p_start1 < p_end2)
result |= PHYS;
- if (p_start2 >= p_start1 && p_start2 < p_end1)
+ if (p_start2 > p_start1 && p_start2 < p_end1)
result |= PHYS;
/* check for overlap in ioremap addresses */
- if (i_start1 >= i_start2 && i_start1 < i_end2)
+ if (i_start1 > i_start2 && i_start1 < i_end2)
result |= IOREMAP;
- if (i_start2 >= i_start1 && i_start2 < i_end1)
+ if (i_start2 > i_start1 && i_start2 < i_end1)
result |= IOREMAP;
return result;
@@ -254,17 +254,14 @@ 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.
+ /* we're only interested in fully adjacent segments; partially
+ * adjacent segments can coexist.
*/
- if ((a & (VIRT|PHYS)) > 0 && (a & IOREMAP) == 0)
+ if (adjacent(&ms[i].entry.mz, &ms[j].entry.mz) == FULL)
return 1;
}
return 0;
--
2.5.0
next prev parent reply other threads:[~2016-04-07 11:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-19 22:39 [dpdk-dev] [PATCH] " 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 ` Anatoly Burakov [this message]
2016-04-07 17:18 ` [dpdk-dev] [PATCH v2] " 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=1460026800-24159-1-git-send-email-anatoly.burakov@intel.com \
--to=anatoly.burakov@intel.com \
--cc=david.verbeiren@intel.com \
--cc=dev@dpdk.org \
--cc=thomas.monjalon@6wind.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).