From: Waiman Long <llong@redhat.com>
To: Chen Ridong <chenridong@huaweicloud.com>,
tj@kernel.org, hannes@cmpxchg.org, mkoutny@suse.com
Cc: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org,
lujialin4@huawei.com, chenridong@huawei.com
Subject: Re: [PATCH -next v4 1/3] cpuset: decouple tmpmasks and cpumasks freeing in cgroup
Date: Sun, 24 Aug 2025 13:07:00 -0400 [thread overview]
Message-ID: <54e1466c-8db7-4fd1-a60f-5590015afaf2@redhat.com> (raw)
In-Reply-To: <20250818064141.1334859-2-chenridong@huaweicloud.com>
On 8/18/25 2:41 AM, Chen Ridong wrote:
> From: Chen Ridong <chenridong@huawei.com>
>
> Currently, free_cpumasks() can free both tmpmasks and cpumasks of a cpuset
> (cs). However, these two operations are not logically coupled. To improve
> code clarity:
> 1. Move cpumask freeing to free_cpuset()
> 2. Rename free_cpumasks() to free_tmpmasks()
>
> This change enforces the single responsibility principle.
>
> Signed-off-by: Chen Ridong <chenridong@huawei.com>
> ---
> kernel/cgroup/cpuset.c | 32 +++++++++++++-------------------
> 1 file changed, 13 insertions(+), 19 deletions(-)
>
> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
> index 3466ebbf1016..aebda14cc67f 100644
> --- a/kernel/cgroup/cpuset.c
> +++ b/kernel/cgroup/cpuset.c
> @@ -459,23 +459,14 @@ static inline int alloc_cpumasks(struct cpuset *cs, struct tmpmasks *tmp)
> }
>
> /**
> - * free_cpumasks - free cpumasks in a tmpmasks structure
> - * @cs: the cpuset that have cpumasks to be free.
> + * free_tmpmasks - free cpumasks in a tmpmasks structure
> * @tmp: the tmpmasks structure pointer
> */
> -static inline void free_cpumasks(struct cpuset *cs, struct tmpmasks *tmp)
> +static inline void free_tmpmasks(struct tmpmasks *tmp)
> {
> - if (cs) {
> - free_cpumask_var(cs->cpus_allowed);
> - free_cpumask_var(cs->effective_cpus);
> - free_cpumask_var(cs->effective_xcpus);
> - free_cpumask_var(cs->exclusive_cpus);
> - }
> - if (tmp) {
> - free_cpumask_var(tmp->new_cpus);
> - free_cpumask_var(tmp->addmask);
> - free_cpumask_var(tmp->delmask);
> - }
> + free_cpumask_var(tmp->new_cpus);
> + free_cpumask_var(tmp->addmask);
> + free_cpumask_var(tmp->delmask);
> }
>
> /**
> @@ -508,7 +499,10 @@ static struct cpuset *alloc_trial_cpuset(struct cpuset *cs)
> */
> static inline void free_cpuset(struct cpuset *cs)
> {
> - free_cpumasks(cs, NULL);
> + free_cpumask_var(cs->cpus_allowed);
> + free_cpumask_var(cs->effective_cpus);
> + free_cpumask_var(cs->effective_xcpus);
> + free_cpumask_var(cs->exclusive_cpus);
> kfree(cs);
> }
>
> @@ -2427,7 +2421,7 @@ static int update_cpumask(struct cpuset *cs, struct cpuset *trialcs,
> if (cs->partition_root_state)
> update_partition_sd_lb(cs, old_prs);
> out_free:
> - free_cpumasks(NULL, &tmp);
> + free_tmpmasks(&tmp);
> return retval;
> }
>
> @@ -2530,7 +2524,7 @@ static int update_exclusive_cpumask(struct cpuset *cs, struct cpuset *trialcs,
> if (cs->partition_root_state)
> update_partition_sd_lb(cs, old_prs);
>
> - free_cpumasks(NULL, &tmp);
> + free_tmpmasks(&tmp);
> return 0;
> }
>
> @@ -2983,7 +2977,7 @@ static int update_prstate(struct cpuset *cs, int new_prs)
> notify_partition_change(cs, old_prs);
> if (force_sd_rebuild)
> rebuild_sched_domains_locked();
> - free_cpumasks(NULL, &tmpmask);
> + free_tmpmasks(&tmpmask);
> return 0;
> }
>
> @@ -4006,7 +4000,7 @@ static void cpuset_handle_hotplug(void)
> if (force_sd_rebuild)
> rebuild_sched_domains_cpuslocked();
>
> - free_cpumasks(NULL, ptmp);
> + free_tmpmasks(ptmp);
> }
>
> void cpuset_update_active_cpus(void)
Reviewed-by: Waiman Long <longman@redhat.com>
next prev parent reply other threads:[~2025-08-24 17:07 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-18 6:41 [PATCH -next v4 0/3] some optimization for cpuset Chen Ridong
2025-08-18 6:41 ` [PATCH -next v4 1/3] cpuset: decouple tmpmasks and cpumasks freeing in cgroup Chen Ridong
2025-08-24 17:07 ` Waiman Long [this message]
2025-08-18 6:41 ` [PATCH -next v4 2/3] cpuset: separate tmpmasks and cpuset allocation logic Chen Ridong
2025-08-24 17:05 ` Waiman Long
2025-08-25 0:52 ` Chen Ridong
2025-08-18 6:41 ` [PATCH -next v4 3/3] cpuset: add helpers for cpus read and cpuset_mutex locks Chen Ridong
2025-08-24 17:07 ` Waiman Long
2025-08-23 2:08 ` [PATCH -next v4 0/3] some optimization for cpuset Chen Ridong
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=54e1466c-8db7-4fd1-a60f-5590015afaf2@redhat.com \
--to=llong@redhat.com \
--cc=cgroups@vger.kernel.org \
--cc=chenridong@huawei.com \
--cc=chenridong@huaweicloud.com \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lujialin4@huawei.com \
--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
all inboxes | Powered by JetHome®