]> git.proxmox.com Git - mirror_lxcfs.git/commitdiff
Skip cpu revise when cfs quota is disable
authorNguyen Phan Huy <phanhuy1502@gmail.com>
Tue, 9 Nov 2021 10:58:28 +0000 (18:58 +0800)
committerNguyen Phan Huy <nguyenph@sea.com>
Tue, 9 Nov 2021 11:00:47 +0000 (19:00 +0800)
Signed-off-by: Nguyen Phan Huy <phanhuy1502@gmail.com>
src/proc_cpuview.c

index 472d69dff40792d477d805626452f26b01e15c67..b6ffd29aeabf362ace6e632429a0fa01c48c387e 100644 (file)
@@ -451,6 +451,19 @@ static double exact_cpu_count(const char *cg)
        return rv;
 }
 
+/*
+ * Return true if cfs quota of the cgroup is neg / not set
+ */
+static bool cfs_quota_disabled(const char *cg)
+{
+       int64_t cfs_quota;
+
+       if (!read_cpu_cfs_param(cg, "quota", &cfs_quota))
+               return true;
+
+       return cfs_quota < 0;
+}
+
 /*
  * Return the maximum number of visible CPUs based on CPU quotas.
  * If there is no quota set, zero is returned.
@@ -705,7 +718,9 @@ int cpuview_proc_stat(const char *cg, const char *cpuset,
 
                /* revise cpu usage view to support partial cpu case. */
                exact_cpus = exact_cpu_count(cg);
-               if (exact_cpus < (double)max_cpus){
+
+               /* skip revise cpu when cfs quota is disabled (exact_cpus == 0) */
+               if (!cfs_quota_disabled(cg) && exact_cpus < (double)max_cpus){
                        uint64_t delta = (uint64_t)((double)(diff_user + diff_system + diff_idle) * (1 - exact_cpus / (double)max_cpus));
 
                        lxcfs_v("revising cpu usage view to match the exact cpu count [%f]\n", exact_cpus);