public inbox for cgroups@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cgroup: remove redundant NULL assignments in migration finish
@ 2026-02-24 10:36 zhaoqingye
  2026-02-24 13:03 ` Michal Koutný
  0 siblings, 1 reply; 3+ messages in thread
From: zhaoqingye @ 2026-02-24 10:36 UTC (permalink / raw)
  To: Tejun Heo
  Cc: Johannes Weiner, "Michal Koutný",
	cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, zhaoqingye

cgroup_migrate_finish() currently sets cset->mg_src_cgrp, cset->mg_dst_cgrp
and cset->mg_dst_cset to NULL when cleaning mgctx->preloaded_dst_csets.

These assignments are redundant for the css_sets on
mgctx->preloaded_dst_csets:

- There are only three places that modify the mg_* members of a css_set:
  - cgroup_migrate_add_src(), which sets src_cset->mg_src_cgrp
  - cgroup_migrate_prepare_dst(), which clears src_cset->mg_src_cgrp when
    src_cset and dst_cset happen to be the same
  - cgroup_migrate_finish(), which clears mg_src_cgrp for css_sets on
    mgctx->preloaded_src_csets and mgctx->preloaded_dst_csets

- All three functions are invoked through the migration sequence:
  cgroup_migrate_add_src() ->
  cgroup_migrate_prepare_dst() ->
  cgroup_migrate_add_task() ->
  cgroup_migrate_execute() ->
  cgroup_migrate_finish()

  All migration entry points (cgroup_attach_task(),
  cgroup_update_dfl_csses() and cgroup_transfer_tasks()) hold
  cgroup_mutex across the whole sequence: cgroup_mutex is acquired before
  cgroup_migrate_add_src() and only released after cgroup_migrate_finish()
  returns. This rules out concurrent updates to the mg_* members.

- During a single migration, a given css_set cannot be on both
  mgctx->preloaded_src_csets and mgctx->preloaded_dst_csets at the same
  time. For css_sets on mgctx->preloaded_dst_csets, mg_src_cgrp,
  mg_dst_cgrp and mg_dst_cset are never assigned and therefore remain NULL
  for the entire migration.

As a result, explicitly setting these fields to NULL again in
cgroup_migrate_finish() for css_sets on mgctx->preloaded_dst_csets does not
change any observable state. Removing the redundant assignments makes the
migration state handling clearer without changing behavior.

Signed-off-by: Qingye Zhao <zhaoqingye@honor.com>
---
 kernel/cgroup/cgroup.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index 5f0d33b04910..6c8eff438462 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -2845,9 +2845,6 @@ void cgroup_migrate_finish(struct cgroup_mgctx *mgctx)
 
 	list_for_each_entry_safe(cset, tmp_cset, &mgctx->preloaded_dst_csets,
 				 mg_dst_preload_node) {
-		cset->mg_src_cgrp = NULL;
-		cset->mg_dst_cgrp = NULL;
-		cset->mg_dst_cset = NULL;
 		list_del_init(&cset->mg_dst_preload_node);
 		put_css_set_locked(cset);
 	}
-- 
2.25.1


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

end of thread, other threads:[~2026-02-25  2:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-24 10:36 [PATCH] cgroup: remove redundant NULL assignments in migration finish zhaoqingye
2026-02-24 13:03 ` Michal Koutný
2026-02-25  2:07   ` zhaoqingye

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