1 Star 0 Fork 7

wangkang101 / lxcfs

forked from src-openEuler / lxcfs 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0009-limit-stat-by-quota-period-setting.patch 1.13 KB
一键复制 编辑 原始数据 按行查看 历史
wangkang101 提交于 2020-08-28 15:17 . update to 4.0.5
diff --git a/src/proc_fuse.c b/src/proc_fuse.c
index 3ceba73..5162a3b 100644
--- a/src/proc_fuse.c
+++ b/src/proc_fuse.c
@@ -910,6 +910,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,
@@ -958,6 +960,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);
+
f = fopen_cached("/proc/stat", "re", &fopen_cache);
if (!f)
return 0;
@@ -1006,6 +1015,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;
1
https://gitee.com/wangkang101/lxcfs.git
git@gitee.com:wangkang101/lxcfs.git
wangkang101
lxcfs
lxcfs
master

搜索帮助