1 Star 0 Fork 9

wuzx/lxcfs

forked from src-openEuler/lxcfs 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0007-limit-stat-by-quota-period-setting.patch 1.47 KB
一键复制 编辑 原始数据 按行查看 历史
vegbir 提交于 2023-07-27 09:31 . upgrade to 5.0.4
From a6e4ec48f7ad6e64eb95bcd46e8656f1cef95cfd Mon Sep 17 00:00:00 2001
From: vegbir <[email protected]>
Date: Wed, 12 Jul 2023 08:25:20 +0000
Subject: [PATCH 07/15] limit stat by quota period setting
Signed-off-by: vegbir <[email protected]>
---
src/proc_fuse.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/src/proc_fuse.c b/src/proc_fuse.c
index 0af559f..e69e867 100644
--- a/src/proc_fuse.c
+++ b/src/proc_fuse.c
@@ -1087,6 +1087,8 @@ static int proc_stat_read(char *buf, size_t size, off_t offset,
size_t linelen = 0, total_len = 0;
int curcpu = -1; /* cpu numbering starts at 0 */
int physcpu = 0;
+ int max_cpus = 0;
+ bool use_view;
uint64_t user = 0, nice = 0, system = 0, idle = 0, iowait = 0, irq = 0,
softirq = 0, steal = 0, guest = 0, guest_nice = 0;
uint64_t user_sum = 0, nice_sum = 0, system_sum = 0, idle_sum = 0,
@@ -1138,6 +1140,13 @@ static int proc_stat_read(char *buf, size_t size, off_t offset,
if (!cpuset)
return 0;
+ if (cgroup_ops->can_use_cpuview(cgroup_ops) && opts && opts->use_cfs)
+ use_view = true;
+ else
+ use_view = false;
+ if (use_view)
+ max_cpus = max_cpu_count(cg, cpu_cg);
+
f = fopen_cached("/proc/stat", "re", &fopen_cache);
if (!f)
return 0;
@@ -1186,6 +1195,9 @@ static int proc_stat_read(char *buf, size_t size, off_t offset,
continue;
}
+ if (use_view && max_cpus > 0 && (curcpu + 1) == max_cpus)
+ continue;
+
if (sscanf(cpu_char, "%d", &physcpu) != 1)
continue;
--
2.41.0
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wuzx065891/lxcfs.git
[email protected]:wuzx065891/lxcfs.git
wuzx065891
lxcfs
lxcfs
master

搜索帮助