This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "".
The branch, master has been updated
via 0d6c0804640151f8aa9970cc74f1fef28a11fac1 (commit)
from b17aeea11a9bac1f5d55463e81904af12c99b4c7 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 0d6c0804640151f8aa9970cc74f1fef28a11fac1
Author: Christophe Milard <christophe.milard(a)linaro.org>
Date: Mon Jan 23 16:38:37 2017 +0100
linux-gen: _ishmphy: fix possible race with malloc
_ishm prereserves address space for _ODP_ISHM_SINGLE_VA allocated memory
by reserving unreachable "memory", using PROT_NONE, hence really allocating
virtual space (as the memory cannot be hit).
The problem came when trying to use some of this preallocated space:
strangely, if a new mapping on the preallocated virtual space failed (e.g.
due to lack of huge pages), linux would returned MAP_FAILED (OK) but
also cancel the previous PROT_NONE mapping, hence making the virtual
memory space available for further mmaps. (code Point A)
Before this patch, the code simply re-reserved (PROT_NONE) the area
(point B):
This was NOT OK: yes, _ishm_reserve calls are mutexed, so no other
odpthread 2 could do a reserve between point A and B of opdthread1, but if
thread2 did its own mmap(), malloc(),..., there was a chance for thread 2
to get virtual space from the preserved area (which should be blocked).
This patch does not allow any A-B window by first doing an mmap (non fixed)
and then performing a second mapping at the correct address (in the
pre-reserved area), which is guaranteed to succeed, and finally removing
the non-fixed mapping.
The non-fix mapping just acts as a failure guard when the proper maping
is done.
Fixes https://bugs.linaro.org/show_bug.cgi?id=2834
(but very hard to trigger i.e. to prove)
Signed-off-by: Christophe Milard <christophe.milard(a)linaro.org>
Reviewed-and-tested-by: Bill Fischofer <bill.fischofer(a)linaro.org>
Signed-off-by: Maxim Uvarov <maxim.uvarov(a)linaro.org>
diff --git a/platform/linux-generic/_ishmphy.c b/platform/linux-generic/_ishmphy.c
index 2b2d100..d519af6 100644
--- a/platform/linux-generic/_ishmphy.c
+++ b/platform/linux-generic/_ishmphy.c
@@ -94,7 +94,7 @@ int _odp_ishmphy_unbook_va(void)
void *_odp_ishmphy_map(int fd, void *start, uint64_t size,
int flags)
{
- void *mapped_addr;
+ void *mapped_addr_tmp, *mapped_addr;
int mmap_flags = 0;
if (flags & _ODP_ISHM_SINGLE_VA) {
@@ -103,15 +103,37 @@ void *_odp_ishmphy_map(int fd, void *start, uint64_t size,
return NULL;
}
/* maps over fragment of reserved VA: */
- mapped_addr = mmap(start, size, PROT_READ | PROT_WRITE,
- MAP_SHARED | MAP_FIXED | mmap_flags, fd, 0);
- /* if mapping fails, re-block the space we tried to take
- * as it seems a mapping failure still affect what was there??*/
- if (mapped_addr == MAP_FAILED) {
- mmap_flags = MAP_SHARED | MAP_FIXED |
- MAP_ANONYMOUS | MAP_NORESERVE;
- mmap(start, size, PROT_NONE, mmap_flags, -1, 0);
- mprotect(start, size, PROT_NONE);
+ /* first, try a normal map. If that works, remap it where it
+ * should (on the prereverved space), and remove the initial
+ * normal mapping:
+ * This is because it turned out that if a mapping fails
+ * on a the prereserved virtual address space, then
+ * the prereserved address space which was tried to be mapped
+ * on becomes available to the kernel again! This was not
+ * according to expectations: the assumption was that if a
+ * mapping fails, the system should remain unchanged, but this
+ * is obvioulsy not true (at least for huge pages when
+ * exhausted).
+ * So the strategy is to first map at a non reserved place
+ * (which can then be freed and returned to the kernel on
+ * failure) and peform a new map to the prereserved space on
+ * success (which is then guaranteed to work).
+ * The initial free maping can then be removed.
+ */
+ mapped_addr = MAP_FAILED;
+ mapped_addr_tmp = mmap(NULL, size, PROT_READ | PROT_WRITE,
+ MAP_SHARED | mmap_flags, fd, 0);
+ if (mapped_addr_tmp != MAP_FAILED) {
+ /* If OK, do new map at right fixed location... */
+ mapped_addr = mmap(start,
+ size, PROT_READ | PROT_WRITE,
+ MAP_SHARED | MAP_FIXED | mmap_flags,
+ fd, 0);
+ if (mapped_addr != start)
+ ODP_ERR("new map failed:%s\n", strerror(errno));
+ /* ... and remove initial mapping: */
+ if (munmap(mapped_addr_tmp, size))
+ ODP_ERR("munmap failed:%s\n", strerror(errno));
}
} else {
/* just do a new mapping in the VA space: */
-----------------------------------------------------------------------
Summary of changes:
platform/linux-generic/_ishmphy.c | 42 +++++++++++++++++++++++++++++----------
1 file changed, 32 insertions(+), 10 deletions(-)
hooks/post-receive
--
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "".
The branch, master has been updated
via bbabb79cfaf5e28ec9e804b95a23605038b39d39 (commit)
from c14ec3dc896e0dd14d0491f09f81ce09e9d53bc2 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit bbabb79cfaf5e28ec9e804b95a23605038b39d39
Author: Christophe Milard <christophe.milard(a)linaro.org>
Date: Mon Jan 23 09:25:23 2017 +0100
linux-gen: _ishm: checking fstat return value.
Hence fixing CID 174663
(Fixes https://bugs.linaro.org/show_bug.cgi?id=2827)
Signed-off-by: Christophe Milard <christophe.milard(a)linaro.org>
Reviewed-by: Bill Fischofer <bill.fischofer(a)linaro.org>
Signed-off-by: Maxim Uvarov <maxim.uvarov(a)linaro.org>
diff --git a/platform/linux-generic/_ishm.c b/platform/linux-generic/_ishm.c
index 3797f20..c1efd7d 100644
--- a/platform/linux-generic/_ishm.c
+++ b/platform/linux-generic/_ishm.c
@@ -818,7 +818,14 @@ int _odp_ishm_reserve(const char *name, uint64_t size, int fd,
/* If a file descriptor is provided, get the real size and map: */
if (fd >= 0) {
- fstat(fd, &statbuf);
+ if (fstat(fd, &statbuf) < 0) {
+ close(fd);
+ odp_spinlock_unlock(&ishm_tbl->lock);
+ ODP_ERR("_ishm_reserve failed (fstat failed: %s).\n",
+ strerror(errno));
+ __odp_errno = errno;
+ return -1;
+ }
len = statbuf.st_size;
/* note that the huge page flag is meningless here as huge
* page is determined by the provided file descriptor: */
-----------------------------------------------------------------------
Summary of changes:
platform/linux-generic/_ishm.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
hooks/post-receive
--
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "".
The branch, master has been updated
via c14ec3dc896e0dd14d0491f09f81ce09e9d53bc2 (commit)
from 50ebc616ddd9d05651923134d7bfaa02c103fbce (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit c14ec3dc896e0dd14d0491f09f81ce09e9d53bc2
Author: Christophe Milard <christophe.milard(a)linaro.org>
Date: Mon Jan 23 09:47:57 2017 +0100
linux-gen: _ishm: fix normal page fallback
Fixing failure due to lack of huge pages.
Fixes: https://bugs.linaro.org/show_bug.cgi?id=2842
Signed-off-by: Christophe Milard <christophe.milard(a)linaro.org>
Reviewed-and-tested-by: Bill Fischofer <bill.fischofer(a)linaro.org>
Signed-off-by: Maxim Uvarov <maxim.uvarov(a)linaro.org>
diff --git a/platform/linux-generic/_ishm.c b/platform/linux-generic/_ishm.c
index f889834..3797f20 100644
--- a/platform/linux-generic/_ishm.c
+++ b/platform/linux-generic/_ishm.c
@@ -547,7 +547,7 @@ static void *do_map(int block_index, uint64_t len, uint32_t align,
addr = alloc_fragment(len, block_index, align, &fragment);
if (!addr) {
ODP_ERR("alloc_fragment failed.\n");
- if (new_block->filename[0]) {
+ if (!new_block->external_fd) {
close(*fd);
*fd = -1;
delete_file(new_block);
@@ -562,7 +562,7 @@ static void *do_map(int block_index, uint64_t len, uint32_t align,
if (mapped_addr == NULL) {
if (flags & _ODP_ISHM_SINGLE_VA)
free_fragment(fragment);
- if (new_block->filename[0]) {
+ if (!new_block->external_fd) {
close(*fd);
*fd = -1;
delete_file(new_block);
-----------------------------------------------------------------------
Summary of changes:
platform/linux-generic/_ishm.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
hooks/post-receive
--
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "".
The branch, master has been updated
via 50ebc616ddd9d05651923134d7bfaa02c103fbce (commit)
via 1ff6b7a7e44e7d7376920f1e1ee81dbf28f95563 (commit)
from c15da68b8dc3187c1929ff7d7705a0958856cbad (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 50ebc616ddd9d05651923134d7bfaa02c103fbce
Author: Matias Elo <matias.elo(a)nokia.com>
Date: Mon Jan 9 12:56:14 2017 +0200
linux-gen: netmap: bump supported netmap version to 11.2
Signed-off-by: Matias Elo <matias.elo(a)nokia.com>
Signed-off-by: Maxim Uvarov <maxim.uvarov(a)linaro.org>
diff --git a/DEPENDENCIES b/DEPENDENCIES
index f1f0edd..574859c 100644
--- a/DEPENDENCIES
+++ b/DEPENDENCIES
@@ -83,13 +83,13 @@ Prerequisites for building the OpenDataPlane (ODP) API
3.3.1 Building netmap kernel modules
ODP works at least with the latest release version of netmap, which is
- currently 11.1. However, if possible one should try to use the latest netmap
+ currently 11.2. However, if possible one should try to use the latest netmap
master branch commit for the best performance and the latest bug fixes.
# Checkout netmap code
$ git clone https://github.com/luigirizzo/netmap.git
$ cd netmap
- $ git checkout v11.1 (optional)
+ $ git checkout v11.2 (optional)
This is enough to build ODP. If you don't want to build netmap kernel
modules you can jump to section 3.3.2.
commit 1ff6b7a7e44e7d7376920f1e1ee81dbf28f95563
Author: Matias Elo <matias.elo(a)nokia.com>
Date: Mon Jan 9 12:56:13 2017 +0200
linux-gen: netmap: fix interface flags initialization
Previously netmap interface flags parsed by nm_open() were always
overwritten by netmap_start() function. In netmap v11.2 release this breaks
pipe interface initialization. Fix this by setting the netmap flags only
when needed.
Signed-off-by: Matias Elo <matias.elo(a)nokia.com>
Signed-off-by: Maxim Uvarov <maxim.uvarov(a)linaro.org>
diff --git a/platform/linux-generic/pktio/netmap.c b/platform/linux-generic/pktio/netmap.c
index 8eb8145..208984b 100644
--- a/platform/linux-generic/pktio/netmap.c
+++ b/platform/linux-generic/pktio/netmap.c
@@ -452,7 +452,7 @@ static int netmap_start(pktio_entry_t *pktio_entry)
{
pkt_netmap_t *pkt_nm = &pktio_entry->s.pkt_nm;
netmap_ring_t *desc_ring;
- struct nm_desc base_desc;
+ struct nm_desc *desc_ptr;
unsigned i;
unsigned j;
unsigned num_rx_desc = 0;
@@ -503,18 +503,27 @@ static int netmap_start(pktio_entry_t *pktio_entry)
pktio_entry->s.num_out_queue,
pktio_entry->s.num_out_queue);
- memset(&base_desc, 0, sizeof(struct nm_desc));
- base_desc.self = &base_desc;
- base_desc.mem = NULL;
- memcpy(base_desc.req.nr_name, pkt_nm->if_name, sizeof(pkt_nm->if_name));
- base_desc.req.nr_flags &= ~NR_REG_MASK;
+ /* Use nm_open() to parse netmap flags from interface name */
+ desc_ptr = nm_open(pkt_nm->nm_name, NULL, 0, NULL);
+ if (desc_ptr == NULL) {
+ ODP_ERR("nm_start(%s) failed\n", pkt_nm->nm_name);
+ goto error;
+ }
+ struct nm_desc base_desc = *desc_ptr;
- if (num_rx_desc == 1)
- base_desc.req.nr_flags |= NR_REG_ALL_NIC;
- else
- base_desc.req.nr_flags |= NR_REG_ONE_NIC;
+ nm_close(desc_ptr);
+ base_desc.self = &base_desc;
+ base_desc.mem = NULL;
base_desc.req.nr_ringid = 0;
+ if ((base_desc.req.nr_flags & NR_REG_MASK) == NR_REG_ALL_NIC ||
+ (base_desc.req.nr_flags & NR_REG_MASK) == NR_REG_ONE_NIC) {
+ base_desc.req.nr_flags &= ~NR_REG_MASK;
+ if (num_rx_desc == 1)
+ base_desc.req.nr_flags |= NR_REG_ALL_NIC;
+ else
+ base_desc.req.nr_flags |= NR_REG_ONE_NIC;
+ }
/* Only the first rx descriptor does mmap */
desc_ring = pkt_nm->rx_desc_ring;
@@ -548,8 +557,12 @@ static int netmap_start(pktio_entry_t *pktio_entry)
/* Open tx descriptors */
desc_ring = pkt_nm->tx_desc_ring;
flags = NM_OPEN_IFNAME | NM_OPEN_NO_MMAP;
- base_desc.req.nr_flags &= ~NR_REG_ALL_NIC;
- base_desc.req.nr_flags |= NR_REG_ONE_NIC;
+
+ if ((base_desc.req.nr_flags & NR_REG_MASK) == NR_REG_ALL_NIC) {
+ base_desc.req.nr_flags &= ~NR_REG_ALL_NIC;
+ base_desc.req.nr_flags |= NR_REG_ONE_NIC;
+ }
+
for (i = 0; i < pktio_entry->s.num_out_queue; i++) {
for (j = desc_ring[i].s.first; j <= desc_ring[i].s.last; j++) {
base_desc.req.nr_ringid = j;
-----------------------------------------------------------------------
Summary of changes:
DEPENDENCIES | 4 ++--
platform/linux-generic/pktio/netmap.c | 37 +++++++++++++++++++++++------------
2 files changed, 27 insertions(+), 14 deletions(-)
hooks/post-receive
--