From 00e743382b45a9585cccfb1e94ba0e9cb8db2433 Mon Sep 17 00:00:00 2001 From: jiangheng Date: Thu, 15 Dec 2022 19:10:44 +0800 Subject: [PATCH] ltran rxtx mbuf pool size config by conf (cherry picked from commit 6f85830e40023d334898c0f14e66988b61dd2f9b) --- ...n-rxtx-mbuf-pool-size-config-by-conf.patch | 169 ++++++++++++++++++ gazelle.spec | 6 +- 2 files changed, 174 insertions(+), 1 deletion(-) create mode 100644 0156-ltran-rxtx-mbuf-pool-size-config-by-conf.patch diff --git a/0156-ltran-rxtx-mbuf-pool-size-config-by-conf.patch b/0156-ltran-rxtx-mbuf-pool-size-config-by-conf.patch new file mode 100644 index 0000000..a891b37 --- /dev/null +++ b/0156-ltran-rxtx-mbuf-pool-size-config-by-conf.patch @@ -0,0 +1,169 @@ +From 3ed8f430fb3070404d5b77da99964623877a01dd Mon Sep 17 00:00:00 2001 +From: jiangheng +Date: Thu, 15 Dec 2022 16:35:46 +0800 +Subject: [PATCH] ltran rxtx mbuf pool size config by conf + +--- + src/ltran/ltran.conf | 3 +++ + src/ltran/ltran_ethdev.c | 18 ++++++++---------- + src/ltran/ltran_param.c | 32 ++++++++++++++++++++++++++++++++ + src/ltran/ltran_param.h | 2 ++ + src/ltran/ltran_stat.h | 2 +- + 5 files changed, 46 insertions(+), 11 deletions(-) + +diff --git a/src/ltran/ltran.conf b/src/ltran/ltran.conf +index 3c1a2bc..4bfcbef 100644 +--- a/src/ltran/ltran.conf ++++ b/src/ltran/ltran.conf +@@ -24,3 +24,6 @@ bond_macs="aa:bb:cc:dd:ee:ff" + bond_ports="0x1" + + tcp_conn_scan_interval=10 ++# number of mbuf for tx and rx. default tx is 30720, default rx is 307200. ++#rx_pool_mbuf_size = 307200 ++#tx_pool_mbuf_size = 30720 +diff --git a/src/ltran/ltran_ethdev.c b/src/ltran/ltran_ethdev.c +index 45bf2ef..62a662d 100644 +--- a/src/ltran/ltran_ethdev.c ++++ b/src/ltran/ltran_ethdev.c +@@ -78,8 +78,8 @@ static int32_t ltran_log_init(void); + static int32_t ltran_eal_init(void); + static int32_t ltran_pdump_init(void); + static int32_t ltran_log_level_init(void); +-static struct rte_mempool *ltran_create_rx_mbuf_pool(uint32_t bond_port_index, uint32_t scale); +-static struct rte_mempool *ltran_create_tx_mbuf_pool(uint32_t bond_port_index, uint32_t scale); ++static struct rte_mempool *ltran_create_rx_mbuf_pool(uint32_t bond_port_index); ++static struct rte_mempool *ltran_create_tx_mbuf_pool(uint32_t bond_port_index); + static int32_t ltran_parse_port(void); + static int32_t ltran_mbuf_pool_init(void); + static int32_t ltran_single_slave_port_init(uint16_t port_num, struct rte_mempool *pktmbuf_rxpool); +@@ -133,9 +133,9 @@ static int32_t ltran_pdump_init(void) + return GAZELLE_OK; + } + +-static struct rte_mempool *ltran_create_rx_mbuf_pool(uint32_t bond_port_index, uint32_t scale) ++static struct rte_mempool *ltran_create_rx_mbuf_pool(uint32_t bond_port_index) + { +- uint32_t num_mbufs = GAZELLE_MBUFS_RX_COUNT * scale; ++ uint32_t num_mbufs = get_ltran_config()->rx_mbuf_pool_size; + + char mbuf_pool_name[GAZELLE_PKT_MBUF_POOL_NAME_LENGTH] = {0}; + +@@ -151,9 +151,9 @@ static struct rte_mempool *ltran_create_rx_mbuf_pool(uint32_t bond_port_index, u + RTE_MBUF_DEFAULT_BUF_SIZE, (int32_t)rte_socket_id()); + } + +-static struct rte_mempool *ltran_create_tx_mbuf_pool(uint32_t bond_port_index, uint32_t scale) ++static struct rte_mempool *ltran_create_tx_mbuf_pool(uint32_t bond_port_index) + { +- const uint32_t num_mbufs = GAZELLE_MBUFS_TX_COUNT * scale; ++ const uint32_t num_mbufs = get_ltran_config()->tx_mbuf_pool_size; + + char mbuf_pool_name[GAZELLE_PKT_MBUF_POOL_NAME_LENGTH] = {0}; + +@@ -174,17 +174,15 @@ static int32_t ltran_mbuf_pool_init(void) + uint32_t bond_num = get_bond_num(); + struct rte_mempool** rxpool = get_pktmbuf_rxpool(); + struct rte_mempool** txpool = get_pktmbuf_txpool(); +- struct ltran_config* ltran_config = get_ltran_config(); +- struct port_info* port_info = get_port_info(); + + for (uint32_t i = 0; i < bond_num; i++) { +- rxpool[i] = ltran_create_rx_mbuf_pool(i, 1); ++ rxpool[i] = ltran_create_rx_mbuf_pool(i); + if (rxpool[i] == NULL) { + LTRAN_ERR("rxpool[%u] is NULL, pktmbuf_pool init failed. rte_errno: %d. \n", i, rte_errno); + return GAZELLE_ERR; + } + +- txpool[i] = ltran_create_tx_mbuf_pool(i, port_info[i].num_ports * ltran_config->bond.tx_queue_num); ++ txpool[i] = ltran_create_tx_mbuf_pool(i); + if (txpool[i] == NULL) { + LTRAN_ERR("txpool[%u] is NULL, pktmbuf_pool init failed. rte_errno: %d. \n", i, rte_errno); + return GAZELLE_ERR; +diff --git a/src/ltran/ltran_param.c b/src/ltran/ltran_param.c +index 18854cf..1b9d82b 100644 +--- a/src/ltran/ltran_param.c ++++ b/src/ltran/ltran_param.c +@@ -43,6 +43,8 @@ + #define PARAM_BOND_MACS "bond_macs" + #define PARAM_TCP_CONN_SCAN_INTERVAL "tcp_conn_scan_interval" + #define PARAM_UNIX_PREFIX "unix_prefix" ++#define PARAM_RX_MBUF_POOL_SIZE "rx_mbuf_pool_size" ++#define PARAM_TX_MBUF_POOL_SIZE "tx_mbuf_pool_size" + + static struct ltran_config g_ltran_config = {0}; + struct ltran_config* get_ltran_config(void) +@@ -610,6 +612,34 @@ static int32_t parse_unix_prefix(const config_t *config, const char *key, struct + return GAZELLE_OK; + } + ++static int32_t parse_rx_mbuf_pool_size(const config_t *config, const char *key, struct ltran_config *ltran_config) ++{ ++ int32_t ret; ++ int32_t rx_mbuf_pool_size = 0; ++ ret = config_lookup_int(config, key, &rx_mbuf_pool_size); ++ if (ret == 0) { ++ ltran_config->rx_mbuf_pool_size = GAZELLE_MBUFS_RX_COUNT; ++ return GAZELLE_OK; ++ } ++ ++ ltran_config->rx_mbuf_pool_size = rx_mbuf_pool_size; ++ return GAZELLE_OK; ++} ++ ++static int32_t parse_tx_mbuf_pool_size(const config_t *config, const char *key, struct ltran_config *ltran_config) ++{ ++ int32_t ret; ++ int32_t tx_mbuf_pool_size = 0; ++ ret = config_lookup_int(config, key, &tx_mbuf_pool_size); ++ if (ret == 0) { ++ ltran_config->tx_mbuf_pool_size = GAZELLE_MBUFS_TX_COUNT; ++ return GAZELLE_OK; ++ } ++ ++ ltran_config->tx_mbuf_pool_size = tx_mbuf_pool_size; ++ return GAZELLE_OK; ++} ++ + struct param_parser g_param_parse_tbl[] = { + {PARAM_FORWARD_KIT_ARGS, parse_forward_kit_args}, + {PARAM_DISPATCH_MAX_CLIENT, parse_dispatch_max_client}, +@@ -625,6 +655,8 @@ struct param_parser g_param_parse_tbl[] = { + {PARAM_TCP_CONN_SCAN_INTERVAL, parse_tcp_conn_scan_interval}, + {PARAM_KNI_SWITCH, parse_kni_switch}, + {PARAM_UNIX_PREFIX, parse_unix_prefix}, ++ {PARAM_RX_MBUF_POOL_SIZE, parse_rx_mbuf_pool_size}, ++ {PARAM_TX_MBUF_POOL_SIZE, parse_tx_mbuf_pool_size}, + }; + + int32_t parse_config_file_args(const char *conf_file_path, struct ltran_config *ltran_config) +diff --git a/src/ltran/ltran_param.h b/src/ltran/ltran_param.h +index 6f013d5..40a92b1 100644 +--- a/src/ltran/ltran_param.h ++++ b/src/ltran/ltran_param.h +@@ -58,6 +58,8 @@ struct ltran_config { + } log; + char unix_socket_filename[NAME_MAX]; + char dfx_socket_filename[NAME_MAX]; ++ uint32_t rx_mbuf_pool_size; ++ uint32_t tx_mbuf_pool_size; + }; + + int32_t parse_config_file_args(const char *conf_file_path, struct ltran_config *ltran_config); +diff --git a/src/ltran/ltran_stat.h b/src/ltran/ltran_stat.h +index f91b0c4..16d03a1 100644 +--- a/src/ltran/ltran_stat.h ++++ b/src/ltran/ltran_stat.h +@@ -23,7 +23,7 @@ + * When doing reads from the NIC or the client queues, + * use this batch size + */ +-#define BACKUP_SIZE_FACTOR (256) ++#define BACKUP_SIZE_FACTOR (1024) + #define RING_MAX_SIZE (512) /* determined by g_mbuf_ring.rx_ring in func create_shared_ring in file dpdk.c */ + #define PACKET_READ_SIZE (32) + #define BACKUP_MBUF_SIZE (BACKUP_SIZE_FACTOR * PACKET_READ_SIZE) +-- +2.33.0 + diff --git a/gazelle.spec b/gazelle.spec index 542726c..d09a3e2 100644 --- a/gazelle.spec +++ b/gazelle.spec @@ -2,7 +2,7 @@ Name: gazelle Version: 1.0.1 -Release: 31 +Release: 32 Summary: gazelle is a high performance user-mode stack License: MulanPSL-2.0 URL: https://gitee.com/openeuler/gazelle @@ -170,6 +170,7 @@ Patch9152: 0152-fix-genarate-out-event-untimely.patch Patch9153: 0153-rxtx-mbuf-pool-size-config-by-conf.patch Patch9154: 0154-fix-kernel-event-thread-bind-numa-failed.patch Patch9155: 0155-stack-thread-parms-config-by-conf.patch +Patch9156: 0156-ltran-rxtx-mbuf-pool-size-config-by-conf.patch %description %{name} is a high performance user-mode stack. @@ -210,6 +211,9 @@ install -Dpm 0640 %{_builddir}/%{name}-%{version}/src/ltran/ltran.conf %{b %config(noreplace) %{conf_path}/ltran.conf %changelog +* Thu Dec 15 2022 jiangheng - 1.0.1-32 +- ltran rxtx mbuf pool size config by conf + * Thu Dec 15 2022 wuchangsheng - 1.0.1-31 - stack thread params config by lstack.conf