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, monarch_lts has been updated
via b06b87af01c29544a46b7e25b20d099d4850148c (commit)
from 0e9e5654cf04c6f92a3539fec06f6cf51a86168d (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 b06b87af01c29544a46b7e25b20d099d4850148c
Author: Juha-Matti Tilli <juha-matti.tilli(a)iki.fi>
Date: Thu Sep 13 20:13:47 2018 +0300
linux-gen: netmap: remove minimum frame len check
Checking the minimum frame length is unnecessary as netmap drops truncated
frames internally.
Signed-off-by: Matias Elo <matias.elo(a)nokia.com>
Signed-off-by: Bill Fischofer <bill.fischofer(a)linaro.org>
Signed-off-by: Juha-Matti Tilli <juha-matti.tilli(a)iki.fi>
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 3017e403..45b193d1 100644
--- a/platform/linux-generic/pktio/netmap.c
+++ b/platform/linux-generic/pktio/netmap.c
@@ -606,11 +606,6 @@ static inline int netmap_pkt_to_odp(pktio_entry_t *pktio_entry,
return -1;
}
- if (odp_unlikely(len < _ODP_ETH_LEN_MIN)) {
- ODP_ERR("RX: Frame truncated: %" PRIu16 "\n", len);
- return -1;
- }
-
if (pktio_cls_enabled(pktio_entry)) {
if (cls_classify_packet(pktio_entry, (const uint8_t *)buf, len,
len, &pool, &parsed_hdr))
-----------------------------------------------------------------------
Summary of changes:
platform/linux-generic/pktio/netmap.c | 5 -----
1 file changed, 5 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 b44cbbbfc148261843b041fbb5b4ea8f8879f44e (commit)
from 461a16705242b1fd7e64b50fcaae57fce7cd7f79 (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 b44cbbbfc148261843b041fbb5b4ea8f8879f44e
Author: Maxim Uvarov <maxim.uvarov(a)linaro.org>
Date: Tue Sep 11 16:35:27 2018 +0300
helper: iplookuptable fix puting values to table
On putting values to table we have to validate input data
and reject unaccepted data (cidr bits - Classless Inter-Domain
Routing is in range of 0 to 32).
Signed-off-by: Maxim Uvarov <maxim.uvarov(a)linaro.org>
Reviewed-by: Bill Fischofer <bill.fischofer(a)linaro.org>
diff --git a/helper/iplookuptable.c b/helper/iplookuptable.c
index 61f63402..7102eb54 100644
--- a/helper/iplookuptable.c
+++ b/helper/iplookuptable.c
@@ -585,24 +585,25 @@ prefix_insert_into_lx(
odph_iplookup_table_impl *tbl, prefix_entry_t *entry,
uint8_t cidr, odp_buffer_t nexthop, uint8_t level)
{
- uint8_t ret = 0;
+ int ret = 0;
uint32_t i = 0, limit = (1 << (level - cidr));
prefix_entry_t *e = entry, *ne = NULL;
for (i = 0; i < limit; i++, e++) {
- if (e->child == 1) {
- if (e->cidr > cidr)
- continue;
+ if (e->cidr > cidr)
+ continue;
+ if (e->child == 1) {
e->cidr = cidr;
/* push to next level */
ne = (prefix_entry_t *)e->ptr;
ret = prefix_insert_into_lx(
tbl, ne, cidr, nexthop, cidr + 8);
+ if (ret == -1)
+ return -1;
+ if (ret == 0)
+ return ret;
} else {
- if (e->cidr > cidr)
- continue;
-
e->child = 0;
e->cidr = cidr;
e->nexthop = nexthop;
@@ -678,8 +679,9 @@ odph_iplookup_table_put_value(odph_table_t tbl, void *key, void *value)
nexthop = *((odp_buffer_t *)value);
- if (prefix->cidr == 0)
+ if (prefix->cidr == 0 || prefix->cidr > 32)
return -1;
+
prefix->ip = prefix->ip & (0xffffffff << (IP_LENGTH - prefix->cidr));
/* insert into trie */
@@ -899,7 +901,7 @@ odph_iplookup_table_remove_value(odph_table_t tbl, void *key)
ip = prefix->ip;
cidr = prefix->cidr;
- if (cidr == 0)
+ if (cidr == 0 || cidr > 32)
return -EINVAL;
prefix_entry_t *entry = &impl->l1e[ip >> 16];
-----------------------------------------------------------------------
Summary of changes:
helper/iplookuptable.c | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 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 c5789c8633254aca7e1d978d1e1f0ad7077e7e2c (commit)
via c46f54d8c708d6335b0288ff4a5aad3a3b93e41c (commit)
from 0b9a1a2e8334581126d4ece3fb4f9e019d88da0d (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 c5789c8633254aca7e1d978d1e1f0ad7077e7e2c
Author: Josep Puigdemont <josep.puigdemont(a)linaro.org>
Date: Thu Sep 6 13:06:09 2018 +0200
linux-gen: ishm: make huge page cache size dynamic
Signed-off-by: Josep Puigdemont <josep.puigdemont(a)linaro.org>
Reviewed-and-tested-by: Matias Elo <matias.elo(a)nokia.com>
Signed-off-by: Maxim Uvarov <maxim.uvarov(a)linaro.org>
diff --git a/config/odp-linux-generic.conf b/config/odp-linux-generic.conf
index 0dd2a6c1..bddc92dd 100644
--- a/config/odp-linux-generic.conf
+++ b/config/odp-linux-generic.conf
@@ -18,14 +18,20 @@
odp_implementation = "linux-generic"
config_file_version = "0.0.1"
-# Internal shared memory allocator
+# Shared memory options
shm: {
- # ODP will try to reserve as many huge pages as the number indicated
- # here, up to 64. A zero value means that no pages should be reserved.
+ # Number of cached default size huge pages. These pages are allocated
+ # during odp_init_global() and freed back to the kernel in
+ # odp_term_global(). A value of zero means no pages are cached.
+ # No negative values should be used here, they are reserved for future
+ # implementations.
+ #
+ # ODP will reserve as many huge pages as possible, which may be less
+ # than requested here if the system does not have enough huge pages
+ # available.
+ #
# When using process mode threads, this value should be set to 0
# because the current implementation won't work properly otherwise.
- # These pages will only be freed when the application calls
- # odp_term_global().
num_cached_hp = 0
}
diff --git a/platform/linux-generic/odp_ishm.c b/platform/linux-generic/odp_ishm.c
index 4879b7b2..80423ace 100644
--- a/platform/linux-generic/odp_ishm.c
+++ b/platform/linux-generic/odp_ishm.c
@@ -239,15 +239,15 @@ typedef struct {
} ishm_ftable_t;
static ishm_ftable_t *ishm_ftbl;
-#define HP_CACHE_SIZE 64
struct huge_page_cache {
uint64_t len;
+ int max_fds; /* maximum amount requested of pre-allocated huge pages */
int total; /* amount of actually pre-allocated huge pages */
int idx; /* retrieve fd[idx] to get a free file descriptor */
- int fd[HP_CACHE_SIZE]; /* list of file descriptors */
+ int fd[]; /* list of file descriptors */
};
-static struct huge_page_cache hpc;
+static struct huge_page_cache *hpc;
#ifndef MAP_ANONYMOUS
#define MAP_ANONYMOUS MAP_ANON
@@ -301,19 +301,14 @@ static void hp_init(void)
char filename[ISHM_FILENAME_MAXLEN];
char dir[ISHM_FILENAME_MAXLEN];
int count;
-
- hpc.total = 0;
- hpc.idx = -1;
- hpc.len = odp_sys_huge_page_size();
+ void *addr;
if (!_odp_libconfig_lookup_ext_int("shm", NULL, "num_cached_hp",
&count)) {
return;
}
- if (count > HP_CACHE_SIZE)
- count = HP_CACHE_SIZE;
- else if (count <= 0)
+ if (count <= 0)
return;
ODP_DBG("Init HP cache with up to %d pages\n", count);
@@ -339,55 +334,77 @@ static void hp_init(void)
dir,
odp_global_data.main_pid);
+ addr = mmap(NULL,
+ sizeof(struct huge_page_cache) + sizeof(int) * count,
+ PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, -1, 0);
+ if (addr == MAP_FAILED) {
+ ODP_ERR("Unable to mmap memory for huge page cache\n.");
+ return;
+ }
+
+ hpc = addr;
+
+ hpc->max_fds = count;
+ hpc->total = 0;
+ hpc->idx = -1;
+ hpc->len = odp_sys_huge_page_size();
+
for (int i = 0; i < count; ++i) {
int fd;
- fd = hp_create_file(hpc.len, filename);
- if (fd == -1)
+ fd = hp_create_file(hpc->len, filename);
+ if (fd == -1) {
+ do {
+ hpc->fd[i++] = -1;
+ } while (i < count);
break;
- hpc.total++;
- hpc.fd[i] = fd;
+ }
+ hpc->total++;
+ hpc->fd[i] = fd;
}
- hpc.idx = hpc.total - 1;
+ hpc->idx = hpc->total - 1;
ODP_DBG("HP cache has %d huge pages of size 0x%08" PRIx64 "\n",
- hpc.total, hpc.len);
+ hpc->total, hpc->len);
}
static void hp_term(void)
{
- for (int i = 0; i < hpc.total; i++) {
- if (hpc.fd[i] != -1)
- close(hpc.fd[i]);
+ if (NULL == hpc)
+ return;
+
+ for (int i = 0; i < hpc->total; i++) {
+ if (hpc->fd[i] != -1)
+ close(hpc->fd[i]);
}
- hpc.total = 0;
- hpc.idx = -1;
- hpc.len = 0;
+ hpc->total = 0;
+ hpc->idx = -1;
+ hpc->len = 0;
}
static int hp_get_cached(uint64_t len)
{
int fd;
- if (hpc.idx < 0 || len != hpc.len)
+ if (NULL == hpc || hpc->idx < 0 || len != hpc->len)
return -1;
- fd = hpc.fd[hpc.idx];
- hpc.fd[hpc.idx--] = -1;
+ fd = hpc->fd[hpc->idx];
+ hpc->fd[hpc->idx--] = -1;
return fd;
}
static int hp_put_cached(int fd)
{
- if (odp_unlikely(++hpc.idx >= hpc.total)) {
- hpc.idx--;
+ if (NULL == hpc || odp_unlikely(++hpc->idx >= hpc->total)) {
+ hpc->idx--;
ODP_ERR("Trying to put more FD than allowed: %d\n", fd);
return -1;
}
- hpc.fd[hpc.idx] = fd;
+ hpc->fd[hpc->idx] = fd;
return 0;
}
commit c46f54d8c708d6335b0288ff4a5aad3a3b93e41c
Author: Josep Puigdemont <josep.puigdemont(a)linaro.org>
Date: Mon Aug 27 16:37:15 2018 +0200
linux-gen: ishm: implement huge page cache
With this patch, ODP will pre-allocate several huge pages at init
time. When memory is to be mapped into a huge page, one that was
pre-allocated will be used, if available, this way ODP won't have to
trap into the kernel to allocate huge pages.
The idea with this implementation is to trick ishm into thinking that
a file descriptor where to map the memory was provided, this way it
it won't try to allocate one itself. This file descriptor is one of
those previously allocated at init time. When the system is done with
this file descriptor, instead of closing it, it is put back into the
list of available huge pages, ready to be reused.
A collateral effect of this patch is that memory is not zeroed out
when it is reused.
WARNING: This patch will not work when using process mode threads.
For several reasons, this may not work when using ODP_ISHM_SINGLE_VA
either, so when this flag is set, the list of pre-allocated files is
not used.
By default ODP will not reserve any huge pages, to tell ODP to do that,
update the ODP configuration file with something like this:
shm: {
num_cached_hp = 32
}
Example usage:
$ echo odp.config
odp_implementation = "linux-generic"
config_file_version = "0.0.1"
shm: {
num_cached_hp = 32
}
$ ODP_CONFIG_FILE=odp.conf ./test/validation/api/shmem/shmem_main
This patch solves bug #3774:
https://bugs.linaro.org/show_bug.cgi?id=3774
Signed-off-by: Josep Puigdemont <josep.puigdemont(a)linaro.org>
Reviewed-and-tested-by: Matias Elo <matias.elo(a)nokia.com>
Signed-off-by: Maxim Uvarov <maxim.uvarov(a)linaro.org>
diff --git a/config/odp-linux-generic.conf b/config/odp-linux-generic.conf
index 85d5414b..0dd2a6c1 100644
--- a/config/odp-linux-generic.conf
+++ b/config/odp-linux-generic.conf
@@ -18,6 +18,17 @@
odp_implementation = "linux-generic"
config_file_version = "0.0.1"
+# Internal shared memory allocator
+shm: {
+ # ODP will try to reserve as many huge pages as the number indicated
+ # here, up to 64. A zero value means that no pages should be reserved.
+ # When using process mode threads, this value should be set to 0
+ # because the current implementation won't work properly otherwise.
+ # These pages will only be freed when the application calls
+ # odp_term_global().
+ num_cached_hp = 0
+}
+
# DPDK pktio options
pktio_dpdk: {
# Default options
diff --git a/platform/linux-generic/odp_ishm.c b/platform/linux-generic/odp_ishm.c
index f0d8ef64..4879b7b2 100644
--- a/platform/linux-generic/odp_ishm.c
+++ b/platform/linux-generic/odp_ishm.c
@@ -63,6 +63,7 @@
#include <odp_ishm_internal.h>
#include <odp_ishmphy_internal.h>
#include <odp_ishmpool_internal.h>
+#include <odp_libconfig_internal.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
@@ -164,7 +165,7 @@ typedef struct ishm_fragment {
* will allocate both a block and a fragment.
* Blocks contain only global data common to all processes.
*/
-typedef enum {UNKNOWN, HUGE, NORMAL, EXTERNAL} huge_flag_t;
+typedef enum {UNKNOWN, HUGE, NORMAL, EXTERNAL, CACHED} huge_flag_t;
typedef struct ishm_block {
char name[ISHM_NAME_MAXLEN]; /* name for the ishm block (if any) */
char filename[ISHM_FILENAME_MAXLEN]; /* name of the .../odp-* file */
@@ -238,6 +239,16 @@ typedef struct {
} ishm_ftable_t;
static ishm_ftable_t *ishm_ftbl;
+#define HP_CACHE_SIZE 64
+struct huge_page_cache {
+ uint64_t len;
+ int total; /* amount of actually pre-allocated huge pages */
+ int idx; /* retrieve fd[idx] to get a free file descriptor */
+ int fd[HP_CACHE_SIZE]; /* list of file descriptors */
+};
+
+static struct huge_page_cache hpc;
+
#ifndef MAP_ANONYMOUS
#define MAP_ANONYMOUS MAP_ANON
#endif
@@ -245,6 +256,142 @@ static ishm_ftable_t *ishm_ftbl;
/* prototypes: */
static void procsync(void);
+static int hp_create_file(uint64_t len, const char *filename)
+{
+ int fd;
+ void *addr;
+
+ if (len <= 0) {
+ ODP_ERR("Length is wrong\n");
+ return -1;
+ }
+
+ fd = open(filename, O_RDWR | O_CREAT | O_TRUNC,
+ S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+ if (fd < 0) {
+ ODP_ERR("Could not create cache file %s\n", filename);
+ return -1;
+ }
+
+ /* remove file from file system */
+ unlink(filename);
+
+ if (ftruncate(fd, len) == -1) {
+ ODP_ERR("Could not truncate file: %s\n", strerror(errno));
+ close(fd);
+ return -1;
+ }
+
+ /* commit huge page */
+ addr = _odp_ishmphy_map(fd, NULL, len, 0);
+ if (addr == NULL) {
+ /* no more pages available */
+ close(fd);
+ return -1;
+ }
+ _odp_ishmphy_unmap(addr, len, 0);
+
+ ODP_DBG("Created HP cache file %s, fd: %d\n", filename, fd);
+
+ return fd;
+}
+
+static void hp_init(void)
+{
+ char filename[ISHM_FILENAME_MAXLEN];
+ char dir[ISHM_FILENAME_MAXLEN];
+ int count;
+
+ hpc.total = 0;
+ hpc.idx = -1;
+ hpc.len = odp_sys_huge_page_size();
+
+ if (!_odp_libconfig_lookup_ext_int("shm", NULL, "num_cached_hp",
+ &count)) {
+ return;
+ }
+
+ if (count > HP_CACHE_SIZE)
+ count = HP_CACHE_SIZE;
+ else if (count <= 0)
+ return;
+
+ ODP_DBG("Init HP cache with up to %d pages\n", count);
+
+ if (!odp_global_data.hugepage_info.default_huge_page_dir) {
+ ODP_ERR("No huge page dir\n");
+ return;
+ }
+
+ snprintf(dir, ISHM_FILENAME_MAXLEN, "%s/%s",
+ odp_global_data.hugepage_info.default_huge_page_dir,
+ odp_global_data.uid);
+
+ if (mkdir(dir, 0744) != 0) {
+ if (errno != EEXIST) {
+ ODP_ERR("Failed to create dir: %s\n", strerror(errno));
+ return;
+ }
+ }
+
+ snprintf(filename, ISHM_FILENAME_MAXLEN,
+ "%s/odp-%d-ishm_cached",
+ dir,
+ odp_global_data.main_pid);
+
+ for (int i = 0; i < count; ++i) {
+ int fd;
+
+ fd = hp_create_file(hpc.len, filename);
+ if (fd == -1)
+ break;
+ hpc.total++;
+ hpc.fd[i] = fd;
+ }
+ hpc.idx = hpc.total - 1;
+
+ ODP_DBG("HP cache has %d huge pages of size 0x%08" PRIx64 "\n",
+ hpc.total, hpc.len);
+}
+
+static void hp_term(void)
+{
+ for (int i = 0; i < hpc.total; i++) {
+ if (hpc.fd[i] != -1)
+ close(hpc.fd[i]);
+ }
+
+ hpc.total = 0;
+ hpc.idx = -1;
+ hpc.len = 0;
+}
+
+static int hp_get_cached(uint64_t len)
+{
+ int fd;
+
+ if (hpc.idx < 0 || len != hpc.len)
+ return -1;
+
+ fd = hpc.fd[hpc.idx];
+ hpc.fd[hpc.idx--] = -1;
+
+ return fd;
+}
+
+static int hp_put_cached(int fd)
+{
+ if (odp_unlikely(++hpc.idx >= hpc.total)) {
+ hpc.idx--;
+ ODP_ERR("Trying to put more FD than allowed: %d\n", fd);
+ return -1;
+ }
+
+ hpc.fd[hpc.idx] = fd;
+
+ return 0;
+}
+
/*
* Take a piece of the preallocated virtual space to fit "size" bytes.
* (best fit). Size must be rounded up to an integer number of pages size.
@@ -798,8 +945,14 @@ static int block_free_internal(int block_index, int close_fd, int deregister)
block_index);
/* close the related fd */
- if (close_fd)
- close(ishm_proctable->entry[proc_index].fd);
+ if (close_fd) {
+ int fd = ishm_proctable->entry[proc_index].fd;
+
+ if (block->huge == CACHED)
+ hp_put_cached(fd);
+ else
+ close(fd);
+ }
/* remove entry from process local table: */
last = ishm_proctable->nb_entries - 1;
@@ -910,6 +1063,7 @@ int _odp_ishm_reserve(const char *name, uint64_t size, int fd,
new_block->huge = EXTERNAL;
} else {
new_block->external_fd = 0;
+ new_block->huge = UNKNOWN;
}
/* Otherwise, Try first huge pages when possible and needed: */
@@ -927,17 +1081,38 @@ int _odp_ishm_reserve(const char *name, uint64_t size, int fd,
/* roundup to page size */
len = (size + (page_hp_size - 1)) & (-page_hp_size);
- addr = do_map(new_index, len, hp_align, flags, HUGE, &fd);
-
- if (addr == NULL) {
- if (!huge_error_printed) {
- ODP_ERR("No huge pages, fall back to normal "
- "pages. "
- "check: /proc/sys/vm/nr_hugepages.\n");
- huge_error_printed = 1;
+ if (!(flags & _ODP_ISHM_SINGLE_VA)) {
+ /* try pre-allocated pages */
+ fd = hp_get_cached(len);
+ if (fd != -1) {
+ /* do as if user provided a fd */
+ new_block->external_fd = 1;
+ addr = do_map(new_index, len, hp_align, flags,
+ CACHED, &fd);
+ if (addr == NULL) {
+ ODP_ERR("Could not use cached hp %d\n",
+ fd);
+ hp_put_cached(fd);
+ fd = -1;
+ } else {
+ new_block->huge = CACHED;
+ }
+ }
+ }
+ if (fd == -1) {
+ addr = do_map(new_index, len, hp_align, flags, HUGE,
+ &fd);
+
+ if (addr == NULL) {
+ if (!huge_error_printed) {
+ ODP_ERR("No huge pages, fall back to "
+ "normal pages. Check: "
+ "/proc/sys/vm/nr_hugepages.\n");
+ huge_error_printed = 1;
+ }
+ } else {
+ new_block->huge = HUGE;
}
- } else {
- new_block->huge = HUGE;
}
}
@@ -961,8 +1136,12 @@ int _odp_ishm_reserve(const char *name, uint64_t size, int fd,
/* if neither huge pages or normal pages works, we cannot proceed: */
if ((fd < 0) || (addr == NULL) || (len == 0)) {
- if ((!new_block->external_fd) && (fd >= 0))
+ if (new_block->external_fd) {
+ if (new_block->huge == CACHED)
+ hp_put_cached(fd);
+ } else if (fd >= 0) {
close(fd);
+ }
delete_file(new_block);
odp_spinlock_unlock(&ishm_tbl->lock);
ODP_ERR("_ishm_reserve failed.\n");
@@ -1564,6 +1743,9 @@ int _odp_ishm_init_global(const odp_init_t *init)
/* get ready to create pools: */
_odp_ishm_pool_init();
+ /* init cache files */
+ hp_init();
+
return 0;
init_glob_err4:
@@ -1705,6 +1887,8 @@ int _odp_ishm_term_global(void)
if (!odp_global_data.shm_dir_from_env)
free(odp_global_data.shm_dir);
+ hp_term();
+
return ret;
}
@@ -1778,6 +1962,9 @@ int _odp_ishm_status(const char *title)
case EXTERNAL:
huge = 'E';
break;
+ case CACHED:
+ huge = 'C';
+ break;
default:
huge = '?';
}
@@ -1911,6 +2098,9 @@ void _odp_ishm_print(int block_index)
case EXTERNAL:
str = "external";
break;
+ case CACHED:
+ str = "cached";
+ break;
default:
str = "??";
}
-----------------------------------------------------------------------
Summary of changes:
config/odp-linux-generic.conf | 17 +++
platform/linux-generic/odp_ishm.c | 235 +++++++++++++++++++++++++++++++++++---
2 files changed, 238 insertions(+), 14 deletions(-)
hooks/post-receive
--