[Devel] [PATCH VZ8 v0 04/14] ve/cgroup: implemented per-ve workqueue.
Valeriy Vdovin
valeriy.vdovin at virtuozzo.com
Tue Jan 19 21:01:44 MSK 2021
Signed-off-by: Valeriy Vdovin <valeriy.vdovin at virtuozzo.com>
Reviewed-by: Kirill Tkhai <ktkhai at virtuozzo.com>
(Cherry-picked from 0293870666c4f96bd56f612d94f560626c76e2fd)
Signed-off-by: Valeriy Vdovin <valeriy.vdovin 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 ab8da4dceec1..2c45f47b9f92 100644
--- a/include/linux/ve.h
+++ b/include/linux/ve.h
@@ -99,6 +99,8 @@ struct ve_struct {
struct list_head devmnt_list;
struct mutex devmnt_mutex;
+
+ struct workqueue_struct *wq;
};
struct ve_devmnt {
diff --git a/kernel/ve/ve.c b/kernel/ve/ve.c
index b922653acf49..7eaf787f3a3d 100644
--- a/kernel/ve/ve.c
+++ b/kernel/ve/ve.c
@@ -387,6 +387,21 @@ static void ve_set_vdso_time(struct ve_struct *ve, u64 time)
*vdso_start_time = time;
}
+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)
{
@@ -442,6 +457,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;
@@ -457,6 +476,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_kthreadd(ve);
@@ -522,6 +543,8 @@ void ve_exit_ns(struct pid_namespace *pid_ns)
cgroup_unmark_ve_roots(ve);
+ ve_workqueue_stop(ve);
+
/*
* At this point all userspace tasks in container are dead.
*/
@@ -1354,6 +1377,8 @@ static int __init ve_subsys_init(void)
{
ve_cachep = KMEM_CACHE_USERCOPY(ve_struct, SLAB_PANIC, core_pattern);
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);
--
2.27.0
More information about the Devel
mailing list