Skip to content

Commit cb33f88

Browse files
Chen Ridonghtejun
authored andcommitted
cpuset: move update_domain_attr_tree to cpuset_v1.c
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>
1 parent 4ef42c6 commit cb33f88

3 files changed

Lines changed: 36 additions & 34 deletions

File tree

kernel/cgroup/cpuset-internal.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,6 @@ struct cpuset {
150150
*/
151151
int attach_in_progress;
152152

153-
/* for custom sched domain */
154-
int relax_domain_level;
155-
156153
/* partition root state */
157154
int partition_root_state;
158155

@@ -182,6 +179,9 @@ struct cpuset {
182179

183180
#ifdef CONFIG_CPUSETS_V1
184181
struct fmeter fmeter; /* memory_pressure filter */
182+
183+
/* for custom sched domain */
184+
int relax_domain_level;
185185
#endif
186186
};
187187

@@ -296,6 +296,8 @@ void cpuset1_hotplug_update_tasks(struct cpuset *cs,
296296
int cpuset1_validate_change(struct cpuset *cur, struct cpuset *trial);
297297
void cpuset1_init(struct cpuset *cs);
298298
void cpuset1_online_css(struct cgroup_subsys_state *css);
299+
void update_domain_attr_tree(struct sched_domain_attr *dattr,
300+
struct cpuset *root_cs);
299301
#else
300302
static inline void cpuset1_update_task_spread_flags(struct cpuset *cs,
301303
struct task_struct *tsk) {}
@@ -307,6 +309,9 @@ static inline int cpuset1_validate_change(struct cpuset *cur,
307309
struct cpuset *trial) { return 0; }
308310
static inline void cpuset1_init(struct cpuset *cs) {}
309311
static inline void cpuset1_online_css(struct cgroup_subsys_state *css) {}
312+
static inline void update_domain_attr_tree(struct sched_domain_attr *dattr,
313+
struct cpuset *root_cs) {}
314+
310315
#endif /* CONFIG_CPUSETS_V1 */
311316

312317
#endif /* __CPUSET_INTERNAL_H */

kernel/cgroup/cpuset-v1.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,7 @@ static int cpuset_write_u64(struct cgroup_subsys_state *css, struct cftype *cft,
502502
void cpuset1_init(struct cpuset *cs)
503503
{
504504
fmeter_init(&cs->fmeter);
505+
cs->relax_domain_level = -1;
505506
}
506507

507508
void cpuset1_online_css(struct cgroup_subsys_state *css)
@@ -552,6 +553,33 @@ void cpuset1_online_css(struct cgroup_subsys_state *css)
552553
cpuset_callback_unlock_irq();
553554
}
554555

556+
static void
557+
update_domain_attr(struct sched_domain_attr *dattr, struct cpuset *c)
558+
{
559+
if (dattr->relax_domain_level < c->relax_domain_level)
560+
dattr->relax_domain_level = c->relax_domain_level;
561+
}
562+
563+
void update_domain_attr_tree(struct sched_domain_attr *dattr,
564+
struct cpuset *root_cs)
565+
{
566+
struct cpuset *cp;
567+
struct cgroup_subsys_state *pos_css;
568+
569+
rcu_read_lock();
570+
cpuset_for_each_descendant_pre(cp, pos_css, root_cs) {
571+
/* skip the whole subtree if @cp doesn't have any CPU */
572+
if (cpumask_empty(cp->cpus_allowed)) {
573+
pos_css = css_rightmost_descendant(pos_css);
574+
continue;
575+
}
576+
577+
if (is_sched_load_balance(cp))
578+
update_domain_attr(dattr, cp);
579+
}
580+
rcu_read_unlock();
581+
}
582+
555583
/*
556584
* for the common functions, 'private' gives the type of file
557585
*/

kernel/cgroup/cpuset.c

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,6 @@ static struct cpuset top_cpuset = {
215215
.flags = BIT(CS_CPU_EXCLUSIVE) |
216216
BIT(CS_MEM_EXCLUSIVE) | BIT(CS_SCHED_LOAD_BALANCE),
217217
.partition_root_state = PRS_ROOT,
218-
.relax_domain_level = -1,
219-
.remote_partition = false,
220218
};
221219

222220
/*
@@ -755,34 +753,6 @@ static int cpusets_overlap(struct cpuset *a, struct cpuset *b)
755753
return cpumask_intersects(a->effective_cpus, b->effective_cpus);
756754
}
757755

758-
static void
759-
update_domain_attr(struct sched_domain_attr *dattr, struct cpuset *c)
760-
{
761-
if (dattr->relax_domain_level < c->relax_domain_level)
762-
dattr->relax_domain_level = c->relax_domain_level;
763-
return;
764-
}
765-
766-
static void update_domain_attr_tree(struct sched_domain_attr *dattr,
767-
struct cpuset *root_cs)
768-
{
769-
struct cpuset *cp;
770-
struct cgroup_subsys_state *pos_css;
771-
772-
rcu_read_lock();
773-
cpuset_for_each_descendant_pre(cp, pos_css, root_cs) {
774-
/* skip the whole subtree if @cp doesn't have any CPU */
775-
if (cpumask_empty(cp->cpus_allowed)) {
776-
pos_css = css_rightmost_descendant(pos_css);
777-
continue;
778-
}
779-
780-
if (is_sched_load_balance(cp))
781-
update_domain_attr(dattr, cp);
782-
}
783-
rcu_read_unlock();
784-
}
785-
786756
/* Must be called with cpuset_mutex held. */
787757
static inline int nr_cpusets(void)
788758
{
@@ -3603,7 +3573,6 @@ cpuset_css_alloc(struct cgroup_subsys_state *parent_css)
36033573

36043574
__set_bit(CS_SCHED_LOAD_BALANCE, &cs->flags);
36053575
cpuset1_init(cs);
3606-
cs->relax_domain_level = -1;
36073576

36083577
/* Set CS_MEMORY_MIGRATE for default hierarchy */
36093578
if (cpuset_v2())

0 commit comments

Comments
 (0)