]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
cgroup/cpuset: move memory_spread to cpuset-v1.c
authorChen Ridong <chenridong@huawei.com>
Fri, 30 Aug 2024 10:02:22 +0000 (10:02 +0000)
committerTejun Heo <tj@kernel.org>
Fri, 30 Aug 2024 20:00:16 +0000 (10:00 -1000)
'memory_spread' is only set in cpuset v1. move corresponding code into
cpuset-v1.c.

Currently, 'cpuset_update_task_spread_flags' and 'update_tasks_flags' are
exposed to cpuset.c.

Signed-off-by: Chen Ridong <chenridong@huawei.com>
Acked-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 1058a45f05ecd06dd10e767da62108b07c348b1d..02c4b0c74fa9b36eb4227718b65c601fc4fdca7e 100644 (file)
@@ -248,5 +248,8 @@ int fmeter_getrate(struct fmeter *fmp);
 int cpuset_write_s64(struct cgroup_subsys_state *css, struct cftype *cft,
                            s64 val);
 s64 cpuset_read_s64(struct cgroup_subsys_state *css, struct cftype *cft);
+void cpuset_update_task_spread_flags(struct cpuset *cs,
+                                       struct task_struct *tsk);
+void update_tasks_flags(struct cpuset *cs);
 
 #endif /* __CPUSET_INTERNAL_H */
index c7b321029cbb055cc77b2381c7d985fe82c522dc..ca973b4de38a9cee607f60edd2e96718dabbe90c 100644 (file)
@@ -194,3 +194,45 @@ s64 cpuset_read_s64(struct cgroup_subsys_state *css, struct cftype *cft)
        /* Unreachable but makes gcc happy */
        return 0;
 }
+
+/*
+ * update task's spread flag if cpuset's page/slab spread flag is set
+ *
+ * Call with callback_lock or cpuset_mutex held. The check can be skipped
+ * if on default hierarchy.
+ */
+void cpuset_update_task_spread_flags(struct cpuset *cs,
+                                       struct task_struct *tsk)
+{
+       if (cgroup_subsys_on_dfl(cpuset_cgrp_subsys))
+               return;
+
+       if (is_spread_page(cs))
+               task_set_spread_page(tsk);
+       else
+               task_clear_spread_page(tsk);
+
+       if (is_spread_slab(cs))
+               task_set_spread_slab(tsk);
+       else
+               task_clear_spread_slab(tsk);
+}
+
+/**
+ * update_tasks_flags - update the spread flags of tasks in the cpuset.
+ * @cs: the cpuset in which each task's spread flags needs to be changed
+ *
+ * Iterate through each task of @cs updating its spread flags.  As this
+ * function is called with cpuset_mutex held, cpuset membership stays
+ * stable.
+ */
+void update_tasks_flags(struct cpuset *cs)
+{
+       struct css_task_iter it;
+       struct task_struct *task;
+
+       css_task_iter_start(&cs->css, 0, &it);
+       while ((task = css_task_iter_next(&it)))
+               cpuset_update_task_spread_flags(cs, task);
+       css_task_iter_end(&it);
+}
index c4d165fc0f70872a2ec87bce25648b5dd538cff9..c77f35fb83478d448a7bbb4aee53bfb5b9d756c3 100644 (file)
@@ -407,29 +407,6 @@ static void guarantee_online_mems(struct cpuset *cs, nodemask_t *pmask)
        nodes_and(*pmask, cs->effective_mems, node_states[N_MEMORY]);
 }
 
-/*
- * update task's spread flag if cpuset's page/slab spread flag is set
- *
- * Call with callback_lock or cpuset_mutex held. The check can be skipped
- * if on default hierarchy.
- */
-static void cpuset_update_task_spread_flags(struct cpuset *cs,
-                                       struct task_struct *tsk)
-{
-       if (cgroup_subsys_on_dfl(cpuset_cgrp_subsys))
-               return;
-
-       if (is_spread_page(cs))
-               task_set_spread_page(tsk);
-       else
-               task_clear_spread_page(tsk);
-
-       if (is_spread_slab(cs))
-               task_set_spread_slab(tsk);
-       else
-               task_clear_spread_slab(tsk);
-}
-
 /*
  * is_cpuset_subset(p, q) - Is cpuset p a subset of cpuset q?
  *
@@ -2794,25 +2771,6 @@ bool current_cpuset_is_being_rebound(void)
        return ret;
 }
 
-/**
- * update_tasks_flags - update the spread flags of tasks in the cpuset.
- * @cs: the cpuset in which each task's spread flags needs to be changed
- *
- * Iterate through each task of @cs updating its spread flags.  As this
- * function is called with cpuset_mutex held, cpuset membership stays
- * stable.
- */
-static void update_tasks_flags(struct cpuset *cs)
-{
-       struct css_task_iter it;
-       struct task_struct *task;
-
-       css_task_iter_start(&cs->css, 0, &it);
-       while ((task = css_task_iter_next(&it)))
-               cpuset_update_task_spread_flags(cs, task);
-       css_task_iter_end(&it);
-}
-
 /*
  * update_flag - read a 0 or a 1 in a file and update associated flag
  * bit:                the bit to update (see cpuset_flagbits_t)