1 Star 0 Fork 32

hantwofish/gazelle_1

forked from src-openEuler/gazelle 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0264-af_xdp-set-rlimit-unlimit-when-gazelle-init.patch 1.47 KB
一键复制 编辑 原始数据 按行查看 历史
From 7e6a5d97430f0d178c5e2b211c0c194fdea0c00a Mon Sep 17 00:00:00 2001
From: yangchen <yangchen145@huawei.com>
Date: Fri, 27 Sep 2024 06:32:41 +0800
Subject: [PATCH] af_xdp: set rlimit unlimit when gazelle init
---
src/lstack/core/lstack_init.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/src/lstack/core/lstack_init.c b/src/lstack/core/lstack_init.c
index 37264a1..1d27f68 100644
--- a/src/lstack/core/lstack_init.c
+++ b/src/lstack/core/lstack_init.c
@@ -17,6 +17,7 @@
#include <semaphore.h>
#include <sys/ioctl.h>
#include <sys/file.h>
+#include <sys/resource.h>
#include <securec.h>
#include <numa.h>
#include <pthread.h>
@@ -104,6 +105,20 @@ static int32_t check_process_conflict(void)
return 0;
}
+/* Remove the memory resource limit of the current process.
+ * if the number of locked memory resources is exceeded, xdp_umem_create fails.
+ */
+static int set_rlimit_unlimited(void)
+{
+ struct rlimit r = {RLIM_INFINITY, RLIM_INFINITY};
+
+ if (setrlimit(RLIMIT_MEMLOCK, &r) != 0) {
+ return -1;
+ }
+
+ return 0;
+}
+
void gazelle_exit(void)
{
wrap_api_exit();
@@ -240,6 +255,11 @@ __attribute__((constructor)) void gazelle_network_init(void)
wrap_api_init();
+ if (set_rlimit_unlimited() != 0) {
+ LSTACK_PRE_LOG(LSTACK_INFO, "set rlimit unlimited failed\n");
+ LSTACK_EXIT(1, "set rlimit unlimited failed\n");
+ }
+
/* check primary process start */
check_process_start();
--
2.33.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/hantwofish/gazelle_1.git
git@gitee.com:hantwofish/gazelle_1.git
hantwofish
gazelle_1
gazelle_1
master

搜索帮助