Skip to content

Commit 4ef42c6

Browse files
Chen Ridonghtejun
authored andcommitted
cpuset: add cpuset1_init helper for v1 initialization
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>
1 parent 56805c1 commit 4ef42c6

3 files changed

Lines changed: 14 additions & 7 deletions

File tree

kernel/cgroup/cpuset-internal.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,6 @@ struct cpuset {
144144
*/
145145
nodemask_t old_mems_allowed;
146146

147-
struct fmeter fmeter; /* memory_pressure filter */
148-
149147
/*
150148
* Tasks are being attached to this cpuset. Used to prevent
151149
* zeroing cpus/mems_allowed between ->can_attach() and ->attach().
@@ -181,6 +179,10 @@ struct cpuset {
181179

182180
/* Used to merge intersecting subsets for generate_sched_domains */
183181
struct uf_node node;
182+
183+
#ifdef CONFIG_CPUSETS_V1
184+
struct fmeter fmeter; /* memory_pressure filter */
185+
#endif
184186
};
185187

186188
static inline struct cpuset *css_cs(struct cgroup_subsys_state *css)
@@ -285,17 +287,16 @@ void cpuset_full_unlock(void);
285287
*/
286288
#ifdef CONFIG_CPUSETS_V1
287289
extern struct cftype cpuset1_files[];
288-
void fmeter_init(struct fmeter *fmp);
289290
void cpuset1_update_task_spread_flags(struct cpuset *cs,
290291
struct task_struct *tsk);
291292
void cpuset1_update_tasks_flags(struct cpuset *cs);
292293
void cpuset1_hotplug_update_tasks(struct cpuset *cs,
293294
struct cpumask *new_cpus, nodemask_t *new_mems,
294295
bool cpus_updated, bool mems_updated);
295296
int cpuset1_validate_change(struct cpuset *cur, struct cpuset *trial);
297+
void cpuset1_init(struct cpuset *cs);
296298
void cpuset1_online_css(struct cgroup_subsys_state *css);
297299
#else
298-
static inline void fmeter_init(struct fmeter *fmp) {}
299300
static inline void cpuset1_update_task_spread_flags(struct cpuset *cs,
300301
struct task_struct *tsk) {}
301302
static inline void cpuset1_update_tasks_flags(struct cpuset *cs) {}
@@ -304,6 +305,7 @@ static inline void cpuset1_hotplug_update_tasks(struct cpuset *cs,
304305
bool cpus_updated, bool mems_updated) {}
305306
static inline int cpuset1_validate_change(struct cpuset *cur,
306307
struct cpuset *trial) { return 0; }
308+
static inline void cpuset1_init(struct cpuset *cs) {}
307309
static inline void cpuset1_online_css(struct cgroup_subsys_state *css) {}
308310
#endif /* CONFIG_CPUSETS_V1 */
309311

kernel/cgroup/cpuset-v1.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ struct cpuset_remove_tasks_struct {
6262
#define FM_SCALE 1000 /* faux fixed point scale */
6363

6464
/* Initialize a frequency meter */
65-
void fmeter_init(struct fmeter *fmp)
65+
static void fmeter_init(struct fmeter *fmp)
6666
{
6767
fmp->cnt = 0;
6868
fmp->val = 0;
@@ -499,6 +499,11 @@ static int cpuset_write_u64(struct cgroup_subsys_state *css, struct cftype *cft,
499499
return retval;
500500
}
501501

502+
void cpuset1_init(struct cpuset *cs)
503+
{
504+
fmeter_init(&cs->fmeter);
505+
}
506+
502507
void cpuset1_online_css(struct cgroup_subsys_state *css)
503508
{
504509
struct cpuset *tmp_cs;

kernel/cgroup/cpuset.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3602,7 +3602,7 @@ cpuset_css_alloc(struct cgroup_subsys_state *parent_css)
36023602
return ERR_PTR(-ENOMEM);
36033603

36043604
__set_bit(CS_SCHED_LOAD_BALANCE, &cs->flags);
3605-
fmeter_init(&cs->fmeter);
3605+
cpuset1_init(cs);
36063606
cs->relax_domain_level = -1;
36073607

36083608
/* Set CS_MEMORY_MIGRATE for default hierarchy */
@@ -3836,7 +3836,7 @@ int __init cpuset_init(void)
38363836
cpumask_setall(top_cpuset.exclusive_cpus);
38373837
nodes_setall(top_cpuset.effective_mems);
38383838

3839-
fmeter_init(&top_cpuset.fmeter);
3839+
cpuset1_init(&top_cpuset);
38403840

38413841
BUG_ON(!alloc_cpumask_var(&cpus_attach, GFP_KERNEL));
38423842

0 commit comments

Comments
 (0)