summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/svm/ssvm.c5
-rw-r--r--src/vnet/session/segment_manager.c4
2 files changed, 6 insertions, 3 deletions
diff --git a/src/svm/ssvm.c b/src/svm/ssvm.c
index dfb68c039ad..c005b61144b 100644
--- a/src/svm/ssvm.c
+++ b/src/svm/ssvm.c
@@ -331,10 +331,11 @@ ssvm_master_init_private (ssvm_private_t * ssvm)
u32 pagesize = clib_mem_get_page_size ();
ssvm_shared_header_t *sh;
mheap_t *heap_header;
- u32 rnd_size = 0;
+ u64 rnd_size = 0;
u8 *heap;
- rnd_size = (ssvm->ssvm_size + (pagesize - 1)) & ~pagesize;
+ rnd_size = (ssvm->ssvm_size + (pagesize - 1)) & ~(pagesize - 1);
+ rnd_size = clib_min (rnd_size, ((u64) 1 << 32) - pagesize);
heap = mheap_alloc (0, rnd_size);
if (heap == 0)
{
diff --git a/src/vnet/session/segment_manager.c b/src/vnet/session/segment_manager.c
index 9dade6ec0d6..31bb0c3aab5 100644
--- a/src/vnet/session/segment_manager.c
+++ b/src/vnet/session/segment_manager.c
@@ -153,7 +153,7 @@ int
segment_manager_add_segment (segment_manager_t * sm, u32 segment_size)
{
segment_manager_main_t *smm = &segment_manager_main;
- u32 rnd_margin = 128 << 10, seg_index;
+ u32 rnd_margin = 128 << 10, seg_index, page_size;
segment_manager_properties_t *props;
uword baseva = (u64) ~ 0, alloc_size;
svm_fifo_segment_private_t *seg;
@@ -187,6 +187,8 @@ segment_manager_add_segment (segment_manager_t * sm, u32 segment_size)
* Initialize ssvm segment and svm fifo private header
*/
segment_size = segment_size ? segment_size : props->add_segment_size;
+ page_size = clib_mem_get_page_size ();
+ segment_size = (segment_size + page_size - 1) & ~(page_size - 1);
if (props->segment_type != SSVM_SEGMENT_PRIVATE)
{
seg_name = format (0, "%d-%d%c", getpid (), segment_name_counter++, 0);