]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
cpuset: add cpuset1_init helper for v1 initialization
authorChen Ridong <chenridong@huawei.com>
Thu, 18 Dec 2025 09:31:38 +0000 (09:31 +0000)
committerTejun Heo <tj@kernel.org>
Thu, 18 Dec 2025 18:36:15 +0000 (08:36 -1000)
This patch introduces the cpuset1_init helper in cpuset_v1.c to initialize
v1-specific fields, including the fmeter and relax_domain_level members.

The relax_domain_level related code will be moved to cpuset_v1.c in a
subsequent patch. After this move, v1-specific members will only be
visible 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 6c03cad02302320ed243d3dde53b04e4aa529c16..a32517da823134f02f1d042a7231dca2dcb9f53e 100644 (file)
@@ -144,8 +144,6 @@ struct cpuset {
         */
        nodemask_t old_mems_allowed;
 
-       struct fmeter fmeter;           /* memory_pressure filter */
-
        /*
         * Tasks are being attached to this cpuset.  Used to prevent
         * zeroing cpus/mems_allowed between ->can_attach() and ->attach().
@@ -181,6 +179,10 @@ struct cpuset {
 
        /* Used to merge intersecting subsets for generate_sched_domains */
        struct uf_node node;
+
+#ifdef CONFIG_CPUSETS_V1
+       struct fmeter fmeter;           /* memory_pressure filter */
+#endif
 };
 
 static inline struct cpuset *css_cs(struct cgroup_subsys_state *css)
@@ -285,7 +287,6 @@ void cpuset_full_unlock(void);
  */
 #ifdef CONFIG_CPUSETS_V1
 extern struct cftype cpuset1_files[];
-void fmeter_init(struct fmeter *fmp);
 void cpuset1_update_task_spread_flags(struct cpuset *cs,
                                        struct task_struct *tsk);
 void cpuset1_update_tasks_flags(struct cpuset *cs);
@@ -293,9 +294,9 @@ void cpuset1_hotplug_update_tasks(struct cpuset *cs,
                            struct cpumask *new_cpus, nodemask_t *new_mems,
                            bool cpus_updated, bool mems_updated);
 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);
 #else
-static inline void fmeter_init(struct fmeter *fmp) {}
 static inline void cpuset1_update_task_spread_flags(struct cpuset *cs,
                                        struct task_struct *tsk) {}
 static inline void cpuset1_update_tasks_flags(struct cpuset *cs) {}
@@ -304,6 +305,7 @@ static inline void cpuset1_hotplug_update_tasks(struct cpuset *cs,
                            bool cpus_updated, bool mems_updated) {}
 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) {}
 #endif /* CONFIG_CPUSETS_V1 */
 
index c296ce47616a83657c0123ec0350d9d6b6ffc1c3..84f00ab9c81fb7039f08341eff30b248e15154ed 100644 (file)
@@ -62,7 +62,7 @@ struct cpuset_remove_tasks_struct {
 #define FM_SCALE 1000          /* faux fixed point scale */
 
 /* Initialize a frequency meter */
-void fmeter_init(struct fmeter *fmp)
+static void fmeter_init(struct fmeter *fmp)
 {
        fmp->cnt = 0;
        fmp->val = 0;
@@ -499,6 +499,11 @@ out_unlock:
        return retval;
 }
 
+void cpuset1_init(struct cpuset *cs)
+{
+       fmeter_init(&cs->fmeter);
+}
+
 void cpuset1_online_css(struct cgroup_subsys_state *css)
 {
        struct cpuset *tmp_cs;
index 5d9dbd1aeed38d24ef66955f5955d46d7f5197d2..8ef8b75116595e75bd2d6a917d57475c79b420ff 100644 (file)
@@ -3602,7 +3602,7 @@ cpuset_css_alloc(struct cgroup_subsys_state *parent_css)
                return ERR_PTR(-ENOMEM);
 
        __set_bit(CS_SCHED_LOAD_BALANCE, &cs->flags);
-       fmeter_init(&cs->fmeter);
+       cpuset1_init(cs);
        cs->relax_domain_level = -1;
 
        /* Set CS_MEMORY_MIGRATE for default hierarchy */
@@ -3836,7 +3836,7 @@ int __init cpuset_init(void)
        cpumask_setall(top_cpuset.exclusive_cpus);
        nodes_setall(top_cpuset.effective_mems);
 
-       fmeter_init(&top_cpuset.fmeter);
+       cpuset1_init(&top_cpuset);
 
        BUG_ON(!alloc_cpumask_var(&cpus_attach, GFP_KERNEL));