From: zhaoqingye <zhaoqingye@honor.com>
To: Tejun Heo <tj@kernel.org>
Cc: "Johannes Weiner" <hannes@cmpxchg.org>,
"\"Michal Koutný\"" <mkoutny@suse.com>,
"cgroups@vger.kernel.org" <cgroups@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
zhaoqingye <zhaoqingye@honor.com>
Subject: [PATCH] cgroup: remove redundant NULL assignments in migration finish
Date: Tue, 24 Feb 2026 10:36:23 +0000 [thread overview]
Message-ID: <994c084e31414d4188c8e2973d9f6e6b@honor.com> (raw)
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
next reply other threads:[~2026-02-24 10:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-24 10:36 zhaoqingye [this message]
2026-02-24 13:03 ` [PATCH] cgroup: remove redundant NULL assignments in migration finish Michal Koutný
2026-02-25 2:07 ` zhaoqingye
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=994c084e31414d4188c8e2973d9f6e6b@honor.com \
--to=zhaoqingye@honor.com \
--cc=cgroups@vger.kernel.org \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mkoutny@suse.com \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox