[Devel] [PATCH RHEL7 COMMIT] ve/cgroup: implemented per-ve workqueue.

Vasily Averin vvs at virtuozzo.com
Thu Aug 6 08:30:57 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 417a43d91ff92229a4fcfd39c3a86fdf74e77e3d
Author: Valeriy Vdovin <valeriy.vdovin at virtuozzo.com>
Date:   Thu Aug 6 08:30:56 2020 +0300

    ve/cgroup: implemented per-ve workqueue.
    
    Signed-off-by: Valeriy Vdovin <valeriy.vdovin at virtuozzo.com>
    
    Reviewed-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 include/linux/ve.h |  2 ++
 kernel/ve/ve.c     | 25 +++++++++++++++++++++++++
 2 files changed, 27 insertions(+)

diff --git a/include/linux/ve.h b/include/linux/ve.h
index 088e274..3640947 100644
--- a/include/linux/ve.h
+++ b/include/linux/ve.h
@@ -125,6 +125,8 @@ struct ve_struct {
 	struct cn_private	*cn;
 #endif
 	struct kmapset_key	sysfs_perms_key;
+
+	struct workqueue_struct	*wq;
 };
 
 struct ve_devmnt {
diff --git a/kernel/ve/ve.c b/kernel/ve/ve.c
index f88452d..236304a 100644
--- a/kernel/ve/ve.c
+++ b/kernel/ve/ve.c
@@ -486,6 +486,21 @@ static const struct timespec zero_time = { };
 
 extern void cgroup_mark_ve_root(struct ve_struct *ve);
 
+static int ve_workqueue_start(struct ve_struct *ve)
+{
+	ve->wq = alloc_workqueue("ve_wq_%s",
+		WQ_SYSFS|WQ_FREEZABLE|WQ_UNBOUND, 8, ve->ve_name);
+
+	if (!ve->wq)
+		return -ENOMEM;
+	return 0;
+}
+
+static void ve_workqueue_stop(struct ve_struct *ve)
+{
+	destroy_workqueue(ve->wq);
+}
+
 /* under ve->op_sem write-lock */
 static int ve_start_container(struct ve_struct *ve)
 {
@@ -529,6 +544,10 @@ static int ve_start_container(struct ve_struct *ve)
 	if (err)
 		goto err_umh;
 
+	err = ve_workqueue_start(ve);
+	if (err)
+		goto err_workqueue;
+
 	err = ve_hook_iterate_init(VE_SS_CHAIN, ve);
 	if (err < 0)
 		goto err_iterate;
@@ -544,6 +563,8 @@ static int ve_start_container(struct ve_struct *ve)
 	return 0;
 
 err_iterate:
+	ve_workqueue_stop(ve);
+err_workqueue:
 	ve_stop_umh(ve);
 err_umh:
 	ve_stop_kthread(ve);
@@ -600,6 +621,8 @@ void ve_exit_ns(struct pid_namespace *pid_ns)
 	if (!ve->ve_ns || ve->ve_ns->pid_ns != pid_ns)
 		return;
 
+	ve_workqueue_stop(ve);
+
 	/*
 	 * At this point all userspace tasks in container are dead.
 	 */
@@ -1655,6 +1678,8 @@ static int __init ve_subsys_init(void)
 {
 	ve_cachep = KMEM_CACHE(ve_struct, SLAB_PANIC);
 	list_add(&ve0.ve_list, &ve_list_head);
+	ve0.wq = alloc_workqueue("ve0_wq", WQ_FREEZABLE|WQ_UNBOUND, 8);
+	BUG_ON(!ve0.wq);
 	return 0;
 }
 late_initcall(ve_subsys_init);


More information about the Devel mailing list