diff options
author | Junfeng Wang <drenfong.wang@intel.com> | 2022-08-12 16:24:46 +0800 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2022-09-15 23:15:26 +0000 |
commit | c795b8836d83b4b062aa21423f842aa765269c2c (patch) | |
tree | 9c7f9835da485443b4a43477e706178661399bdd | |
parent | 0654242d1ef51566f0d58445a16053cf376e5a6e (diff) |
vcl: add hugepage for vcl configure and svm
add hugepage for vcl configure and svm
Type: feature
Signed-off-by: Junfeng Wang <drenfong.wang@intel.com>
Change-Id: I6a8905e3fec23d840e629114b1e5a403d0a258ef
-rw-r--r-- | src/svm/ssvm.c | 10 | ||||
-rw-r--r-- | src/svm/ssvm.h | 2 | ||||
-rw-r--r-- | src/vcl/vcl_bapi.c | 3 | ||||
-rw-r--r-- | src/vcl/vcl_cfg.c | 6 | ||||
-rw-r--r-- | src/vcl/vcl_private.h | 1 | ||||
-rw-r--r-- | src/vcl/vcl_sapi.c | 3 | ||||
-rw-r--r-- | src/vnet/session/application.c | 2 | ||||
-rw-r--r-- | src/vnet/session/application_interface.h | 3 | ||||
-rw-r--r-- | src/vnet/session/segment_manager.c | 10 | ||||
-rw-r--r-- | src/vnet/session/segment_manager.h | 1 |
10 files changed, 33 insertions, 8 deletions
diff --git a/src/svm/ssvm.c b/src/svm/ssvm.c index 9cdde128561..bf0a1361e4a 100644 --- a/src/svm/ssvm.c +++ b/src/svm/ssvm.c @@ -227,8 +227,12 @@ ssvm_server_init_memfd (ssvm_private_t * memfd) ASSERT (vec_c_string_is_terminated (memfd->name)); - memfd->fd = clib_mem_vm_create_fd (CLIB_MEM_PAGE_SZ_DEFAULT, - (char *) memfd->name); + if (memfd->huge_page) + memfd->fd = clib_mem_vm_create_fd (CLIB_MEM_PAGE_SZ_DEFAULT_HUGE, + (char *) memfd->name); + else + memfd->fd = + clib_mem_vm_create_fd (CLIB_MEM_PAGE_SZ_DEFAULT, (char *) memfd->name); if (memfd->fd == CLIB_MEM_ERROR) { @@ -270,7 +274,7 @@ ssvm_server_init_memfd (ssvm_private_t * memfd) sh->ssvm_va = pointer_to_uword (sh); sh->type = SSVM_SEGMENT_MEMFD; - page_size = 1ULL << log2_page_size; + page_size = clib_mem_get_page_size (); sh->heap = clib_mem_create_heap (((u8 *) sh) + page_size, memfd->ssvm_size - page_size, 1 /* locked */ , "ssvm server memfd"); diff --git a/src/svm/ssvm.h b/src/svm/ssvm.h index 9bd16a9b462..ef982a1b304 100644 --- a/src/svm/ssvm.h +++ b/src/svm/ssvm.h @@ -87,7 +87,7 @@ typedef struct u8 *name; u8 numa; /**< UNUSED: numa requested at alloc time */ int is_server; - + int huge_page; union { int fd; /**< memfd segments */ diff --git a/src/vcl/vcl_bapi.c b/src/vcl/vcl_bapi.c index bb2b94f04d8..bbb04205768 100644 --- a/src/vcl/vcl_bapi.c +++ b/src/vcl/vcl_bapi.c @@ -354,7 +354,8 @@ vcl_bapi_send_attach (void) (vcm->cfg.app_scope_local ? APP_OPTIONS_FLAGS_USE_LOCAL_SCOPE : 0) | (vcm->cfg.app_scope_global ? APP_OPTIONS_FLAGS_USE_GLOBAL_SCOPE : 0) | (app_is_proxy ? APP_OPTIONS_FLAGS_IS_PROXY : 0) | - (vcm->cfg.use_mq_eventfd ? APP_OPTIONS_FLAGS_EVT_MQ_USE_EVENTFD : 0); + (vcm->cfg.use_mq_eventfd ? APP_OPTIONS_FLAGS_EVT_MQ_USE_EVENTFD : 0) | + (vcm->cfg.huge_page ? APP_OPTIONS_FLAGS_USE_HUGE_PAGE : 0); bmp->options[APP_OPTIONS_PROXY_TRANSPORT] = (u64) ((vcm->cfg.app_proxy_transport_tcp ? 1 << TRANSPORT_PROTO_TCP : 0) | (vcm->cfg.app_proxy_transport_udp ? 1 << TRANSPORT_PROTO_UDP : 0)); diff --git a/src/vcl/vcl_cfg.c b/src/vcl/vcl_cfg.c index ac768c4d6e3..be142eaeb58 100644 --- a/src/vcl/vcl_cfg.c +++ b/src/vcl/vcl_cfg.c @@ -416,6 +416,12 @@ vppcom_cfg_read_file (char *conf_fname) VCFG_DBG (0, "VCL<%d>: configured app_scope_global (%d)", getpid (), vcl_cfg->app_scope_global); } + else if (unformat (line_input, "huge_page")) + { + vcl_cfg->huge_page = 1; + VCFG_DBG (0, "VCL<%d>: configured huge_page (%d)", getpid (), + vcl_cfg->huge_page); + } else if (unformat (line_input, "namespace-secret %lu", &vcl_cfg->namespace_secret)) { diff --git a/src/vcl/vcl_private.h b/src/vcl/vcl_private.h index 624a2dad50e..846875df8a9 100644 --- a/src/vcl/vcl_private.h +++ b/src/vcl/vcl_private.h @@ -204,6 +204,7 @@ typedef struct vppcom_cfg_t_ u8 *vpp_bapi_socket_name; /**< bapi socket transport socket name */ u32 tls_engine; u8 mt_wrk_supported; + u8 huge_page; } vppcom_cfg_t; void vppcom_cfg (vppcom_cfg_t * vcl_cfg); diff --git a/src/vcl/vcl_sapi.c b/src/vcl/vcl_sapi.c index 5f4263b3b13..7d677e9dc1a 100644 --- a/src/vcl/vcl_sapi.c +++ b/src/vcl/vcl_sapi.c @@ -127,7 +127,8 @@ vcl_api_send_attach (clib_socket_t * cs) (vcm->cfg.app_scope_local ? APP_OPTIONS_FLAGS_USE_LOCAL_SCOPE : 0) | (vcm->cfg.app_scope_global ? APP_OPTIONS_FLAGS_USE_GLOBAL_SCOPE : 0) | (app_is_proxy ? APP_OPTIONS_FLAGS_IS_PROXY : 0) | - (vcm->cfg.use_mq_eventfd ? APP_OPTIONS_FLAGS_EVT_MQ_USE_EVENTFD : 0); + (vcm->cfg.use_mq_eventfd ? APP_OPTIONS_FLAGS_EVT_MQ_USE_EVENTFD : 0) | + (vcm->cfg.huge_page ? APP_OPTIONS_FLAGS_USE_HUGE_PAGE : 0); mp->options[APP_OPTIONS_PROXY_TRANSPORT] = (u64) ((vcm->cfg.app_proxy_transport_tcp ? 1 << TRANSPORT_PROTO_TCP : 0) | (vcm->cfg.app_proxy_transport_udp ? 1 << TRANSPORT_PROTO_UDP : 0)); diff --git a/src/vnet/session/application.c b/src/vnet/session/application.c index 67dc7d633ec..3b2c7cdb35a 100644 --- a/src/vnet/session/application.c +++ b/src/vnet/session/application.c @@ -819,6 +819,8 @@ application_alloc_and_init (app_init_args_t * a) props->add_segment_size = opts[APP_OPTIONS_ADD_SEGMENT_SIZE]; props->add_segment = 1; } + if (opts[APP_OPTIONS_FLAGS] & APP_OPTIONS_FLAGS_USE_HUGE_PAGE) + props->huge_page = 1; if (opts[APP_OPTIONS_RX_FIFO_SIZE]) props->rx_fifo_size = opts[APP_OPTIONS_RX_FIFO_SIZE]; if (opts[APP_OPTIONS_TX_FIFO_SIZE]) diff --git a/src/vnet/session/application_interface.h b/src/vnet/session/application_interface.h index b1dab322dd7..9fc03a0e97a 100644 --- a/src/vnet/session/application_interface.h +++ b/src/vnet/session/application_interface.h @@ -232,7 +232,8 @@ typedef enum _ (USE_GLOBAL_SCOPE, "App can use global session scope") \ _ (USE_LOCAL_SCOPE, "App can use local session scope") \ _ (EVT_MQ_USE_EVENTFD, "Use eventfds for signaling") \ - _ (MEMFD_FOR_BUILTIN, "Use memfd for builtin app segs") + _ (MEMFD_FOR_BUILTIN, "Use memfd for builtin app segs") \ + _ (USE_HUGE_PAGE, "Use huge page for FIFO") typedef enum _app_options { diff --git a/src/vnet/session/segment_manager.c b/src/vnet/session/segment_manager.c index 14e4e219996..c14cffa66a2 100644 --- a/src/vnet/session/segment_manager.c +++ b/src/vnet/session/segment_manager.c @@ -127,7 +127,15 @@ segment_manager_add_segment_inline (segment_manager_t *sm, uword segment_size, sizeof (fifo_segment_header_t) + vlib_thread_main.n_vlib_mains * sizeof (fifo_segment_slice_t) + FIFO_SEGMENT_ALLOC_OVERHEAD; - segment_size = round_pow2 (segment_size, clib_mem_get_page_size ()); + + if (props->huge_page) + { + uword hugepage_size = clib_mem_get_default_hugepage_size (); + segment_size = round_pow2 (segment_size, hugepage_size); + fs->ssvm.huge_page = 1; + } + else + segment_size = round_pow2 (segment_size, clib_mem_get_page_size ()); seg_name = format (0, "seg-%u-%u-%u%c", app_wrk->app_index, app_wrk->wrk_index, smm->seg_name_counter++, 0); diff --git a/src/vnet/session/segment_manager.h b/src/vnet/session/segment_manager.h index 8b722a02324..e786b3144c2 100644 --- a/src/vnet/session/segment_manager.h +++ b/src/vnet/session/segment_manager.h @@ -40,6 +40,7 @@ typedef struct _segment_manager_props u8 high_watermark; /**< memory usage high watermark % */ u8 low_watermark; /**< memory usage low watermark % */ u8 pct_first_alloc; /**< pct of fifo size to alloc */ + u8 huge_page; /**< use hugepage */ } segment_manager_props_t; typedef enum seg_manager_flag_ |