public inbox for cgroups@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cgroup: Simplify code in css_set_move_task
@ 2022-10-20  7:47 haifeng.xu
       [not found] ` <20221020074701.84326-1-haifeng.xu-LL2PKPoSiP3QT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: haifeng.xu @ 2022-10-20  7:47 UTC (permalink / raw)
  To: tj-DgEjT+Ai2ygdnm+yROfE0A
  Cc: lizefan.x-EC8Uxl6Npydl57MIdRCFDg, hannes-druUgvl0LCNAfugRpC6u6w,
	cgroups-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, haifeng.xu

Check the populated state of css_set in css_set_update_populated
and update the populated state of to_cset after from_cset is updated.

Signed-off-by: haifeng.xu <haifeng.xu-LL2PKPoSiP3QT0dZR+AlfA@public.gmane.org>
---
 kernel/cgroup/cgroup.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index d922773fa90b..6c474be57f91 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -861,7 +861,8 @@ static void css_set_update_populated(struct css_set *cset, bool populated)
 {
 	struct cgrp_cset_link *link;
 
-	lockdep_assert_held(&css_set_lock);
+	if (!cset || css_set_populated(cset))
+		return;
 
 	list_for_each_entry(link, &cset->cgrp_links, cgrp_link)
 		cgroup_update_populated(link->cgrp, populated);
@@ -903,16 +904,12 @@ static void css_set_move_task(struct task_struct *task,
 {
 	lockdep_assert_held(&css_set_lock);
 
-	if (to_cset && !css_set_populated(to_cset))
-		css_set_update_populated(to_cset, true);
-
 	if (from_cset) {
 		WARN_ON_ONCE(list_empty(&task->cg_list));
 
 		css_set_skip_task_iters(from_cset, task);
 		list_del_init(&task->cg_list);
-		if (!css_set_populated(from_cset))
-			css_set_update_populated(from_cset, false);
+		css_set_update_populated(from_cset, false);
 	} else {
 		WARN_ON_ONCE(!list_empty(&task->cg_list));
 	}
@@ -926,6 +923,7 @@ static void css_set_move_task(struct task_struct *task,
 		WARN_ON_ONCE(task->flags & PF_EXITING);
 
 		cgroup_move_task(task, to_cset);
+		css_set_update_populated(to_cset, true);
 		list_add_tail(&task->cg_list, use_mg_tasks ? &to_cset->mg_tasks :
 							     &to_cset->tasks);
 	}
-- 
2.25.1


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

end of thread, other threads:[~2022-11-03 14:55 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-20  7:47 [PATCH] cgroup: Simplify code in css_set_move_task haifeng.xu
     [not found] ` <20221020074701.84326-1-haifeng.xu-LL2PKPoSiP3QT0dZR+AlfA@public.gmane.org>
2022-10-27  8:05   ` Michal Koutný
     [not found]     ` <20221027080558.GA23269-9OudH3eul5jcvrawFnH+a6VXKuFTiq87@public.gmane.org>
2022-10-28 11:29       ` Haifeng Xu
     [not found]         ` <adb7418c-39a2-6202-970a-a039ad8201dd-LL2PKPoSiP3QT0dZR+AlfA@public.gmane.org>
2022-10-31 13:11           ` Michal Koutný
     [not found]             ` <20221031131140.GC27841-9OudH3eul5jcvrawFnH+a6VXKuFTiq87@public.gmane.org>
2022-11-03  2:13               ` Haifeng Xu
     [not found]                 ` <25f6a188-4cc6-dace-1468-fd5645711515-LL2PKPoSiP3QT0dZR+AlfA@public.gmane.org>
2022-11-03  2:31                   ` Tejun Heo
2022-11-03 14:55                     ` Haifeng Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox