aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/svm/fifo_segment.c2
-rw-r--r--src/svm/fifo_segment.h2
-rw-r--r--src/vnet/session/segment_manager.c6
3 files changed, 9 insertions, 1 deletions
diff --git a/src/svm/fifo_segment.c b/src/svm/fifo_segment.c
index 2ff272e2f88..48d019c9aac 100644
--- a/src/svm/fifo_segment.c
+++ b/src/svm/fifo_segment.c
@@ -295,7 +295,7 @@ fss_fl_chunk_bytes_sub (fifo_segment_slice_t * fss, uword size)
int
fifo_segment_init (fifo_segment_t * fs)
{
- u32 align = 8, offset = 2 * 4096, slices_sz, i;
+ u32 align = 8, offset = FIFO_SEGMENT_ALLOC_OVERHEAD, slices_sz, i;
uword max_fifo, seg_start, seg_sz;
fifo_segment_header_t *fsh;
ssvm_shared_header_t *sh;
diff --git a/src/svm/fifo_segment.h b/src/svm/fifo_segment.h
index de4622f6a2a..440f1bb6a02 100644
--- a/src/svm/fifo_segment.h
+++ b/src/svm/fifo_segment.h
@@ -20,6 +20,8 @@
#include <svm/message_queue.h>
#include <svm/svm_fifo.h>
+#define FIFO_SEGMENT_ALLOC_OVERHEAD (2 * clib_mem_get_page_size ())
+
typedef enum
{
FIFO_SEGMENT_FTYPE_NONE = -1,
diff --git a/src/vnet/session/segment_manager.c b/src/vnet/session/segment_manager.c
index e04f626eab2..a55f7d3472c 100644
--- a/src/vnet/session/segment_manager.c
+++ b/src/vnet/session/segment_manager.c
@@ -119,6 +119,12 @@ segment_manager_add_segment_inline (segment_manager_t *sm, uword segment_size,
* Allocate ssvm segment
*/
segment_size = segment_size ? segment_size : props->add_segment_size;
+ /* add overhead to ensure the result segment size is at least
+ * of that requested */
+ segment_size +=
+ sizeof (fifo_segment_header_t) +
+ vlib_thread_main.n_vlib_mains * sizeof (fifo_segment_slice_t) +
+ FIFO_SEGMENT_ALLOC_OVERHEAD;
segment_size = round_pow2 (segment_size, clib_mem_get_page_size ());
if (props->segment_type != SSVM_SEGMENT_PRIVATE)