代码拉取完成,页面将自动刷新
同步操作将从 src-openEuler/gazelle 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
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
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。