aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/svm/svm_fifo.c2
-rw-r--r--src/vnet/session/segment_manager.c37
-rw-r--r--src/vnet/session/segment_manager.h8
-rw-r--r--src/vnet/session/session.c8
4 files changed, 8 insertions, 47 deletions
diff --git a/src/svm/svm_fifo.c b/src/svm/svm_fifo.c
index 14729710aac..dc9e4fbed87 100644
--- a/src/svm/svm_fifo.c
+++ b/src/svm/svm_fifo.c
@@ -1340,7 +1340,7 @@ svm_fifo_clone (svm_fifo_t * df, svm_fifo_t * sf)
ASSERT (svm_fifo_n_chunks (sf) == 1);
clib_memcpy_fast (f_head_cptr (df)->data, f_head_cptr (sf)->data,
- sf->shr->size);
+ f_head_cptr (sf)->length);
f_load_head_tail_all_acq (sf, &head, &tail);
clib_atomic_store_rel_n (&df->shr->head, head);
diff --git a/src/vnet/session/segment_manager.c b/src/vnet/session/segment_manager.c
index eca199f9d0e..2d20d9cc1e4 100644
--- a/src/vnet/session/segment_manager.c
+++ b/src/vnet/session/segment_manager.c
@@ -20,7 +20,6 @@
typedef struct segment_manager_main_
{
segment_manager_t *segment_managers; /**< Pool of segment managers */
- clib_valloc_main_t va_allocator; /**< Virtual address allocator */
u32 seg_name_counter; /**< Counter for segment names */
/*
@@ -91,11 +90,10 @@ segment_manager_segment_index (segment_manager_t * sm, fifo_segment_t * seg)
int
segment_manager_add_segment (segment_manager_t * sm, uword segment_size)
{
- uword baseva = (uword) ~ 0ULL, alloc_size, page_size;
- u32 rnd_margin = 128 << 10, fs_index = ~0;
segment_manager_main_t *smm = &sm_main;
segment_manager_props_t *props;
fifo_segment_t *fs;
+ u32 fs_index = ~0;
u8 *seg_name;
int rv;
@@ -120,22 +118,11 @@ segment_manager_add_segment (segment_manager_t * sm, uword segment_size)
* 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);
+ segment_size = round_pow2 (segment_size, clib_mem_get_page_size ());
if (props->segment_type != SSVM_SEGMENT_PRIVATE)
{
seg_name = format (0, "%d-%d%c", getpid (), smm->seg_name_counter++, 0);
- alloc_size = (uword) segment_size + rnd_margin;
- baseva = clib_valloc_alloc (&smm->va_allocator, alloc_size, 0);
- if (!baseva)
- {
- clib_warning ("out of space for segments");
- pool_put (sm->segments, fs);
- goto done;
- }
}
else
{
@@ -146,16 +133,12 @@ segment_manager_add_segment (segment_manager_t * sm, uword segment_size)
fs->ssvm.ssvm_size = segment_size;
fs->ssvm.name = seg_name;
- /* clib_mem_vm_map_shared consumes first page before requested_va */
- fs->ssvm.requested_va = baseva + page_size;
+ fs->ssvm.requested_va = 0;
if ((rv = ssvm_server_init (&fs->ssvm, props->segment_type)))
{
clib_warning ("svm_master_init ('%v', %u) failed", seg_name,
segment_size);
-
- if (props->segment_type != SSVM_SEGMENT_PRIVATE)
- clib_valloc_free (&smm->va_allocator, baseva);
pool_put (sm->segments, fs);
goto done;
}
@@ -193,14 +176,8 @@ done:
void
segment_manager_del_segment (segment_manager_t * sm, fifo_segment_t * fs)
{
- segment_manager_main_t *smm = &sm_main;
-
if (ssvm_type (&fs->ssvm) != SSVM_SEGMENT_PRIVATE)
{
- /* clib_mem_vm_map_shared consumes first page before requested_va */
- clib_valloc_free (&smm->va_allocator,
- fs->ssvm.requested_va - clib_mem_get_page_size ());
-
if (!segment_manager_app_detached (sm))
{
app_worker_t *app_wrk;
@@ -930,15 +907,9 @@ segment_manager_dealloc_queue (segment_manager_t * sm, svm_queue_t * q)
* Init segment vm address allocator
*/
void
-segment_manager_main_init (segment_manager_main_init_args_t * a)
+segment_manager_main_init (void)
{
segment_manager_main_t *sm = &sm_main;
- clib_valloc_chunk_t _ip, *ip = &_ip;
-
- ip->baseva = a->baseva;
- ip->size = a->size;
-
- clib_valloc_init (&sm->va_allocator, ip, 1 /* lock */ );
sm->default_fifo_size = 1 << 12;
sm->default_segment_size = 1 << 20;
diff --git a/src/vnet/session/segment_manager.h b/src/vnet/session/segment_manager.h
index 1036ca2a99a..454fef87967 100644
--- a/src/vnet/session/segment_manager.h
+++ b/src/vnet/session/segment_manager.h
@@ -78,12 +78,6 @@ typedef struct _segment_manager
u8 low_watermark;
} segment_manager_t;
-typedef struct segment_manager_main_init_args_
-{
- u64 baseva;
- u64 size;
-} segment_manager_main_init_args_t;
-
#define SEGMENT_MANAGER_INVALID_APP_INDEX ((u32) ~0)
segment_manager_t *segment_manager_alloc (void);
@@ -166,7 +160,7 @@ void segment_manager_app_detach (segment_manager_t * sm);
void segment_manager_del_sessions (segment_manager_t * sm);
void segment_manager_format_sessions (segment_manager_t * sm, int verbose);
-void segment_manager_main_init (segment_manager_main_init_args_t * a);
+void segment_manager_main_init (void);
segment_manager_props_t *segment_manager_props_init (segment_manager_props_t *
sm);
diff --git a/src/vnet/session/session.c b/src/vnet/session/session.c
index 9a4d29bdf29..90f2fdeba0c 100644
--- a/src/vnet/session/session.c
+++ b/src/vnet/session/session.c
@@ -1670,11 +1670,9 @@ session_queue_run_on_main_thread (vlib_main_t * vm)
static clib_error_t *
session_manager_main_enable (vlib_main_t * vm)
{
- segment_manager_main_init_args_t _sm_args = { 0 }, *sm_args = &_sm_args;
session_main_t *smm = &session_main;
vlib_thread_main_t *vtm = vlib_get_thread_main ();
u32 num_threads, preallocated_sessions_per_worker;
- uword margin = 8 << 12;
session_worker_t *wrk;
int i;
@@ -1708,10 +1706,8 @@ session_manager_main_enable (vlib_main_t * vm)
/* Allocate vpp event queues segment and queue */
session_vpp_event_queues_allocate (smm);
- /* Initialize fifo segment main baseva and timeout */
- sm_args->baseva = smm->session_baseva + smm->evt_qs_segment_size + margin;
- sm_args->size = smm->session_va_space_size;
- segment_manager_main_init (sm_args);
+ /* Initialize segment manager properties */
+ segment_manager_main_init ();
/* Preallocate sessions */
if (smm->preallocated_sessions)