[Devel] [PATCH RHEL8 COMMIT] ve/cgroup: Unmark ve-root cgroups at Container stop

Konstantin Khorenko khorenko at virtuozzo.com
Thu Jan 28 12:04:25 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.5
------>
commit eb1382872c59700876c558bddf3c056028b384d5
Author: Valeriy Vdovin <valeriy.vdovin at virtuozzo.com>
Date:   Thu Jan 28 12:04:25 2021 +0300

    ve/cgroup: Unmark ve-root cgroups at Container stop
    
    To_merge: 3a90ea5cf85a ("cgroup: Mark cgroup CGRP_VE_ROOT")
    
    Signed-off-by: Valeriy Vdovin <valeriy.vdovin at virtuozzo.com>
    Reviewed-by: Kirill Tkhai <ktkhai at virtuozzo.com>
    
    Cherry-picked from vz7 commit
    5dceccf5dd79 "(ve/cgroup: unmark ve-root cgroups at container stop)"
    
    Signed-off-by: Valeriy Vdovin <valeriy.vdovin at virtuozzo.com>
---
 include/linux/cgroup.h |  1 +
 kernel/cgroup/cgroup.c | 23 +++++++++++++++++++++++
 kernel/ve/ve.c         |  3 +++
 3 files changed, 27 insertions(+)

diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
index 4f0dd51338bf..c0a42c3d43fa 100644
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -867,6 +867,7 @@ int cgroup_path_ns(struct cgroup *cgrp, char *buf, size_t buflen,
 
 #ifdef CONFIG_VE
 extern void cgroup_mark_ve_root(struct ve_struct *ve);
+void cgroup_unmark_ve_roots(struct ve_struct *ve);
 #endif
 
 #else /* !CONFIG_CGROUPS */
diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index 0335a07f64e6..b71d4ccb2f0c 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -1908,6 +1908,29 @@ void cgroup_mark_ve_root(struct ve_struct *ve)
 	spin_unlock_irq(&css_set_lock);
 }
 
+void cgroup_unmark_ve_roots(struct ve_struct *ve)
+{
+	struct cgrp_cset_link *link;
+	struct css_set *cset;
+	struct cgroup *cgrp;
+
+	spin_lock_irq(&css_set_lock);
+
+	rcu_read_lock();
+	cset = rcu_dereference(ve->ve_ns)->cgroup_ns->root_cset;
+	if (WARN_ON(!cset))
+		goto unlock;
+
+	list_for_each_entry(link, &cset->cgrp_links, cgrp_link) {
+		cgrp = link->cgrp;
+		clear_bit(CGRP_VE_ROOT, &cgrp->flags);
+	}
+unlock:
+	rcu_read_unlock();
+
+	spin_unlock_irq(&css_set_lock);
+}
+
 struct cgroup *cgroup_get_ve_root1(struct cgroup *cgrp)
 {
 	struct cgroup *ve_root = NULL;
diff --git a/kernel/ve/ve.c b/kernel/ve/ve.c
index b83b2b66a875..f7d605357d2e 100644
--- a/kernel/ve/ve.c
+++ b/kernel/ve/ve.c
@@ -520,6 +520,9 @@ void ve_exit_ns(struct pid_namespace *pid_ns)
 	 */
 	if (!ve_ns || ve_ns->pid_ns_for_children != pid_ns)
 		goto unlock;
+
+	cgroup_unmark_ve_roots(ve);
+
 	/*
 	 * At this point all userspace tasks in container are dead.
 	 */


More information about the Devel mailing list