lkml.org 
[lkml]   [2022]   [Apr]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] cgroup: fix attach task fail when subtree_control configured
Date
From: Zhaoyang Huang <zhaoyang.huang@unisoc.com>

It is found that task attach to a vacant cgroup will fail when its
subtree_control has been configured. Fix it by judging if there is no chrildren
existed.

Signed-off-by: Zhaoyang Huang <zhaoyang.huang@unisoc.com>
---
kernel/cgroup/cgroup.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index 919194d..f00583b 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -2561,6 +2561,9 @@ static int cgroup_migrate_execute(struct cgroup_mgctx *mgctx)
*/
int cgroup_migrate_vet_dst(struct cgroup *dst_cgrp)
{
+ struct cgroup_subsys_state *css = &dst_cgrp->self;
+ struct list_head *children = &css->children;
+
/* v1 doesn't have any restriction */
if (!cgroup_on_dfl(dst_cgrp))
return 0;
@@ -2581,7 +2584,7 @@ int cgroup_migrate_vet_dst(struct cgroup *dst_cgrp)
return 0;

/* apply no-internal-process constraint */
- if (dst_cgrp->subtree_control)
+ if (dst_cgrp->subtree_control && !list_empty(children))
return -EBUSY;

return 0;
--
1.9.1
\
 
 \ /
  Last update: 2022-04-08 12:25    [W:0.026 / U:0.076 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site