The commit is pushed to "branch-rh9-5.14.vz9.1.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git after rh9-5.14.0-4.vz9.10.1 ------> commit 898abc31593362995e322d2ae021ca9abfc353be Author: Pavel Tikhomirov <ptikhomi...@virtuozzo.com> Date: Wed Oct 13 14:13:31 2021 +0300
cgroup: split cgroup_get_ve_root1 into css and cgroup version In vz8 we had css_local_root, cgroup_get_local_root and cgroup_get_ve_root1 all doing the same thing, let's reuse code. There is no more implicit ve0 fallback here, caller shoudl handle NULL retcode now. Rename cgroup_get_ve_root1 to cgroup_ve_root1. https://jira.sw.ru/browse/PSBM-134002 Signed-off-by: Pavel Tikhomirov <ptikhomi...@virtuozzo.com> --- include/linux/ve.h | 12 ++++++++++-- kernel/cgroup/cgroup.c | 35 ++++++++++++++++++++++++----------- kernel/sched/cpuacct.c | 6 +++--- 3 files changed, 37 insertions(+), 16 deletions(-) diff --git a/include/linux/ve.h b/include/linux/ve.h index e8514c5a0afb..d3499853e6dd 100644 --- a/include/linux/ve.h +++ b/include/linux/ve.h @@ -180,7 +180,9 @@ extern void vtty_release(struct tty_struct *tty, struct tty_struct *o_tty, extern bool vtty_is_master(struct tty_struct *tty); #endif /* CONFIG_TTY */ -extern struct cgroup *cgroup_get_ve_root1(struct cgroup *cgrp); +extern struct cgroup *cgroup_ve_root1(struct cgroup *cgrp); +extern struct cgroup_subsys_state *css_ve_root1( + struct cgroup_subsys_state *css); #define ve_uevent_seqnum (get_exec_env()->_uevent_seqnum) @@ -210,10 +212,16 @@ static inline struct user_namespace *ve_init_user_ns(void) return &init_user_ns; } -static inline struct cgroup *cgroup_get_ve_root1(struct cgroup *cgrp) +static inline struct cgroup *cgroup_ve_root1(struct cgroup *cgrp) { return NULL; } +static inline struct cgroup_subsys_state *css_ve_root1( + struct cgroup_subsys_state *css) +{ + return NULL; +} + #define ve_uevent_seqnum uevent_seqnum static inline int vz_security_family_check(struct net *net, int family, int type) { return 0; } diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c index 06f0906a5ea5..c7435500a352 100644 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c @@ -315,7 +315,7 @@ struct ve_struct *cgroup_ve_owner(struct cgroup *cgrp) struct ve_struct *ve = NULL; struct cgroup *ve_root; - ve_root = cgroup_get_ve_root1(cgrp); + ve_root = cgroup_ve_root1(cgrp); if (ve_root) ve = rcu_dereference(ve_root->ve_owner); return ve; @@ -2020,7 +2020,7 @@ static inline bool ve_check_root_cgroups(struct css_set *cset) return true; /* Nested CGRP_VE_ROOT not allowed */ - if (cgroup_get_ve_root1(link->cgrp)) + if (cgroup_ve_root1(link->cgrp)) return true; } return false; @@ -2094,27 +2094,40 @@ void cgroup_unmark_ve_roots(struct ve_struct *ve) synchronize_rcu(); } -struct cgroup *cgroup_get_ve_root1(struct cgroup *cgrp) +struct cgroup_subsys_state *css_ve_root1(struct cgroup_subsys_state *css) { - struct cgroup *ve_root = NULL; - - do { - if (test_bit(CGRP_VE_ROOT, &cgrp->flags)) { - ve_root = cgrp; + struct cgroup_subsys_state *ve_root = NULL; + /* + * Find css for nearest ancestor cgroup marked with CGRP_VE_ROOT + */ + while (css) { + if (test_bit(CGRP_VE_ROOT, &css->cgroup->flags)) { + ve_root = css; break; } - cgrp = cgroup_parent(cgrp); - } while (cgrp); + css = css->parent; + } return ve_root; } +struct cgroup *cgroup_ve_root1(struct cgroup *cgrp) +{ + struct cgroup_subsys_state *css = &cgrp->self; + + css = css_ve_root1(css); + if (!css) + return NULL; + + return container_of(css, struct cgroup, self); +} + static bool subgroup_limit_reached(struct cgroup *cgroup) { struct cgroup *ve_root; bool ret = false; - ve_root = cgroup_get_ve_root1(cgroup); + ve_root = cgroup_ve_root1(cgroup); if (ve_root && ve_root->subgroups_limit > 0 && ve_root->nr_descendants >= ve_root->subgroups_limit) ret = true; diff --git a/kernel/sched/cpuacct.c b/kernel/sched/cpuacct.c index 489211d78f84..021a0e9cdafa 100644 --- a/kernel/sched/cpuacct.c +++ b/kernel/sched/cpuacct.c @@ -380,13 +380,13 @@ struct cgroup_subsys cpuacct_cgrp_subsys = { extern struct task_group *css_tg(struct cgroup_subsys_state *css); static struct task_group *ve_root_tg(struct task_group *tg) { - struct cgroup *cg; + struct cgroup_subsys_state *css; if (!tg) return NULL; - cg = cgroup_get_ve_root1(tg->css.cgroup); - return cg ? css_tg(&cg->self) : NULL; + css = css_ve_root1(&tg->css); + return css ? css_tg(css) : NULL; } unsigned int tg_cpu_rate(struct task_group *tg) _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel