aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config/odp-linux-generic.conf5
-rw-r--r--platform/linux-generic/odp_ishm.c30
2 files changed, 23 insertions, 12 deletions
diff --git a/config/odp-linux-generic.conf b/config/odp-linux-generic.conf
index 9969860d5..8a1eddbd9 100644
--- a/config/odp-linux-generic.conf
+++ b/config/odp-linux-generic.conf
@@ -34,6 +34,11 @@ shm: {
# because the current implementation won't work properly otherwise.
num_cached_hp = 0
+ # Huge page usage limit in kilobytes. Memory reservations larger than
+ # this value are done using huge pages (if available). Smaller
+ # reservations are done using normal pages to conserve memory.
+ huge_page_limit_kb = 64
+
# Allocate internal shared memory using a single virtual address space.
# Set to 1 to enable using process mode.
single_va = 0
diff --git a/platform/linux-generic/odp_ishm.c b/platform/linux-generic/odp_ishm.c
index a66d9fab2..d02e5ee90 100644
--- a/platform/linux-generic/odp_ishm.c
+++ b/platform/linux-generic/odp_ishm.c
@@ -114,13 +114,6 @@
#define ISHM_NB_FRAGMNTS (ISHM_MAX_NB_BLOCKS * 2 + 1)
/*
- * Memory reservations larger than ISHM_HUGE_PAGE_LIMIT (bytes) are allocated
- * using huge pages (if available). Smaller reservations are done using normal
- * pages to conserve memory.
- */
-#define ISHM_HUGE_PAGE_LIMIT (64 * 1024)
-
-/*
* when a memory block is to be exported outside its ODP instance,
* an block 'attribute file' is created in /dev/shm/odp-<pid>-shm-<name>.
* The information given in this file is according to the following:
@@ -190,6 +183,8 @@ typedef struct ishm_block {
typedef struct {
odp_spinlock_t lock;
uint64_t dev_seq; /* used when creating device names */
+ /* limit for reserving memory using huge pages */
+ uint64_t huge_page_limit;
uint32_t odpthread_cnt; /* number of running ODP threads */
ishm_block_t block[ISHM_MAX_NB_BLOCKS];
void *single_va_start; /* start of single VA memory */
@@ -1108,7 +1103,7 @@ int _odp_ishm_reserve(const char *name, uint64_t size, int fd,
/* Otherwise, Try first huge pages when possible and needed: */
if ((fd < 0) && page_hp_size && ((flags & _ODP_ISHM_USE_HP) ||
- size > ISHM_HUGE_PAGE_LIMIT)) {
+ size > ishm_tbl->huge_page_limit)) {
/* at least, alignment in VA should match page size, but user
* can request more: If the user requirement exceeds the page
* size then we have to make sure the block will be mapped at
@@ -1643,23 +1638,33 @@ int _odp_ishm_init_global(const odp_init_t *init)
void *addr;
void *spce_addr = NULL;
int i;
- int single_va_size_kb = 0;
+ int val_kb;
uid_t uid;
char *hp_dir = odp_global_ro.hugepage_info.default_huge_page_dir;
uint64_t max_memory;
uint64_t internal;
+ uint64_t huge_page_limit;
if (!_odp_libconfig_lookup_ext_int("shm", NULL, "single_va_size_kb",
- &single_va_size_kb)) {
+ &val_kb)) {
ODP_ERR("Unable to read single VA size from config\n");
return -1;
}
- ODP_DBG("Shm single VA size: %dkB\n", single_va_size_kb);
+ ODP_DBG("Shm single VA size: %dkB\n", val_kb);
- max_memory = single_va_size_kb * 1024;
+ max_memory = val_kb * 1024;
internal = max_memory / 8;
+ if (!_odp_libconfig_lookup_ext_int("shm", NULL, "huge_page_limit_kb",
+ &val_kb)) {
+ ODP_ERR("Unable to read huge page usage limit from config\n");
+ return -1;
+ }
+ huge_page_limit = (uint64_t)val_kb * 1024;
+
+ ODP_DBG("Shm huge page usage limit: %dkB\n", val_kb);
+
/* user requested memory size + some extra for internal use */
if (init && init->shm.max_memory)
max_memory = init->shm.max_memory + internal;
@@ -1710,6 +1715,7 @@ int _odp_ishm_init_global(const odp_init_t *init)
memset(ishm_tbl, 0, sizeof(ishm_table_t));
ishm_tbl->dev_seq = 0;
ishm_tbl->odpthread_cnt = 0;
+ ishm_tbl->huge_page_limit = huge_page_limit;
odp_spinlock_init(&ishm_tbl->lock);
/* allocate space for the internal shared mem fragment table: */