]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
cpuset: move update_domain_attr_tree to cpuset_v1.c
authorChen Ridong <chenridong@huawei.com>
Thu, 18 Dec 2025 09:31:39 +0000 (09:31 +0000)
committerTejun Heo <tj@kernel.org>
Thu, 18 Dec 2025 18:36:15 +0000 (08:36 -1000)
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>
Reviewed-by: Waiman Long <longman@redhat.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
kernel/cgroup/cpuset-internal.h
kernel/cgroup/cpuset-v1.c
kernel/cgroup/cpuset.c

index a32517da823134f02f1d042a7231dca2dcb9f53e..677053ffb9136193375a50b8cdd44a7774978eca 100644 (file)
@@ -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 */
index 84f00ab9c81fb7039f08341eff30b248e15154ed..a4f8f1c3cfaa57be8628cc68d01872b5397d5a37 100644 (file)
@@ -502,6 +502,7 @@ out_unlock:
 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
  */
index 8ef8b75116595e75bd2d6a917d57475c79b420ff..cf2363a9c552c18e312f4ecca31956c64aded6fd 100644 (file)
@@ -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,
-       .remote_partition = false,
 };
 
 /*
@@ -755,34 +753,6 @@ static int cpusets_overlap(struct cpuset *a, struct cpuset *b)
        return cpumask_intersects(a->effective_cpus, b->effective_cpus);
 }
 
-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;
-       return;
-}
-
-static 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();
-}
-
 /* Must be called with cpuset_mutex held.  */
 static inline int nr_cpusets(void)
 {
@@ -3603,7 +3573,6 @@ cpuset_css_alloc(struct cgroup_subsys_state *parent_css)
 
        __set_bit(CS_SCHED_LOAD_BALANCE, &cs->flags);
        cpuset1_init(cs);
-       cs->relax_domain_level = -1;
 
        /* Set CS_MEMORY_MIGRATE for default hierarchy */
        if (cpuset_v2())