session: improve fifo segment allocation

This patch ensures that fifo segment has at least the size that was
requested during allocation.

Type: improvement

Signed-off-by: Filip Tehlar <ftehlar@cisco.com>
Change-Id: Iea8a885ac290183e25e5c8f9163bba226c5efa15
This commit is contained in:
Filip Tehlar
2021-11-24 10:30:59 +00:00
parent 32c7335ea9
commit 2711ca710a
3 changed files with 9 additions and 1 deletions

View File

@ -295,7 +295,7 @@ fss_fl_chunk_bytes_sub (fifo_segment_slice_t * fss, uword size)
int int
fifo_segment_init (fifo_segment_t * fs) 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; uword max_fifo, seg_start, seg_sz;
fifo_segment_header_t *fsh; fifo_segment_header_t *fsh;
ssvm_shared_header_t *sh; ssvm_shared_header_t *sh;

View File

@ -20,6 +20,8 @@
#include <svm/message_queue.h> #include <svm/message_queue.h>
#include <svm/svm_fifo.h> #include <svm/svm_fifo.h>
#define FIFO_SEGMENT_ALLOC_OVERHEAD (2 * clib_mem_get_page_size ())
typedef enum typedef enum
{ {
FIFO_SEGMENT_FTYPE_NONE = -1, FIFO_SEGMENT_FTYPE_NONE = -1,

View File

@ -119,6 +119,12 @@ segment_manager_add_segment_inline (segment_manager_t *sm, uword segment_size,
* Allocate ssvm segment * Allocate ssvm segment
*/ */
segment_size = segment_size ? segment_size : props->add_segment_size; 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 ()); segment_size = round_pow2 (segment_size, clib_mem_get_page_size ());
if (props->segment_type != SSVM_SEGMENT_PRIVATE) if (props->segment_type != SSVM_SEGMENT_PRIVATE)