From baa962305773a6e1df01fc8b40d089bf72dfe384 Mon Sep 17 00:00:00 2001 From: jiangheng Date: Fri, 27 Sep 2024 16:52:06 +0800 Subject: [PATCH] sync Fill in a portion of mbuf to send_ring, when mbuf is insufficient. (cherry picked from commit f46f3a984c2578f4a7d897785f887cf99d9cc949) --- ...n-of-mbuf-to-send_ring-when-mbuf-is-.patch | 78 +++++++++++++++++++ gazelle.spec | 6 +- 2 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 0261-Fill-in-a-portion-of-mbuf-to-send_ring-when-mbuf-is-.patch diff --git a/0261-Fill-in-a-portion-of-mbuf-to-send_ring-when-mbuf-is-.patch b/0261-Fill-in-a-portion-of-mbuf-to-send_ring-when-mbuf-is-.patch new file mode 100644 index 0000000..1290f60 --- /dev/null +++ b/0261-Fill-in-a-portion-of-mbuf-to-send_ring-when-mbuf-is-.patch @@ -0,0 +1,78 @@ +From 7718bd104226b2444e1a3a7405e4daed9ac046f9 Mon Sep 17 00:00:00 2001 +From: hkk +Date: Wed, 25 Sep 2024 15:01:02 +0800 +Subject: [PATCH] Fill in a portion of mbuf to send_ring, when mbuf is + insufficient. + +--- + src/lstack/core/lstack_lwip.c | 31 +++++++++++++++++++--- + src/lstack/include/lstack_protocol_stack.h | 2 +- + 2 files changed, 29 insertions(+), 4 deletions(-) + +diff --git a/src/lstack/core/lstack_lwip.c b/src/lstack/core/lstack_lwip.c +index 91f4838..7677e46 100644 +--- a/src/lstack/core/lstack_lwip.c ++++ b/src/lstack/core/lstack_lwip.c +@@ -109,18 +109,43 @@ static struct pbuf *init_mbuf_to_pbuf(struct rte_mbuf *mbuf, pbuf_layer layer, u + return pbuf; + } + ++static uint32_t update_replenish_mbuf_cnt(struct protocol_stack *stack, struct lwip_sock *sock) ++{ ++ const uint32_t min_alloc_mbuf_num = 4; ++ struct rte_ring *ring = sock->send_ring; ++ ++ uint32_t replenish_cnt = gazelle_ring_free_count(ring); ++ if (replenish_cnt <= min_alloc_mbuf_num) { ++ return replenish_cnt; ++ } ++ ++ uint32_t resu = replenish_cnt; ++ uint32_t tcp_conn_count = get_global_cfg_params()->tcp_conn_count; ++ uint16_t send_ring_size = get_global_cfg_params()->send_ring_size; ++ uint16_t proportion = stack->conn_num / tcp_conn_count; ++ uint32_t replenish_mbuf_cnt_cal = (send_ring_size >> proportion); ++ ++ if (replenish_mbuf_cnt_cal <= min_alloc_mbuf_num) { ++ resu = min_alloc_mbuf_num; ++ } else if (replenish_mbuf_cnt_cal < replenish_cnt) { ++ resu = replenish_mbuf_cnt_cal; ++ } else { ++ resu = replenish_cnt + 1; ++ } ++ ++ return resu - 1; ++} ++ + /* true: need replenish again */ + static bool replenish_send_idlembuf(struct protocol_stack *stack, struct lwip_sock *sock) + { + void *pbuf[SOCK_SEND_RING_SIZE_MAX]; +- + struct rte_ring *ring = sock->send_ring; + +- uint32_t replenish_cnt = gazelle_ring_free_count(ring); ++ uint32_t replenish_cnt = update_replenish_mbuf_cnt(stack, sock); + if (replenish_cnt == 0) { + return false; + } +- + if (dpdk_alloc_pktmbuf(stack->rxtx_mbuf_pool, (struct rte_mbuf **)pbuf, replenish_cnt, true) != 0) { + stack->stats.tx_allocmbuf_fail++; + return true; +diff --git a/src/lstack/include/lstack_protocol_stack.h b/src/lstack/include/lstack_protocol_stack.h +index 8cb0020..4d10ac2 100644 +--- a/src/lstack/include/lstack_protocol_stack.h ++++ b/src/lstack/include/lstack_protocol_stack.h +@@ -34,7 +34,7 @@ + #define SOCK_RECV_RING_SIZE_MAX (2048) + #define SOCK_SEND_RING_SIZE_MAX (2048) + +-#define MBUFPOOL_RESERVE_NUM (get_global_cfg_params()->rxqueue_size + 1024) ++#define MBUFPOOL_RESERVE_NUM (2 * get_global_cfg_params()->rxqueue_size + 1024) + + struct protocol_stack { + uint32_t tid; +-- +2.33.0 + diff --git a/gazelle.spec b/gazelle.spec index 2d3093c..59ded9a 100644 --- a/gazelle.spec +++ b/gazelle.spec @@ -2,7 +2,7 @@ Name: gazelle Version: 1.0.2 -Release: 64 +Release: 65 Summary: gazelle is a high performance user-mode stack License: MulanPSL-2.0 URL: https://gitee.com/openeuler/gazelle @@ -277,6 +277,7 @@ Patch9257: 0257-cleancode-refactor-rtc_api-rtw_api-and-dummy_api.patch Patch9258: 0258-cleancode-move-some-API-from-stack-to-rpc-and-rtw.patch Patch9259: 0259-cleancode-add-rpc_async_call-remove-rpc_msg_arg.sock.patch Patch9260: 0260-cleancode-declare-different-cfg_params-types.patch +Patch9261: 0261-Fill-in-a-portion-of-mbuf-to-send_ring-when-mbuf-is-.patch %description %{name} is a high performance user-mode stack. @@ -318,6 +319,9 @@ install -Dpm 0640 %{_builddir}/%{name}-%{version}/src/ltran/ltran.conf %{b %config(noreplace) %{conf_path}/ltran.conf %changelog +* Fri Sep 27 2024 yinbin6 - 1.0.2-65 +- Fill in a portion of mbuf to send_ring, when mbuf is insufficient. + * Fri Sep 27 2024 yinbin6 - 1.0.2-64 - cleancode: declare different cfg_params types - cleancode: add rpc_async_call, remove rpc_msg_arg.socklen, fix some format