登录
注册
开源
企业版
高校版
搜索
帮助中心
使用条款
关于我们
开源
企业版
高校版
私有云
模力方舟
AI 队友
登录
注册
Gitee 2025年度开源项目评选启动,快来选出你心中的最佳开源项目!
代码拉取完成,页面将自动刷新
捐赠
捐赠前请先登录
取消
前往登录
扫描微信二维码支付
取消
支付完成
支付提示
将跳转至支付宝完成支付
确定
取消
Watch
不关注
关注所有动态
仅关注版本发行动态
关注但不提醒动态
18
Star
81
Fork
132
openEuler
/
gala-gopher
代码
Issues
11
Pull Requests
3
Wiki
统计
流水线
服务
JavaDoc
PHPDoc
质量分析
Jenkins for Gitee
腾讯云托管
腾讯云 Serverless
悬镜安全
阿里云 SAE
Codeblitz
SBOM
我知道了,不再自动展开
更新失败,请稍后重试!
移除标识
内容风险标识
本任务被
标识为内容中包含有代码安全 Bug 、隐私泄露等敏感信息,仓库外成员不可访问
探针内多处使用bpf_buffer__open可能导致fd资源耗尽
已挂起
#I9K9IY
缺陷
algorithmofdish
创建于
2024-04-28 11:14
**问题描述** 当gopher探针包含多个子探针,且每个子探针都会调用bpf_buffer__open初始化ebpf event buffer时,若目标机器的cpu数量比较多且内核版本只支持perf buffer(5.8内核以上才支持ring buffer)时,探针启动时会出现fd资源耗尽导致探针启动失败的问题。 下图是tprofiling探针启动时fd资源占用情况,可以看到随着启动的子探针数量增加,perf-event类型的fd数量每次都会增加192个,当超过上限(一般都是配置的1024)时,fd资源就会耗尽。 ```bash (base) [root@localhost ]# uname -r 4.19.90-2107.6.0.0098.oe1.bclinux.aarch64 (base) [root@localhost ]# lscpu | grep CPU: CPU: 192 (base) [root@localhost ]# curl -X PUT http://localhost:9999/tprofiling -d json='{"cmd":{"probe": ["python_gc"]}, "snoopers":{"proc_name": [{"comm":"python3", "cmdline":"pygc"}, {"comm":"python3", "cmdline":"write-big-file"}]},"params":{"report_period":10}, "state": "running"}' { "result": "success", "message":"New config takes effect" } (base) [root@localhost ]# sh ./test-tp-fdnum.sh `pidof tprofiling` pid=1538597, total fd nums: 233, pipe fd nums: 1, anon_inode fd nums: 227 anon_inode detail: bpf-prog=2, bpf-map=26, perf-event=192, eventpoll=3 (base) [root@localhost ]# (base) [root@localhost ]# curl -X PUT http://localhost:9999/tprofiling -d json='{"cmd":{"probe": ["python_gc", "oncpu"]}, "snoopers":{"proc_name": [{"comm":"python3", "cmdline":"pygc"}, {"comm":"python3", "cmdline":"write-big-file"}]},"params":{"report_period":10}, "state": "running"}' { "result": "success", "message":"New config takes effect" } (base) [root@localhost ]# sh ./test-tp-fdnum.sh `pidof tprofiling` pid=1538597, total fd nums: 441, pipe fd nums: 1, anon_inode fd nums: 435 anon_inode detail: bpf-prog=3, bpf-map=39, perf-event=385, eventpoll=4 (base) [root@localhost ]# (base) [root@localhost ]# curl -X PUT http://localhost:9999/tprofiling -d json='{"cmd":{"probe": ["python_gc", "oncpu", "syscall_file"]}, "snoopers":{"proc_name": [{"comm":"python3", "cmdline":"pygc"}, {"comm":"python3", "cmdline":"write-big-file"}]},"params":{"report_period":10}, "state": "running"}' { "result": "success", "message":"New config takes effect" } (base) [root@localhost ]# sh ./test-tp-fdnum.sh `pidof tprofiling` pid=1538597, total fd nums: 692, pipe fd nums: 1, anon_inode fd nums: 686 anon_inode detail: bpf-prog=23, bpf-map=57, perf-event=597, eventpoll=5 (base) [root@localhost ]# (base) [root@localhost ]# curl -X PUT http://localhost:9999/tprofiling -d json='{"cmd":{"probe": ["python_gc", "oncpu", "syscall_file", "syscall_net"]}, "snoopers":{"proc_name": [{"comm":"python3", "cmdline":"pygc"}, {"comm":"python3", "cmdline":"write-big-file"}]},"params":{"report_period":10}, "state": "running"}' { "result": "success", "message":"New config takes effect" } (base) [root@localhost ]# sh ./test-tp-fdnum.sh `pidof tprofiling` pid=1538597, total fd nums: 927, pipe fd nums: 1, anon_inode fd nums: 921 anon_inode detail: bpf-prog=35, bpf-map=75, perf-event=801, eventpoll=6 ``` **问题根因** 每个子探针调用bpf_buffer__open初始化ebpf event buffer时,如果当前内核版本不支持ring buffer,则会创建perf buffer类型的buffer,每创建一个perf buffer结构,都会打开`cpu数量`个perf-event类型的fd。当cpu数量比较多时,fd会增长很快。 **问题排查** 经查询,当前gopher还有多个探针存在该问题,可考虑优化。  **优化建议** 多个子探针共享同一个ebpf event buffer结构。
**问题描述** 当gopher探针包含多个子探针,且每个子探针都会调用bpf_buffer__open初始化ebpf event buffer时,若目标机器的cpu数量比较多且内核版本只支持perf buffer(5.8内核以上才支持ring buffer)时,探针启动时会出现fd资源耗尽导致探针启动失败的问题。 下图是tprofiling探针启动时fd资源占用情况,可以看到随着启动的子探针数量增加,perf-event类型的fd数量每次都会增加192个,当超过上限(一般都是配置的1024)时,fd资源就会耗尽。 ```bash (base) [root@localhost ]# uname -r 4.19.90-2107.6.0.0098.oe1.bclinux.aarch64 (base) [root@localhost ]# lscpu | grep CPU: CPU: 192 (base) [root@localhost ]# curl -X PUT http://localhost:9999/tprofiling -d json='{"cmd":{"probe": ["python_gc"]}, "snoopers":{"proc_name": [{"comm":"python3", "cmdline":"pygc"}, {"comm":"python3", "cmdline":"write-big-file"}]},"params":{"report_period":10}, "state": "running"}' { "result": "success", "message":"New config takes effect" } (base) [root@localhost ]# sh ./test-tp-fdnum.sh `pidof tprofiling` pid=1538597, total fd nums: 233, pipe fd nums: 1, anon_inode fd nums: 227 anon_inode detail: bpf-prog=2, bpf-map=26, perf-event=192, eventpoll=3 (base) [root@localhost ]# (base) [root@localhost ]# curl -X PUT http://localhost:9999/tprofiling -d json='{"cmd":{"probe": ["python_gc", "oncpu"]}, "snoopers":{"proc_name": [{"comm":"python3", "cmdline":"pygc"}, {"comm":"python3", "cmdline":"write-big-file"}]},"params":{"report_period":10}, "state": "running"}' { "result": "success", "message":"New config takes effect" } (base) [root@localhost ]# sh ./test-tp-fdnum.sh `pidof tprofiling` pid=1538597, total fd nums: 441, pipe fd nums: 1, anon_inode fd nums: 435 anon_inode detail: bpf-prog=3, bpf-map=39, perf-event=385, eventpoll=4 (base) [root@localhost ]# (base) [root@localhost ]# curl -X PUT http://localhost:9999/tprofiling -d json='{"cmd":{"probe": ["python_gc", "oncpu", "syscall_file"]}, "snoopers":{"proc_name": [{"comm":"python3", "cmdline":"pygc"}, {"comm":"python3", "cmdline":"write-big-file"}]},"params":{"report_period":10}, "state": "running"}' { "result": "success", "message":"New config takes effect" } (base) [root@localhost ]# sh ./test-tp-fdnum.sh `pidof tprofiling` pid=1538597, total fd nums: 692, pipe fd nums: 1, anon_inode fd nums: 686 anon_inode detail: bpf-prog=23, bpf-map=57, perf-event=597, eventpoll=5 (base) [root@localhost ]# (base) [root@localhost ]# curl -X PUT http://localhost:9999/tprofiling -d json='{"cmd":{"probe": ["python_gc", "oncpu", "syscall_file", "syscall_net"]}, "snoopers":{"proc_name": [{"comm":"python3", "cmdline":"pygc"}, {"comm":"python3", "cmdline":"write-big-file"}]},"params":{"report_period":10}, "state": "running"}' { "result": "success", "message":"New config takes effect" } (base) [root@localhost ]# sh ./test-tp-fdnum.sh `pidof tprofiling` pid=1538597, total fd nums: 927, pipe fd nums: 1, anon_inode fd nums: 921 anon_inode detail: bpf-prog=35, bpf-map=75, perf-event=801, eventpoll=6 ``` **问题根因** 每个子探针调用bpf_buffer__open初始化ebpf event buffer时,如果当前内核版本不支持ring buffer,则会创建perf buffer类型的buffer,每创建一个perf buffer结构,都会打开`cpu数量`个perf-event类型的fd。当cpu数量比较多时,fd会增长很快。 **问题排查** 经查询,当前gopher还有多个探针存在该问题,可考虑优化。  **优化建议** 多个子探针共享同一个ebpf event buffer结构。
评论 (
2
)
登录
后才可以发表评论
状态
已挂起
待办的
已挂起
修复中
已确认
已完成
已验收
已取消
负责人
未设置
标签
sig/sig-ebpf
未设置
项目
未立项任务
未立项任务
里程碑
未关联里程碑
未关联里程碑
Pull Requests
未关联
未关联
关联的 Pull Requests 被合并后可能会关闭此 issue
分支
未关联
分支 (6)
标签 (9)
master
systrace
dev_meituan
dev
demo
dev-core
2.0.2
2.0.2-beta
2.0.1
1.0.3
2.0.0
1.0.2
1.0.1
1.0.0
v1.0.0
开始日期   -   截止日期
-
置顶选项
不置顶
置顶等级:高
置顶等级:中
置顶等级:低
优先级
不指定
严重
主要
次要
不重要
预计工期
(小时)
参与者(1)
1
https://gitee.com/openeuler/gala-gopher.git
[email protected]
:openeuler/gala-gopher.git
openeuler
gala-gopher
gala-gopher
点此查找更多帮助
搜索帮助
Git 命令在线学习
如何在 Gitee 导入 GitHub 仓库
Git 仓库基础操作
企业版和社区版功能对比
SSH 公钥设置
如何处理代码冲突
仓库体积过大,如何减小?
如何找回被删除的仓库数据
Gitee 产品配额说明
GitHub仓库快速导入Gitee及同步更新
什么是 Release(发行版)
将 PHP 项目自动发布到 packagist.org
仓库举报
回到顶部
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册