The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Guopeng Zhang <guopeng.zhang@linux.dev>
To: "Ridong Chen" <ridong.chen@linux.dev>,
	"Waiman Long" <longman@redhat.com>, "Tejun Heo" <tj@kernel.org>,
	"Johannes Weiner" <hannes@cmpxchg.org>,
	"Michal Koutný" <mkoutny@suse.com>
Cc: Guopeng Zhang <zhangguopeng@kylinos.cn>,
	cgroups@vger.kernel.org, linux-kernel@vger.kernel.org,
	Ridong Chen <chenridong@xiaomi.com>
Subject: Re: [PATCH v5 05/12] cpuset: use partition_disable() for remote partition disablement
Date: Tue, 24 Nov 2026 18:34:49 +0800	[thread overview]
Message-ID: <08e4f7bd-37d7-4752-93f3-23fe6d15b1df@linux.dev> (raw)
In-Reply-To: <20261114083124.1340140-6-ridong.chen@linux.dev>



在 2026/11/14 16:31, Ridong Chen 写道:
> From: Ridong Chen <chenridong@xiaomi.com>
> 
> Now that the partition_disable() helper is available, replace the
> existing implementation for remote partition disablement with this
> centralized function to unify the disablement logic.
> 
> remote_partition_disable() is removed and its callers call
> partition_disable() directly. The new partition root state is passed
> in by the caller instead of being derived from cs->prs_err, as only the
> caller knows which state the partition is going to.
> 
> Signed-off-by: Ridong Chen <chenridong@xiaomi.com>
> ---
>  kernel/cgroup/cpuset.c | 57 ++++++------------------------------------
>  1 file changed, 8 insertions(+), 49 deletions(-)
> 
> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
> index 3702e43e95ef..681adcde10e8 100644
> --- a/kernel/cgroup/cpuset.c
> +++ b/kernel/cgroup/cpuset.c
> @@ -1771,9 +1771,8 @@ static void partition_enable(struct cpuset *cs, struct cpuset *parent,
>   * has its state updated. A valid partition under an invalid parent has
>   * already given back its CPUs, so only the propagation is done.
>   */
> -static void __maybe_unused partition_disable(struct cpuset *cs, int new_prs,
> -					     enum prs_errcode prs_err,
> -					     struct tmpmasks *tmp)
> +static void partition_disable(struct cpuset *cs, int new_prs,
> +			      enum prs_errcode prs_err, struct tmpmasks *tmp)
>  {
>  	struct cpuset *parent = is_remote_partition(cs) ? NULL : parent_cs(cs);
>  	int old_prs = cs->partition_root_state;
> @@ -1923,48 +1922,6 @@ static int remote_partition_enable(struct cpuset *cs, int new_prs,
>  	return 0;
>  }
>  
> -/*
> - * remote_partition_disable - Remove current cpuset from remote partition list
> - * @cs: the cpuset to update
> - * @tmp: temporary masks
> - *
> - * The effective_cpus is also updated.
> - *
> - * cpuset_mutex must be held by the caller.
> - */
> -static void remote_partition_disable(struct cpuset *cs, struct tmpmasks *tmp)
> -{
> -	WARN_ON_ONCE(!is_remote_partition(cs));
> -	/*
> -	 * When a CPU is offlined, top_cpuset may end up with no available CPUs,
> -	 * which should clear subpartitions_cpus. We should not emit a warning for this
> -	 * scenario: the hierarchy is updated from top to bottom, so subpartitions_cpus
> -	 * may already be cleared when disabling the partition.
> -	 */
> -	WARN_ON_ONCE(!cpumask_subset(cs->effective_xcpus, subpartitions_cpus) &&
> -		     !cpumask_empty(subpartitions_cpus));
> -
> -	spin_lock_irq(&callback_lock);
> -	cs->remote_partition = false;
> -	partition_xcpus_del(cs->partition_root_state, NULL, cs->effective_xcpus);
> -	if (cs->prs_err)
> -		cs->partition_root_state = -cs->partition_root_state;
> -	else
> -		cs->partition_root_state = PRS_MEMBER;
> -
> -	/* effective_xcpus may need to be changed */
> -	compute_excpus(cs, cs->effective_xcpus);
> -	reset_partition_data(cs);
> -	spin_unlock_irq(&callback_lock);
> -	cpuset_force_rebuild();
> -
> -	/*
> -	 * Propagate changes in top_cpuset's effective_cpus down the hierarchy.
> -	 */
> -	cpuset_update_tasks_cpumask(&top_cpuset, tmp->new_cpus);
> -	update_sibling_cpumasks(&top_cpuset, NULL, tmp);
> -}
> -
>  /*
>   * remote_cpus_update - cpus_exclusive change of remote partition
>   * @cs: the cpuset to be updated
> @@ -2039,7 +1996,7 @@ static void remote_cpus_update(struct cpuset *cs, struct cpumask *xcpus,
>  	return;
>  
>  invalidate:
> -	remote_partition_disable(cs, tmp);
> +	partition_disable(cs, -prs, cs->prs_err, tmp);
>  }
>  
>  /**
> @@ -2667,7 +2624,8 @@ static void partition_cpus_change(struct cpuset *cs, struct cpuset *trialcs,
>  
>  	if (is_remote_partition(cs)) {
>  		if (trialcs->prs_err)
> -			remote_partition_disable(cs, tmp);
> +			partition_disable(cs, -cs->partition_root_state,
> +					  cs->prs_err, tmp);
>  		else
>  			remote_cpus_update(cs, trialcs->exclusive_cpus,
>  					   trialcs->effective_xcpus, tmp);
> @@ -3215,7 +3173,7 @@ static int update_prstate(struct cpuset *cs, int new_prs)
>  
>  	if (disable_partition) {
>  		if (is_remote_partition(cs))
> -			remote_partition_disable(cs, &tmpmask);
> +			partition_disable(cs, PRS_MEMBER, PERR_NONE, &tmpmask);
>  		else
>  			update_parent_effective_cpumask(cs, partcmd_disable,
>  							NULL, &tmpmask);
> @@ -4164,7 +4122,8 @@ static void cpuset_hotplug_update_tasks(struct cpuset *cs, struct tmpmasks *tmp)
>  				       (cpumask_empty(&new_cpus) &&
>  					partition_is_populated(cs, NULL)))) {
>  		WRITE_ONCE(cs->prs_err, PERR_HOTPLUG);
> -		remote_partition_disable(cs, tmp);
> +		partition_disable(cs, -cs->partition_root_state, cs->prs_err,
> +				  tmp);

Now that partition_disable() takes the error code directly and updates
prs_err through partition_state_update(), the preceding
WRITE_ONCE(cs->prs_err, PERR_HOTPLUG) seems unnecessary.

Could we pass PERR_HOTPLUG directly to partition_disable() and remove
that assignment?

Thanks,
Guopeng

>  		compute_effective_cpumask(&new_cpus, cs, parent);
>  	}
>  


  reply	other threads:[~2026-11-24 10:34 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-14  8:31 [PATCH v5 00/12] cpuset: rework local partition logic Ridong Chen
2026-11-14  8:31 ` [PATCH v5 01/12] cpuset: introduce partition_enable() Ridong Chen
2026-11-18  9:21   ` Guopeng Zhang
2026-11-18 10:59     ` Ridong Chen
2026-11-14  8:31 ` [PATCH v5 02/12] cpuset: introduce partition_disable() Ridong Chen
2026-11-24 10:04   ` Guopeng Zhang
2026-11-14  8:31 ` [PATCH v5 03/12] cpuset: introduce partition_update() Ridong Chen
2026-11-24 10:06   ` Guopeng Zhang
2026-11-14  8:31 ` [PATCH v5 04/12] cpuset: use partition_enable() for remote partition enablement Ridong Chen
2026-11-14  8:31 ` [PATCH v5 05/12] cpuset: use partition_disable() for remote partition disablement Ridong Chen
2026-11-24 10:34   ` Guopeng Zhang [this message]
2026-11-14  8:31 ` [PATCH v5 06/12] cpuset: use partition_update() for remote partition update Ridong Chen
2026-11-14  8:31 ` [PATCH v5 07/12] cpuset: introduce validate_local_partition() Ridong Chen
2026-11-14  8:31 ` [PATCH v5 08/12] cpuset: introduce local_partition_enable() Ridong Chen
2026-11-14  8:31 ` [PATCH v5 09/12] cpuset: use partition_disable() for local partition disablement Ridong Chen
2026-11-14  8:31 ` [PATCH v5 10/12] cpuset: use partition_disable() to invalidate local partition Ridong Chen
2026-11-14  8:31 ` [PATCH v5 11/12] cpuset: introduce local_partition_update() Ridong Chen
2026-11-14  8:31 ` [PATCH v5 12/12] cpuset: remove update_parent_effective_cpumask Ridong Chen

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=08e4f7bd-37d7-4752-93f3-23fe6d15b1df@linux.dev \
    --to=guopeng.zhang@linux.dev \
    --cc=cgroups@vger.kernel.org \
    --cc=chenridong@xiaomi.com \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=longman@redhat.com \
    --cc=mkoutny@suse.com \
    --cc=ridong.chen@linux.dev \
    --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