From: Kirill Tkhai <[email protected]>

Init task of container can be moved to any child cgroup.
But ve_get_init_css() remains to return its cgroup as
top of container. Fix that by finding of real top cgroup
among init_task cgroup parents.

https://jira.sw.ru/browse/PSBM-81572

Signed-off-by: Kirill Tkhai <[email protected]>
Reviewed-by: Andrey Ryabinin <[email protected]>

======================================================
Patchset description:
sched/ve: Fix wrong loadavg accounting inside CT

Three problems are fixed here:

1)Tasks from child task groups are not propagated in CT's loadavg
2)Loadavg of CT's init task cgroup is returned as CT's loadavg,
  while init task may be in child task group.
3)In calc_load_ve() (from interrupt) we count loadavg for all cpu
  cgroups, which is slow and unneed.

The patchset fixes all of them.

https://jira.sw.ru/browse/PSBM-81572

Kirill Tkhai (5):
      ve/cgroup: Get correct VE init css when ve init_task is moved to child 
cgroup
      sched/ve: Link VE root cpu cgroups in separate list
      sched/ve: Do not show loadavg in child VE cpu cgroups
      sched/ve: Iterate only VE root cpu cgroups to count loadavg
      sched/ve: Use cfs_rq::h_nr_running to count loadavg

(cherry picked from commit 52d17a28f60d446da2159d486fbbedc197061a91)

See also
d51f39b ("cgroup: remove cgroup->parent")

VZ 8 rebase part https://jira.sw.ru/browse/PSBM-127797

Signed-off-by: Alexander Mikhalitsyn <[email protected]>
---
 kernel/ve/ve.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/kernel/ve/ve.c b/kernel/ve/ve.c
index db548c6d1c4b..3246ee43245e 100644
--- a/kernel/ve/ve.c
+++ b/kernel/ve/ve.c
@@ -330,7 +330,8 @@ const char *ve_get_release_agent_path(struct ve_struct *ve,
 
 struct cgroup_subsys_state *ve_get_init_css(struct ve_struct *ve, int 
subsys_id)
 {
-       struct cgroup_subsys_state *css;
+       struct cgroup_subsys_state *css, *tmp;
+       struct cgroup *cgroup;
        struct css_set *root_cset;
        struct nsproxy *nsproxy;
 
@@ -342,6 +343,17 @@ struct cgroup_subsys_state *ve_get_init_css(struct 
ve_struct *ve, int subsys_id)
        /* nsproxy->cgroup_ns must hold root_cset refcnt */
        BUG_ON(!css_tryget(css));
 
+       cgroup = css->cgroup;
+       while (!test_bit(CGRP_VE_ROOT, &cgroup->flags) && cgroup_parent(cgroup))
+               cgroup = cgroup_parent(cgroup);
+
+       if (cgroup != css->cgroup) {
+               tmp = cgroup->subsys[subsys_id];
+               css_get(tmp);
+               css_put(css);
+               css = tmp;
+       }
+
        rcu_read_unlock();
        return css;
 }
-- 
2.28.0

_______________________________________________
Devel mailing list
[email protected]
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to