summaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2021-11-17 23:38:54 -0800
committerDave Barach <openvpp@barachs.net>2021-11-18 15:25:28 +0000
commit8afe1b88955d2bd2cdcb9b0cb27b21a149af861c (patch)
tree2caebc70e17057126c0c146f3a9c8f0f153f05fa /src/vnet
parentb28652ed7ab016177593b059390f2e99e6af2961 (diff)
session: improve wrk mq segment allocation
Type: improvement Signed-off-by: Florin Coras <fcoras@cisco.com> Change-Id: I9e5438a2f82762aa8a88bbacf4290151ef30969e
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/session/application.c6
-rw-r--r--src/vnet/session/session.c101
-rw-r--r--src/vnet/session/session.h8
3 files changed, 62 insertions, 53 deletions
diff --git a/src/vnet/session/application.c b/src/vnet/session/application.c
index 30c59e1bc84..46dc6d63e74 100644
--- a/src/vnet/session/application.c
+++ b/src/vnet/session/application.c
@@ -684,7 +684,7 @@ application_get_rx_mqs_segment (application_t *app)
{
if (application_use_private_rx_mqs ())
return &app->rx_mqs_segment;
- return session_main_get_evt_q_segment ();
+ return session_main_get_wrk_mqs_segment ();
}
void
@@ -747,14 +747,14 @@ application_verify_cfg (ssvm_segment_type_t st)
u8 is_valid;
if (st == SSVM_SEGMENT_MEMFD)
{
- is_valid = (session_main_get_evt_q_segment () != 0);
+ is_valid = (session_main_get_wrk_mqs_segment () != 0);
if (!is_valid)
clib_warning ("memfd seg: vpp's event qs IN binary api svm region");
return is_valid;
}
else if (st == SSVM_SEGMENT_SHM)
{
- is_valid = (session_main_get_evt_q_segment () == 0);
+ is_valid = (session_main_get_wrk_mqs_segment () == 0);
if (!is_valid)
clib_warning ("shm seg: vpp's event qs NOT IN binary api svm region");
return is_valid;
diff --git a/src/vnet/session/session.c b/src/vnet/session/session.c
index 3a7e98053c6..de1943c84fc 100644
--- a/src/vnet/session/session.c
+++ b/src/vnet/session/session.c
@@ -1648,64 +1648,65 @@ session_transport_cleanup (session_t * s)
}
/**
- * Allocate event queues in the shared-memory segment
+ * Allocate worker mqs in share-able segment
*
- * That can only be a newly created memfd segment, that must be
- * mapped by all apps/stack users.
+ * That can only be a newly created memfd segment, that must be mapped
+ * by all apps/stack users unless private rx mqs are enabled.
*/
void
-session_vpp_event_queues_allocate (session_main_t * smm)
+session_vpp_wrk_mqs_alloc (session_main_t *smm)
{
- u32 evt_q_length = 2048, evt_size = sizeof (session_event_t);
- fifo_segment_t *eqs = &smm->evt_qs_segment;
- uword eqs_size = 64 << 20;
- pid_t vpp_pid = getpid ();
+ u32 mq_q_length = 2048, evt_size = sizeof (session_event_t);
+ fifo_segment_t *mqs_seg = &smm->wrk_mqs_segment;
+ svm_msg_q_cfg_t _cfg, *cfg = &_cfg;
+ uword mqs_seg_size;
int i;
- if (smm->configured_event_queue_length)
- evt_q_length = smm->configured_event_queue_length;
+ mq_q_length = clib_max (mq_q_length, smm->configured_wrk_mq_length);
- if (smm->evt_qs_segment_size)
- eqs_size = smm->evt_qs_segment_size;
+ svm_msg_q_ring_cfg_t rc[SESSION_MQ_N_RINGS] = {
+ { mq_q_length, evt_size, 0 }, { mq_q_length >> 1, 256, 0 }
+ };
+ cfg->consumer_pid = 0;
+ cfg->n_rings = 2;
+ cfg->q_nitems = mq_q_length;
+ cfg->ring_cfgs = rc;
+
+ /*
+ * Compute mqs segment size based on rings config and leave space
+ * for passing extended configuration messages, i.e., data allocated
+ * outside of the rings. If provided with a config value, accept it
+ * if larger than minimum size.
+ */
+ mqs_seg_size = svm_msg_q_size_to_alloc (cfg) * vec_len (smm->wrk);
+ mqs_seg_size = mqs_seg_size + (32 << 10);
+ mqs_seg_size = clib_max (mqs_seg_size, smm->wrk_mqs_segment_size);
- eqs->ssvm.ssvm_size = eqs_size;
- eqs->ssvm.my_pid = vpp_pid;
- eqs->ssvm.name = format (0, "%s%c", "session: evt-qs-segment", 0);
+ mqs_seg->ssvm.ssvm_size = mqs_seg_size;
+ mqs_seg->ssvm.my_pid = getpid ();
+ mqs_seg->ssvm.name = format (0, "%s%c", "session: wrk-mqs-segment", 0);
/* clib_mem_vm_map_shared consumes first page before requested_va */
- eqs->ssvm.requested_va = smm->session_baseva + clib_mem_get_page_size ();
+ mqs_seg->ssvm.requested_va = smm->session_baseva + clib_mem_get_page_size ();
- if (ssvm_server_init (&eqs->ssvm, SSVM_SEGMENT_MEMFD))
+ if (ssvm_server_init (&mqs_seg->ssvm, SSVM_SEGMENT_MEMFD))
{
clib_warning ("failed to initialize queue segment");
return;
}
- fifo_segment_init (eqs);
+ fifo_segment_init (mqs_seg);
/* Special fifo segment that's filled only with mqs */
- eqs->h->n_mqs = vec_len (smm->wrk);
+ mqs_seg->h->n_mqs = vec_len (smm->wrk);
for (i = 0; i < vec_len (smm->wrk); i++)
- {
- svm_msg_q_cfg_t _cfg, *cfg = &_cfg;
- svm_msg_q_ring_cfg_t rc[SESSION_MQ_N_RINGS] = {
- {evt_q_length, evt_size, 0}
- ,
- {evt_q_length >> 1, 256, 0}
- };
- cfg->consumer_pid = 0;
- cfg->n_rings = 2;
- cfg->q_nitems = evt_q_length;
- cfg->ring_cfgs = rc;
-
- smm->wrk[i].vpp_event_queue = fifo_segment_msg_q_alloc (eqs, i, cfg);
- }
+ smm->wrk[i].vpp_event_queue = fifo_segment_msg_q_alloc (mqs_seg, i, cfg);
}
fifo_segment_t *
-session_main_get_evt_q_segment (void)
+session_main_get_wrk_mqs_segment (void)
{
- return &session_main.evt_qs_segment;
+ return &session_main.wrk_mqs_segment;
}
u64
@@ -1862,7 +1863,7 @@ session_manager_main_enable (vlib_main_t * vm)
}
/* Allocate vpp event queues segment and queue */
- session_vpp_event_queues_allocate (smm);
+ session_vpp_wrk_mqs_alloc (smm);
/* Initialize segment manager properties */
segment_manager_main_init ();
@@ -1989,10 +1990,9 @@ session_main_init (vlib_main_t * vm)
#if (HIGH_SEGMENT_BASEVA > (4ULL << 30))
smm->session_va_space_size = 128ULL << 30;
- smm->evt_qs_segment_size = 64 << 20;
#else
smm->session_va_space_size = 128 << 20;
- smm->evt_qs_segment_size = 1 << 20;
+ smm->wrk_mqs_segment_size = 1 << 20;
#endif
smm->last_transport_proto_type = TRANSPORT_PROTO_SRTP;
@@ -2025,10 +2025,10 @@ session_config_fn (vlib_main_t * vm, unformat_input_t * input)
while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
{
- if (unformat (input, "event-queue-length %d", &nitems))
+ if (unformat (input, "wrk-mq-length %d", &nitems))
{
if (nitems >= 2048)
- smm->configured_event_queue_length = nitems;
+ smm->configured_wrk_mq_length = nitems;
else
clib_warning ("event queue length %d too small, ignored", nitems);
}
@@ -2090,12 +2090,6 @@ session_config_fn (vlib_main_t * vm, unformat_input_t * input)
else if (unformat (input, "local-endpoints-table-buckets %d",
&smm->local_endpoints_table_buckets))
;
- /* Deprecated but maintained for compatibility */
- else if (unformat (input, "evt_qs_memfd_seg"))
- ;
- else if (unformat (input, "evt_qs_seg_size %U", unformat_memory_size,
- &smm->evt_qs_segment_size))
- ;
else if (unformat (input, "enable"))
smm->session_enable_asap = 1;
else if (unformat (input, "segment-baseva 0x%lx", &smm->session_baseva))
@@ -2108,6 +2102,21 @@ session_config_fn (vlib_main_t * vm, unformat_input_t * input)
smm->use_private_rx_mqs = 1;
else if (unformat (input, "no-adaptive"))
smm->no_adaptive = 1;
+ /*
+ * Deprecated but maintained for compatibility
+ */
+ else if (unformat (input, "evt_qs_memfd_seg"))
+ ;
+ else if (unformat (input, "evt_qs_seg_size %U", unformat_memory_size,
+ &tmp))
+ ;
+ else if (unformat (input, "event-queue-length %d", &nitems))
+ {
+ if (nitems >= 2048)
+ smm->configured_wrk_mq_length = nitems;
+ else
+ clib_warning ("event queue length %d too small, ignored", nitems);
+ }
else
return clib_error_return (0, "unknown input `%U'",
format_unformat_error, input);
diff --git a/src/vnet/session/session.h b/src/vnet/session/session.h
index 2d01eb6a67a..51ca269ef8c 100644
--- a/src/vnet/session/session.h
+++ b/src/vnet/session/session.h
@@ -176,7 +176,7 @@ typedef struct session_main_
session_worker_t *wrk;
/** Event queues memfd segment */
- fifo_segment_t evt_qs_segment;
+ fifo_segment_t wrk_mqs_segment;
/** Unique segment name counter */
u32 unique_segment_name_counter;
@@ -217,12 +217,12 @@ typedef struct session_main_
u8 no_adaptive;
/** vpp fifo event queue configured length */
- u32 configured_event_queue_length;
+ u32 configured_wrk_mq_length;
/** Session ssvm segment configs*/
uword session_baseva;
uword session_va_space_size;
- uword evt_qs_segment_size;
+ uword wrk_mqs_segment_size;
/** Session table size parameters */
u32 configured_v4_session_table_buckets;
@@ -761,7 +761,7 @@ session_wrk_update_time (session_worker_t *wrk, f64 now)
}
void session_wrk_enable_adaptive_mode (session_worker_t *wrk);
-fifo_segment_t *session_main_get_evt_q_segment (void);
+fifo_segment_t *session_main_get_wrk_mqs_segment (void);
void session_node_enable_disable (u8 is_en);
clib_error_t *vnet_session_enable_disable (vlib_main_t * vm, u8 is_en);