[Devel] [PATCH RHEL8 COMMIT] ve/cgroup: Get correct VE init css when ve init_task is moved to child cgroup
Konstantin Khorenko
khorenko at virtuozzo.com
Mon May 24 18:31:56 MSK 2021
The commit is pushed to "branch-rh8-4.18.0-240.1.1.vz8.5.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-240.1.1.vz8.5.32
------>
commit 18afce1b24e201005a9d177232d884a2cc5753fb
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date: Mon May 24 18:31:56 2021 +0300
ve/cgroup: Get correct VE init css when ve init_task is moved to child cgroup
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 <ktkhai at virtuozzo.com>
Reviewed-by: Andrey Ryabinin <aryabinin at virtuozzo.com>
======================================================
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 vz7 commit 52d17a28f60d ("ve/cgroup: Get correct VE init css
when ve init_task is moved to child cgroup"))
See also
d51f39b ("cgroup: remove cgroup->parent")
VZ 8 rebase part https://jira.sw.ru/browse/PSBM-127797
Signed-off-by: Alexander Mikhalitsyn <alexander.mikhalitsyn at virtuozzo.com>
khorenko@: in vz8 we've reworked ve_get_init_css() to return css using
ve->ve_ns, but it points to the VE init task's nsproxy (a pointer!),
thus if CT's init task switches a cgroup, we'll get no a top CT css.
So the current patch is still needed.
---
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 ef8fb52936bc..2283e234af5f 100644
--- a/kernel/ve/ve.c
+++ b/kernel/ve/ve.c
@@ -383,7 +383,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;
@@ -395,6 +396,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;
}
More information about the Devel
mailing list