[RHEL7,COMMIT] sched/ve: Use cfs_rq::h_nr_running to count loadavg

Submitted by Konstantin Khorenko on Feb. 27, 2018, 12:28 p.m.

Details

Message ID 201802271228.w1RCSUde014720@finist_ce7.work
State New
Series "Fix wrong loadavg accounting inside CT"
Headers show

Commit Message

Konstantin Khorenko Feb. 27, 2018, 12:28 p.m.
The commit is pushed to "branch-rh7-3.10.0-693.17.1.vz7.45.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-693.17.1.vz7.45.4
------>
commit 9bdbf2ea8a27b0a9fd64b0408082c3ca26fe60a8
Author: Kirill Tkhai <ktkhai@virtuozzo.com>
Date:   Tue Feb 27 15:28:30 2018 +0300

    sched/ve: Use cfs_rq::h_nr_running to count loadavg
    
    cfs_rq::nr_running contains number of child entities
    of one level below: tasks and cfs_rq, but it does not
    contain tasks from deeper levels.
    
    Use cfs_rq::h_nr_running instead as it contains number
    of tasks among all child hierarchy.
    
    https://jira.sw.ru/browse/PSBM-81572
    
    Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
    Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
---
 kernel/sched/core.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index f93334fd0229..f14bbf5c8ed6 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -2894,7 +2894,13 @@  static void calc_load_ve(void)
 		nr_active = 0;
 		for_each_possible_cpu(i) {
 #ifdef CONFIG_FAIR_GROUP_SCHED
-			nr_active += tg->cfs_rq[i]->nr_running;
+			nr_active += tg->cfs_rq[i]->h_nr_running;
+			/*
+                         * We do not export nr_unint to parent task groups
+                         * like we do for h_nr_running, as it gives additional
+                         * overhead for activate/deactivate operations. So, we
+			 * don't account child cgroup unint tasks here.
+                         */
 			nr_active += tg->cfs_rq[i]->nr_unint;
 #endif
 		}