diff options
author | Florin Coras <fcoras@cisco.com> | 2020-12-28 16:28:07 -0800 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2020-12-29 21:43:49 +0000 |
commit | 9a45bd84d9f8e37f7914eb36d2ffdcd209aa15cb (patch) | |
tree | 3a16e384fc88ad6b607c8017f09b40b2bc5b5b39 /src/vnet/session/segment_manager.c | |
parent | 14f066e95100cfdcd5f0531e35ba84b7b859a00a (diff) |
session: remove fifo segment va allocator
Type: improvement
Signed-off-by: Florin Coras <fcoras@cisco.com>
Change-Id: I7b2fd896dfa6df46916f46327975b95561809f00
Diffstat (limited to 'src/vnet/session/segment_manager.c')
-rw-r--r-- | src/vnet/session/segment_manager.c | 37 |
1 files changed, 4 insertions, 33 deletions
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; |