[Devel] [PATCH RHEL7 COMMIT] ve/cgroup: saving root_css to ve

Vasily Averin vvs at virtuozzo.com
Thu Aug 6 08:31:25 MSK 2020


The commit is pushed to "branch-rh7-3.10.0-1127.18.2.vz7.163.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1127.18.2.el7
------>
commit 84d2044ee5cd4d275e80b21b3c60c05ad457d58a
Author: Valeriy Vdovin <valeriy.vdovin at virtuozzo.com>
Date:   Thu Aug 6 08:31:24 2020 +0300

    ve/cgroup: saving root_css to ve
    
    Signed-off-by: Valeriy Vdovin <valeriy.vdovin at virtuozzo.com>
    
    Reviewed-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 include/linux/ve.h | 7 +++++++
 kernel/ve/ve.c     | 6 +++++-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/include/linux/ve.h b/include/linux/ve.h
index 3640947..542fd08 100644
--- a/include/linux/ve.h
+++ b/include/linux/ve.h
@@ -127,6 +127,13 @@ struct ve_struct {
 	struct kmapset_key	sysfs_perms_key;
 
 	struct workqueue_struct	*wq;
+
+	/*
+	 * All tasks, that belong to this ve, live
+	 * in cgroups, that are children to cgroups
+	 * that form this css_set.
+	 */
+	struct css_set		*root_css_set;
 };
 
 struct ve_devmnt {
diff --git a/kernel/ve/ve.c b/kernel/ve/ve.c
index 32c9598..73cfee6 100644
--- a/kernel/ve/ve.c
+++ b/kernel/ve/ve.c
@@ -453,6 +453,8 @@ static void ve_grab_context(struct ve_struct *ve)
 
 	get_task_struct(tsk);
 	ve->init_task = tsk;
+	ve->root_css_set = tsk->cgroups;
+	get_css_set(ve->root_css_set);
 	ve->init_cred = (struct cred *)get_current_cred();
 	rcu_assign_pointer(ve->ve_ns, get_nsproxy(tsk->nsproxy));
 	ve->ve_netns =  get_net(ve->ve_ns->net_ns);
@@ -464,6 +466,9 @@ static void ve_drop_context(struct ve_struct *ve)
 	struct nsproxy *ve_ns = ve->ve_ns;
 	struct net *net = ve->ve_netns;
 
+	put_css_set_taskexit(ve->root_css_set);
+	ve->root_css_set = NULL;
+
 	ve->ve_netns = NULL;
 	put_net(net);
 
@@ -479,7 +484,6 @@ static void ve_drop_context(struct ve_struct *ve)
 
 	put_task_struct(ve->init_task);
 	ve->init_task = NULL;
-
 }
 
 static const struct timespec zero_time = { };


More information about the Devel mailing list