summaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2019-05-11 16:55:53 -0700
committerDave Barach <openvpp@barachs.net>2019-05-14 18:40:20 +0000
commitf9d4ab42724b260d5c242f7291d05f74cd725d7d (patch)
treee73966462c7c8ebc36cc2d7f0147ee1f81e4ba25 /src/vnet
parent0224514c28bdee05ea11a89a721c810e5f99ede2 (diff)
svm: improve fifo segment prealloc support
- track fifo segment free and chunk freelist memory - improve fifo alloc. If there are enough chunks to satisfy a fifo allocation request but not enough free memory, allocate a multi-chunk fifo - add apis to preallocate chunks and fifo headers - more tests Change-Id: If18dba7ab856272c9f565d36ac36365139793e0b Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/session/segment_manager.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/vnet/session/segment_manager.c b/src/vnet/session/segment_manager.c
index cbec493e55f..f53026c8778 100644
--- a/src/vnet/session/segment_manager.c
+++ b/src/vnet/session/segment_manager.c
@@ -102,7 +102,7 @@ segment_manager_add_segment (segment_manager_t * sm, u32 segment_size)
}
/*
- * Allocate fifo segment and lock if needed
+ * Allocate fifo segment and grab lock if needed
*/
if (vlib_num_workers ())
clib_rwlock_writer_lock (&sm->segments_rwlock);
@@ -110,13 +110,14 @@ segment_manager_add_segment (segment_manager_t * sm, u32 segment_size)
pool_get_zero (sm->segments, fs);
/*
- * Initialize ssvm segment and svm fifo private header
+ * Allocate ssvm segment
*/
segment_size = segment_size ? segment_size : props->add_segment_size;
page_size = clib_mem_get_page_size ();
/* Protect against segment size u32 wrap */
segment_size = clib_max (segment_size + page_size - 1, segment_size);
segment_size = segment_size & ~(page_size - 1);
+
if (props->segment_type != SSVM_SEGMENT_PRIVATE)
{
seg_name = format (0, "%d-%d%c", getpid (), smm->seg_name_counter++, 0);
@@ -147,6 +148,9 @@ segment_manager_add_segment (segment_manager_t * sm, u32 segment_size)
goto done;
}
+ /*
+ * Initialize fifo segment
+ */
fifo_segment_init (fs);
/*
@@ -761,6 +765,7 @@ segment_manager_alloc_queue (fifo_segment_t * segment,
oldheap = ssvm_push_heap (segment->ssvm.sh);
q = svm_msg_q_alloc (cfg);
+ fifo_segment_update_free_bytes (segment);
ssvm_pop_heap (oldheap);
if (props->use_mq_eventfd)
@@ -865,7 +870,7 @@ segment_manager_show_fn (vlib_main_t * vm, unformat_input_t * input,
segment_manager_foreach_segment_w_lock (seg, sm, ({
fifo_segment_info (seg, &address, &size);
active_fifos = fifo_segment_num_fifos (seg);
- free_fifos = fifo_segment_num_free_fifos (seg, ~0 /* size */);
+ free_fifos = fifo_segment_num_free_fifos (seg);
vlib_cli_output (vm, "%-15v%15U%15llu%15u%15u%15llx",
ssvm_name (&seg->ssvm), format_fifo_segment_type,
seg, size >> 20ULL, active_fifos, free_fifos,