1 Star 0 Fork 32

compile_success/gazelle_3

forked from src-openEuler/gazelle 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0261-Fill-in-a-portion-of-mbuf-to-send_ring-when-mbuf-is-.patch 2.72 KB
一键复制 编辑 原始数据 按行查看 历史
From 7718bd104226b2444e1a3a7405e4daed9ac046f9 Mon Sep 17 00:00:00 2001
From: hkk <hankangkang5@huawei.com>
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
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/compile_success/gazelle_3.git
git@gitee.com:compile_success/gazelle_3.git
compile_success
gazelle_3
gazelle_3
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385