1 Star 0 Fork 32

吴昌盛/gazelle-tar

forked from src-openEuler/gazelle 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0215-gazelle-send-recv-thread-bind-numa.patch 2.02 KB
一键复制 编辑 原始数据 按行查看 历史
From b658a975bb76d3b39edb7fd73ab5815c302bce02 Mon Sep 17 00:00:00 2001
From: kircher <majun65@huawei.com>
Date: Tue, 21 Mar 2023 11:08:46 +0800
Subject: [PATCH] gazelle send/recv thread bind numa
---
src/lstack/core/lstack_lwip.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/src/lstack/core/lstack_lwip.c b/src/lstack/core/lstack_lwip.c
index 60abfe8..7355d7b 100644
--- a/src/lstack/core/lstack_lwip.c
+++ b/src/lstack/core/lstack_lwip.c
@@ -97,6 +97,7 @@ static void reset_sock_data(struct lwip_sock *sock)
sock->events = 0;
sock->call_num = 0;
sock->remain_len = 0;
+ sock->already_bind_numa = 0;
if (sock->recv_lastdata) {
pbuf_free(sock->recv_lastdata);
@@ -882,6 +883,21 @@ ssize_t gazelle_same_node_ring_send(struct lwip_sock *sock, const void *buf, siz
return act_len;
}
+PER_THREAD uint16_t stack_sock_num[GAZELLE_MAX_STACK_NUM] = {0};
+PER_THREAD uint16_t max_sock_stack = 0;
+
+static void thread_bind_stack(struct lwip_sock *sock) {
+ if (likely(!sock->stack || sock->already_bind_numa)) {
+ return;
+ }
+ sock->already_bind_numa = 1;
+ stack_sock_num[sock->stack->stack_idx]++;
+ if (stack_sock_num[sock->stack->stack_idx] > max_sock_stack) {
+ max_sock_stack = stack_sock_num[sock->stack->stack_idx];
+ bind_to_stack_numa(sock->stack);
+ }
+}
+
ssize_t gazelle_send(int32_t fd, const void *buf, size_t len, int32_t flags)
{
if (buf == NULL) {
@@ -893,6 +909,9 @@ ssize_t gazelle_send(int32_t fd, const void *buf, size_t len, int32_t flags)
}
struct lwip_sock *sock = get_socket_by_fd(fd);
+
+ thread_bind_stack(sock);
+
if (sock->same_node_tx_ring != NULL) {
return gazelle_same_node_ring_send(sock, buf, len, flags);
}
@@ -973,6 +992,8 @@ ssize_t read_stack_data(int32_t fd, void *buf, size_t len, int32_t flags)
return 0;
}
+ thread_bind_stack(sock);
+
if (sock->same_node_rx_ring != NULL) {
return gazelle_same_node_ring_recv(sock, buf, len, flags);
}
--
2.33.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wu-changsheng/gazelle-tar.git
git@gitee.com:wu-changsheng/gazelle-tar.git
wu-changsheng
gazelle-tar
gazelle-tar
master

搜索帮助