Linux cgroups development
 help / color / mirror / Atom feed
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
Subject: Re: [PATCH -next 4/6] cpuset: move update_domain_attr_tree to cpuset_v1.c
Date: Wed, 17 Dec 2025 12:09:34 -0500	[thread overview]
Message-ID: <249786b2-f715-4a46-be47-d6d3d6f35c10@redhat.com> (raw)
In-Reply-To: <20251217084942.2666405-5-chenridong@huaweicloud.com>


On 12/17/25 3:49 AM, Chen Ridong wrote:
> From: Chen Ridong <chenridong@huawei.com>
>
> Since relax_domain_level is only applicable to v1, move
> update_domain_attr_tree() to cpuset-v1.c, which solely updates
> relax_domain_level,
>
> Additionally, relax_domain_level is now initialized in cpuset1_inited.
> Accordingly, the initialization of relax_domain_level in top_cpuset is
> removed. The unnecessary remote_partition initialization in top_cpuset
> is also cleaned up.
>
> As a result, relax_domain_level can be defined in cpuset only when
> CONFIG_CPUSETS_V1=y.
>
> Signed-off-by: Chen Ridong <chenridong@huawei.com>
> ---
>   kernel/cgroup/cpuset-internal.h | 11 ++++++++---
>   kernel/cgroup/cpuset-v1.c       | 28 ++++++++++++++++++++++++++++
>   kernel/cgroup/cpuset.c          | 31 -------------------------------
>   3 files changed, 36 insertions(+), 34 deletions(-)
>
> diff --git a/kernel/cgroup/cpuset-internal.h b/kernel/cgroup/cpuset-internal.h
> index a32517da8231..677053ffb913 100644
> --- a/kernel/cgroup/cpuset-internal.h
> +++ b/kernel/cgroup/cpuset-internal.h
> @@ -150,9 +150,6 @@ struct cpuset {
>   	 */
>   	int attach_in_progress;
>   
> -	/* for custom sched domain */
> -	int relax_domain_level;
> -
>   	/* partition root state */
>   	int partition_root_state;
>   
> @@ -182,6 +179,9 @@ struct cpuset {
>   
>   #ifdef CONFIG_CPUSETS_V1
>   	struct fmeter fmeter;		/* memory_pressure filter */
> +
> +	/* for custom sched domain */
> +	int relax_domain_level;
>   #endif
>   };
>   
> @@ -296,6 +296,8 @@ void cpuset1_hotplug_update_tasks(struct cpuset *cs,
>   int cpuset1_validate_change(struct cpuset *cur, struct cpuset *trial);
>   void cpuset1_init(struct cpuset *cs);
>   void cpuset1_online_css(struct cgroup_subsys_state *css);
> +void update_domain_attr_tree(struct sched_domain_attr *dattr,
> +				    struct cpuset *root_cs);
>   #else
>   static inline void cpuset1_update_task_spread_flags(struct cpuset *cs,
>   					struct task_struct *tsk) {}
> @@ -307,6 +309,9 @@ static inline int cpuset1_validate_change(struct cpuset *cur,
>   				struct cpuset *trial) { return 0; }
>   static inline void cpuset1_init(struct cpuset *cs) {}
>   static inline void cpuset1_online_css(struct cgroup_subsys_state *css) {}
> +static inline void update_domain_attr_tree(struct sched_domain_attr *dattr,
> +				    struct cpuset *root_cs) {}
> +
>   #endif /* CONFIG_CPUSETS_V1 */
>   
>   #endif /* __CPUSET_INTERNAL_H */
> diff --git a/kernel/cgroup/cpuset-v1.c b/kernel/cgroup/cpuset-v1.c
> index 574df740f21a..95de6f2a4cc5 100644
> --- a/kernel/cgroup/cpuset-v1.c
> +++ b/kernel/cgroup/cpuset-v1.c
> @@ -502,6 +502,7 @@ static int cpuset_write_u64(struct cgroup_subsys_state *css, struct cftype *cft,
>   void cpuset1_init(struct cpuset *cs)
>   {
>   	fmeter_init(&cs->fmeter);
> +	cs->relax_domain_level = -1;
>   }
>   
>   void cpuset1_online_css(struct cgroup_subsys_state *css)
> @@ -552,6 +553,33 @@ void cpuset1_online_css(struct cgroup_subsys_state *css)
>   	cpuset_callback_unlock_irq();
>   }
>   
> +static void
> +update_domain_attr(struct sched_domain_attr *dattr, struct cpuset *c)
> +{
> +	if (dattr->relax_domain_level < c->relax_domain_level)
> +		dattr->relax_domain_level = c->relax_domain_level;
> +}
> +
> +void update_domain_attr_tree(struct sched_domain_attr *dattr,
> +				    struct cpuset *root_cs)
> +{
> +	struct cpuset *cp;
> +	struct cgroup_subsys_state *pos_css;
> +
> +	rcu_read_lock();
> +	cpuset_for_each_descendant_pre(cp, pos_css, root_cs) {
> +		/* skip the whole subtree if @cp doesn't have any CPU */
> +		if (cpumask_empty(cp->cpus_allowed)) {
> +			pos_css = css_rightmost_descendant(pos_css);
> +			continue;
> +		}
> +
> +		if (is_sched_load_balance(cp))
> +			update_domain_attr(dattr, cp);
> +	}
> +	rcu_read_unlock();
> +}
> +
>   /*
>    * for the common functions, 'private' gives the type of file
>    */
> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
> index e836a1f2b951..88ca8b40e01a 100644
> --- a/kernel/cgroup/cpuset.c
> +++ b/kernel/cgroup/cpuset.c
> @@ -215,8 +215,6 @@ static struct cpuset top_cpuset = {
>   	.flags = BIT(CS_CPU_EXCLUSIVE) |
>   		 BIT(CS_MEM_EXCLUSIVE) | BIT(CS_SCHED_LOAD_BALANCE),
>   	.partition_root_state = PRS_ROOT,
> -	.relax_domain_level = -1,

As the cpuset1_init() function will not be called for top_cpuset, you 
should not remove the initialization of relax_domain_level. Instead, put 
it inside a "ifdef CONFIG_CPUSETS_V1 block.

> -	.remote_partition = false,

Yes, this is not really needed and can be removed.

Cheers,
Longman


  reply	other threads:[~2025-12-17 17:09 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-17  8:49 [PATCH -next 0/6] cpuset: further separate v1 and v2 implementations Chen Ridong
2025-12-17  8:49 ` [PATCH -next 1/6] cpuset: add assert_cpuset_lock_held helper Chen Ridong
2025-12-17 17:02   ` Waiman Long
2025-12-18  0:37     ` Chen Ridong
2025-12-17  8:49 ` [PATCH -next 2/6] cpuset: add cpuset1_online_css helper for v1-specific operations Chen Ridong
2025-12-17  8:49 ` [PATCH -next 3/6] cpuset: add cpuset1_init helper for v1 initialization Chen Ridong
2025-12-17  8:49 ` [PATCH -next 4/6] cpuset: move update_domain_attr_tree to cpuset_v1.c Chen Ridong
2025-12-17 17:09   ` Waiman Long [this message]
2025-12-18  0:44     ` Chen Ridong
2025-12-18  3:06       ` Waiman Long
2025-12-17  8:49 ` [PATCH -next 5/6] cpuset: separate generate_sched_domains for v1 and v2 Chen Ridong
2025-12-17 17:48   ` Waiman Long
2025-12-18  1:28     ` Chen Ridong
2025-12-18  3:09       ` Waiman Long
2025-12-18  3:31         ` Chen Ridong
2025-12-17  8:49 ` [PATCH -next 6/6] cpuset: remove v1-specific code from generate_sched_domains Chen Ridong
2025-12-17 19:05   ` Waiman Long
2025-12-18  1:39     ` Chen Ridong
2025-12-18  3:14       ` Waiman Long
2025-12-18  3:32         ` Chen Ridong
2025-12-18  3:56     ` 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=249786b2-f715-4a46-be47-d6d3d6f35c10@redhat.com \
    --to=llong@redhat.com \
    --cc=cgroups@vger.kernel.org \
    --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