[Devel] [PATCH 1/2 RH8] kernel/cgroup: implement cgroup_get_e_ve_css
Andrey Zhadchenko
andrey.zhadchenko at virtuozzo.com
Tue Jul 6 20:53:30 MSK 2021
Existing cgroup_get_e_css() is not suited for cgroup-v1 and will always
return root cgroup css. Implement new cgroup_get_e_ve_css to return
ve css.
https://jira.sw.ru/browse/PSBM-131253
Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko at virtuozzo.com>
---
include/linux/cgroup.h | 2 ++
kernel/cgroup/cgroup.c | 29 +++++++++++++++++++++++++++++
2 files changed, 31 insertions(+)
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
index 7cf6e1e..77d1ba7 100644
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -876,6 +876,8 @@ int cgroup_path_ns(struct cgroup *cgrp, char *buf, size_t buflen,
void cgroup_unmark_ve_roots(struct ve_struct *ve);
struct cgroup_subsys_state *css_get_local_root(struct cgroup_subsys_state *css);
struct ve_struct *cgroup_get_ve_owner(struct cgroup *cgrp);
+struct cgroup_subsys_state *cgroup_get_e_ve_css(struct cgroup *cgrp,
+ struct cgroup_subsys *ss);
#endif
#else /* !CONFIG_CGROUPS */
diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index 1bc15fb..ead3825 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -656,6 +656,35 @@ struct cgroup_subsys_state *cgroup_get_e_css(struct cgroup *cgrp,
return css;
}
+#ifdef CONFIG_VE
+struct cgroup_subsys_state *cgroup_get_e_ve_css(struct cgroup *cgrp,
+ struct cgroup_subsys *ss)
+{
+ struct cgroup_subsys_state *css;
+ struct css_set *cset;
+ struct ve_struct *ve;
+
+ rcu_read_lock();
+
+ do {
+ if (test_bit(CGRP_VE_ROOT, &cgrp->flags)) {
+ ve = rcu_dereference(cgrp->ve_owner);
+ cset = rcu_dereference(ve->ve_ns)->cgroup_ns->root_cset;
+ goto cset_found;
+ }
+ cgrp = cgroup_parent(cgrp);
+ } while (cgrp);
+
+ cset = &init_css_set;
+cset_found:
+ css = cset->subsys[ss->id];
+ css_get(css);
+
+ rcu_read_unlock();
+ return css;
+}
+#endif
+
static void cgroup_get_live(struct cgroup *cgrp)
{
WARN_ON_ONCE(cgroup_is_dead(cgrp));
--
1.8.3.1
More information about the Devel
mailing list