lxcfs/0007-limit-stat-by-quota-period-setting.patch
vegbir 9cae669874 upgrade to 5.0.4
Signed-off-by: vegbir <yangjiaqi16@huawei.com>
2023-07-29 09:15:09 +00:00

51 lines
1.5 KiB
Diff

From a6e4ec48f7ad6e64eb95bcd46e8656f1cef95cfd Mon Sep 17 00:00:00 2001
From: vegbir <yangjiaqi16@huawei.com>
Date: Wed, 12 Jul 2023 08:25:20 +0000
Subject: [PATCH 07/15] limit stat by quota period setting
Signed-off-by: vegbir <yangjiaqi16@huawei.com>
---
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