mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Guopeng Zhang <guopeng.zhang@linux.dev>
To: "Waiman Long" <longman@redhat.com>,
	"Ridong Chen" <ridong.chen@linux.dev>,
	"Tejun Heo" <tj@kernel.org>,
	"Johannes Weiner" <hannes@cmpxchg.org>,
	"Michal Koutný" <mkoutny@suse.com>,
	"Shuah Khan" <shuah@kernel.org>
Cc: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-kselftest@vger.kernel.org
Subject: Re: [PATCH-next v3 04/11] cgroup/cpuset: Minor fixes to prstate_housekeeping_conflict()
Date: Mon, 26 Oct 2026 14:57:36 +0800	[thread overview]
Message-ID: <1961a890-0917-416c-9733-272d92a59d35@linux.dev> (raw)
In-Reply-To: <20261025214449.310715-5-longman@redhat.com>



在 2026/10/26 05:44, Waiman Long 写道:
> Commit 9527ff78a413 ("cgroup/cpuset: Consider all the exclusive CPUs when
> doing housekeeping check") changes the way prstate_housekeeping_conflict()
> is being used by considering all the exclusive xcpus to be owned by the
> partition when doing housekeeping check. However there are two minor
> issues reported by sashiko with that patch:
> 
>  1) In partition_cpus_change(), prstate_housekeeping_conflict() can
>  be called with an invalid partition root. In that case, there are
>  no isolated CPUs that are going to be returned back to the system to
>  become housekeeping CPUs, so the calculation of the del_cpus cpumask
>  is meaningless.
> 
>  2) The checking of del_cpus in prstate_housekeeping_conflict() to see
>  if it can contain an active housekeeping CPU that can be returned to the
>  system ignores the fact that an active CPU not in HK_TYPE_DOMAIN_BOOT HK
>  cpumask will not become an active housekeeping CPU when it is released
>  by an isolated partition.
> 
> Update the existing code to handle these two issues properly to make
> prstate_housekeeping_conflict() produce more accurate result.
> 
> Fixes: 9527ff78a413 ("cgroup/cpuset: Consider all the exclusive CPUs when doing housekeeping check")
> Signed-off-by: Waiman Long <longman@redhat.com>
> ---
>  kernel/cgroup/cpuset.c | 45 +++++++++++++++++++++++++++++-------------
>  1 file changed, 31 insertions(+), 14 deletions(-)
> 
> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
> index 37bc79d0c647..57e5334eb919 100644
> --- a/kernel/cgroup/cpuset.c
> +++ b/kernel/cgroup/cpuset.c
> @@ -1446,6 +1446,9 @@ static bool prstate_housekeeping_conflict(int new_prs, int parent_prs,
>  	    !cpumask_subset(new_cpus, housekeeping_cpumask(HK_TYPE_DOMAIN_BOOT)))
>  		return true;
>  
> +	if (del_cpus && cpumask_empty(del_cpus))
> +		del_cpus = NULL;
> +
>  	/*
>  	 * Exit 2nd check early and return false if
>  	 * 1) there is no boot time isolated nohz_full CPU
> @@ -1454,8 +1457,7 @@ static bool prstate_housekeeping_conflict(int new_prs, int parent_prs,
>  	 *    be returned back to the parent.
>  	 */
>  	if (!housekeeping_enabled(HK_TYPE_KERNEL_NOISE) ||
> -	    (new_prs == parent_prs) ||
> -	    ((new_prs == PRS_ROOT) && (!del_cpus || cpumask_empty(del_cpus))))
> +	    (new_prs == parent_prs) || (!del_cpus && (new_prs == PRS_ROOT)))
>  		return false;
>  
>  	/*
> @@ -1466,20 +1468,29 @@ static bool prstate_housekeeping_conflict(int new_prs, int parent_prs,
>  	if (parent_prs == PRS_ISOLATED)
>  		swap(new_cpus, del_cpus);
>  
> -	if (del_cpus &&
> -	   (cpumask_first_and_and(del_cpus, housekeeping_cpumask(HK_TYPE_KERNEL_NOISE),
> -				   cpu_active_mask) < nr_cpu_ids))
> -		return false;
> -
>  	if (!alloc_cpumask_var(&full_hk_cpus, GFP_KERNEL))
>  		return true;
>  
> +	/*
> +	 * Check if del_cpus may contain a CPU that can become an active
> +	 * housekeeping CPU again.
> +	 */
> +	if (del_cpus) {
> +		cpumask_and(full_hk_cpus, housekeeping_cpumask(HK_TYPE_KERNEL_NOISE),
> +			    housekeeping_cpumask(HK_TYPE_DOMAIN_BOOT));
> +		if (cpumask_first_and_and(del_cpus, full_hk_cpus,
> +					  cpu_active_mask) < nr_cpu_ids) {
> +			res = false;
> +			goto out;
> +		}
> +	}
> +
>  	cpumask_and(full_hk_cpus, housekeeping_cpumask(HK_TYPE_KERNEL_NOISE),
>  		    housekeeping_cpumask(HK_TYPE_DOMAIN));
>  	cpumask_andnot(full_hk_cpus, full_hk_cpus, isolated_cpus);
>  	cpumask_and(full_hk_cpus, full_hk_cpus, cpu_active_mask);
>  	res = !cpumask_weight_andnot(full_hk_cpus, new_cpus);
> -
> +out:
>  	free_cpumask_var(full_hk_cpus);
>  	return res;
>  }
> @@ -2486,23 +2497,29 @@ static void partition_cpus_change(struct cpuset *cs, struct cpuset *trialcs,
>  				  struct tmpmasks *tmp)
>  {
>  	enum prs_errcode prs_err;
> +	int parent_prs = is_remote_partition(cs)
> +		       ? PRS_ROOT : parent_cs(cs)->partition_root_state;
>  
>  	if (cs_is_member(cs))
>  		return;
>  
>  	prs_err = validate_partition(cs, trialcs);
> -	if (!prs_err && !cpumask_empty(trialcs->effective_xcpus)) {
> +	if (!prs_err && (parent_prs > 0) &&
> +	    !cpumask_empty(trialcs->effective_xcpus)) {
>  		int prs = cs->partition_root_state;
> -		int parent_prs = is_remote_partition(cs)
> -			       ? PRS_ROOT : parent_cs(cs)->partition_root_state;
> +
>  		/*
>  		 * Check for housekeeping conflict by passing the whole
>  		 * effective_xcpus as well as those CPUs that are to be
>  		 * removed from cs as delmask.
>  		 */
> -		cpumask_andnot(tmp->delmask, cs->effective_xcpus, trialcs->effective_xcpus);
> -		if (parent_prs > 0 &&
> -		    prstate_housekeeping_conflict(prs, parent_prs,
> +		if (prs > 0)
> +			cpumask_andnot(tmp->delmask, cs->effective_xcpus,
> +				       trialcs->effective_xcpus);
> +		else
> +			cpumask_clear(tmp->delmask);
> +
> +		if (prstate_housekeeping_conflict(prs, parent_prs,
>  						  trialcs->effective_xcpus, tmp->delmask))
>  			prs_err = PERR_HKEEPING;
>  	}

Reviewed-by: Guopeng Zhang <zhangguopeng@kylinos.cn>

Thanks,
Guopeng

  reply	other threads:[~2026-10-26  6:57 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-25 21:44 [PATCH-next v3 00/11] cgroup/cpuset: Miscellaneous bug fixes & cleanup Waiman Long
2026-10-25 21:44 ` [PATCH-next v3 01/11] cgroup/cpuset: Find furthest isolated ancestor for invalidated isolated partition Waiman Long
2026-10-26  6:33   ` Guopeng Zhang
2026-10-25 21:44 ` [PATCH-next v3 02/11] cgroup/cpuset: Properly compute effective xcpus in update_parent_effective_cpumask() Waiman Long
2026-10-26  6:39   ` Guopeng Zhang
2026-10-25 21:44 ` [PATCH-next v3 03/11] cgroup/cpuset: Fix incorrect effective_cpus bug in update_cpumasks_hier() Waiman Long
2026-10-26  6:46   ` Guopeng Zhang
2026-10-25 21:44 ` [PATCH-next v3 04/11] cgroup/cpuset: Minor fixes to prstate_housekeeping_conflict() Waiman Long
2026-10-26  6:57   ` Guopeng Zhang [this message]
2026-10-25 21:44 ` [PATCH-next v3 05/11] selftests/cgroup: Check for a single range nohz_full CPUs before running test matrix Waiman Long
2026-10-25 21:44 ` [PATCH-next v3 06/11] cgroup/cpuset: Prevent recursive call of remote_cpus_update() via update_cpumasks_hier() Waiman Long
2026-10-25 21:44 ` [PATCH-next v3 07/11] cgroup/cpuset: Make sure compute_partition_effective_cpumask() is only called for valid partition Waiman Long
2026-10-26  7:14   ` Guopeng Zhang
2026-10-25 21:44 ` [PATCH-next v3 08/11] cgroup/cpuset: Release invalid isolated CPUs in compute_partition_effective_cpumask() Waiman Long
2026-10-26  8:49   ` Guopeng Zhang
2026-10-25 21:44 ` [PATCH-next v3 09/11] cgroup/cpuset: Release invalid isolated CPUs with a shrunk root partition parent Waiman Long
2026-10-25 23:53   ` [PATCH-next v3.1 " Waiman Long
2026-10-26  8:51     ` Guopeng Zhang
2026-10-25 23:56   ` [PATCH-next v3 " Waiman Long
2026-10-25 21:44 ` [PATCH-next v3 10/11] cgroup/cpuset: Relocate compute_*effective_cpumask() and compute_effective_nodemask() Waiman Long
2026-10-26  9:08   ` Guopeng Zhang
2026-10-25 21:44 ` [PATCH-next v3 11/11] cgroup/cpuset: Integrate compute_partition_effective_cpumask() into compute_effective_cpumask() Waiman Long
2026-10-26  9:44   ` Guopeng Zhang
2026-10-26 18:26 ` [PATCH-next v3 00/11] cgroup/cpuset: Miscellaneous bug fixes & cleanup Tejun Heo

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=1961a890-0917-416c-9733-272d92a59d35@linux.dev \
    --to=guopeng.zhang@linux.dev \
    --cc=cgroups@vger.kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=longman@redhat.com \
    --cc=mkoutny@suse.com \
    --cc=ridong.chen@linux.dev \
    --cc=shuah@kernel.org \
    --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®