linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cgroup: fix attach task fail when subtree_control configured
@ 2022-04-08 10:23 zhaoyang.huang
  2022-04-08 17:54 ` Tejun Heo
  0 siblings, 1 reply; 2+ messages in thread
From: zhaoyang.huang @ 2022-04-08 10:23 UTC (permalink / raw)
  To: Tejun Heo, Zefan Li, Johannes Weiner, Zhaoyang Huang,
	linux-kernel, cgroups, ke.wang

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] cgroup: fix attach task fail when subtree_control configured
  2022-04-08 10:23 [PATCH] cgroup: fix attach task fail when subtree_control configured zhaoyang.huang
@ 2022-04-08 17:54 ` Tejun Heo
  0 siblings, 0 replies; 2+ messages in thread
From: Tejun Heo @ 2022-04-08 17:54 UTC (permalink / raw)
  To: zhaoyang.huang
  Cc: Zefan Li, Johannes Weiner, Zhaoyang Huang, linux-kernel, cgroups,
	ke.wang

On Fri, Apr 08, 2022 at 06:23:14PM +0800, zhaoyang.huang wrote:
> 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>

If I'm not misunderstanding, that's the intended behavior. Can you please
take a look at Documentation/admin-guide/cgroup-v2.rst and confirm what
you're trying to do?

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-04-08 17:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-08 10:23 [PATCH] cgroup: fix attach task fail when subtree_control configured zhaoyang.huang
2022-04-08 17:54 ` Tejun Heo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).