From: Ridong Chen <ridong.chen@linux.dev>
To: "Guopeng Zhang" <guopeng.zhang@linux.dev>,
"Waiman Long" <longman@redhat.com>, "Tejun Heo" <tj@kernel.org>,
"Johannes Weiner" <hannes@cmpxchg.org>,
"Michal Koutný" <mkoutny@suse.com>
Cc: Chen Ridong <chenridong@huaweicloud.com>,
cgroups@vger.kernel.org, linux-kernel@vger.kernel.org,
Guopeng Zhang <zhangguopeng@kylinos.cn>
Subject: Re: [PATCH] cgroup/cpuset: Free sched domains on rebuild guard failure
Date: Tue, 2 Jun 2026 17:27:10 +0800 [thread overview]
Message-ID: <7775e634-7667-4184-9d5a-cd17162ef402@linux.dev> (raw)
In-Reply-To: <20260528093742.1792456-1-guopeng.zhang@linux.dev>
On 2026/5/28 17:37, Guopeng Zhang wrote:
> From: Guopeng Zhang <zhangguopeng@kylinos.cn>
>
> generate_sched_domains() returns sched-domain masks and optional
> attributes that are normally handed to partition_sched_domains(), which
> takes ownership of them.
>
> rebuild_sched_domains_locked() has a WARN guard after
> generate_sched_domains() and before partition_sched_domains() to avoid
> passing offline CPUs into the scheduler domain rebuild path. If that
> guard fires, the function currently returns directly without freeing
> the generated doms and attr.
>
> Free the generated sched-domain masks and attributes before returning
> from the guard failure path.
>
> Signed-off-by: Guopeng Zhang <zhangguopeng@kylinos.cn>
> ---
> kernel/cgroup/cpuset.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
> index 51327333980a..c5fdebc205d8 100644
> --- a/kernel/cgroup/cpuset.c
> +++ b/kernel/cgroup/cpuset.c
> @@ -1004,8 +1004,11 @@ void rebuild_sched_domains_locked(void)
> * prevent the panic.
> */
> for (i = 0; doms && i < ndoms; i++) {
> - if (WARN_ON_ONCE(!cpumask_subset(doms[i], cpu_active_mask)))
> + if (WARN_ON_ONCE(!cpumask_subset(doms[i], cpu_active_mask))) {
> + free_sched_domains(doms, ndoms);
> + kfree(attr);
> return;
> + }
> }
>
> /* Have scheduler rebuild the domains */
Thank you. This helps prevent a memory leak in this abnormal scenario. I
should have included it when I originally added this check.
--
Best regards,
Ridong
prev parent reply other threads:[~2026-06-02 9:27 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-28 9:37 [PATCH] cgroup/cpuset: Free sched domains on rebuild guard failure Guopeng Zhang
2026-05-29 18:07 ` Waiman Long
2026-05-29 18:28 ` Tejun Heo
2026-06-02 9:27 ` Ridong Chen [this message]
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=7775e634-7667-4184-9d5a-cd17162ef402@linux.dev \
--to=ridong.chen@linux.dev \
--cc=cgroups@vger.kernel.org \
--cc=chenridong@huaweicloud.com \
--cc=guopeng.zhang@linux.dev \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=longman@redhat.com \
--cc=mkoutny@suse.com \
--cc=tj@kernel.org \
--cc=zhangguopeng@kylinos.cn \
/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