diff options
author | Florin Coras <fcoras@cisco.com> | 2020-09-28 23:40:28 -0700 |
---|---|---|
committer | Damjan Marion <dmarion@me.com> | 2020-09-30 10:11:21 +0000 |
commit | 2a7c0b6fc027e86727c08d98b66e19ad8768c82b (patch) | |
tree | cf037f459b5620fcf4151d272b3fad3d5fa82a19 /src/vnet/session | |
parent | 5aa34d54de1e3dcdab1b74207ef8a24cc67a0f5d (diff) |
svm session: use new clib mem apis for segments
"sh memory map" now reports shared memory segments mapped by session
layer for applications.
Type: improvement
Signed-off-by: Florin Coras <fcoras@cisco.com>
Change-Id: I7debdcd06c7728abfb5cf817a1ccc37de495472c
Diffstat (limited to 'src/vnet/session')
-rw-r--r-- | src/vnet/session/application.c | 7 | ||||
-rw-r--r-- | src/vnet/session/application_worker.c | 8 | ||||
-rw-r--r-- | src/vnet/session/segment_manager.c | 14 | ||||
-rw-r--r-- | src/vnet/session/session.c | 8 |
4 files changed, 22 insertions, 15 deletions
diff --git a/src/vnet/session/application.c b/src/vnet/session/application.c index a0ddaed90cf..0b5c951fd70 100644 --- a/src/vnet/session/application.c +++ b/src/vnet/session/application.c @@ -876,11 +876,8 @@ vnet_application_attach (vnet_app_attach_args_t * a) if (application_is_proxy (app)) { application_setup_proxy (app); - /* - * I suspect the segment manager pool gets reallocated (because a new listener - * is added, and each listener has a segment manager) so sm becomes a dangling - * reference. That's why we need to re-grab sm. - */ + /* The segment manager pool is reallocated because a new listener + * is added. Re-grab segment manager to avoid dangling reference */ sm = segment_manager_get (app_wrk->first_segment_manager); } diff --git a/src/vnet/session/application_worker.c b/src/vnet/session/application_worker.c index 17aeb57d49b..2b2cc344f05 100644 --- a/src/vnet/session/application_worker.c +++ b/src/vnet/session/application_worker.c @@ -180,12 +180,12 @@ app_worker_alloc_segment_manager (app_worker_t * app_wrk) { sm = segment_manager_get (app_wrk->first_segment_manager); app_wrk->first_segment_manager_in_use = 1; - return sm; } - - sm = segment_manager_alloc (); + else + { + sm = segment_manager_alloc (); + } sm->app_wrk_index = app_wrk->wrk_index; - return sm; } diff --git a/src/vnet/session/segment_manager.c b/src/vnet/session/segment_manager.c index dbeff6e4acf..44ff5fefd70 100644 --- a/src/vnet/session/segment_manager.c +++ b/src/vnet/session/segment_manager.c @@ -138,11 +138,16 @@ segment_manager_add_segment (segment_manager_t * sm, uword segment_size) } } else - seg_name = format (0, "%s%c", "process-private", 0); + { + app_worker_t *app_wrk = app_worker_get (sm->app_wrk_index); + application_t *app = application_get (app_wrk->app_index); + seg_name = format (0, "%v segment%c", app->name, 0); + } fs->ssvm.ssvm_size = segment_size; fs->ssvm.name = seg_name; - fs->ssvm.requested_va = baseva; + /* clib_mem_vm_map_shared consumes first page before requested_va */ + fs->ssvm.requested_va = baseva + page_size; if ((rv = ssvm_master_init (&fs->ssvm, props->segment_type))) { @@ -192,7 +197,9 @@ segment_manager_del_segment (segment_manager_t * sm, fifo_segment_t * fs) if (ssvm_type (&fs->ssvm) != SSVM_SEGMENT_PRIVATE) { - clib_valloc_free (&smm->va_allocator, fs->ssvm.requested_va); + /* 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)) { @@ -947,6 +954,7 @@ segment_manager_show_fn (vlib_main_t * vm, unformat_input_t * input, })); /* *INDENT-ON* */ + vlib_cli_output (vm, "\n"); } if (show_segments) { diff --git a/src/vnet/session/session.c b/src/vnet/session/session.c index d27d1bbab23..5065f7834b1 100644 --- a/src/vnet/session/session.c +++ b/src/vnet/session/session.c @@ -1496,8 +1496,9 @@ session_vpp_event_queues_allocate (session_main_t * smm) eqs->ssvm_size = eqs_size; eqs->i_am_master = 1; eqs->my_pid = vpp_pid; - eqs->name = format (0, "%s%c", "evt-qs-segment", 0); - eqs->requested_va = smm->session_baseva; + eqs->name = format (0, "%s%c", "session: evt-qs-segment", 0); + /* clib_mem_vm_map_shared consumes first page before requested_va */ + eqs->requested_va = smm->session_baseva + clib_mem_get_page_size (); if (ssvm_master_init (eqs, SSVM_SEGMENT_MEMFD)) { @@ -1661,6 +1662,7 @@ session_manager_main_enable (vlib_main_t * vm) 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; @@ -1691,7 +1693,7 @@ session_manager_main_enable (vlib_main_t * vm) session_vpp_event_queues_allocate (smm); /* Initialize fifo segment main baseva and timeout */ - sm_args->baseva = smm->session_baseva + smm->evt_qs_segment_size; + 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); |