Skip to content

Commit 1abab1b

Browse files
Chen Ridonghtejun
authored andcommitted
cgroup/cpuset: guard cpuset-v1 code under CONFIG_CPUSETS_V1
This patch introduces CONFIG_CPUSETS_V1 and guard cpuset-v1 code under CONFIG_CPUSETS_V1. The default value of CONFIG_CPUSETS_V1 is N, so that user who adopted v2 don't have 'pay' for cpuset v1. Signed-off-by: Chen Ridong <[email protected]> Acked-by: Waiman Long <[email protected]> Signed-off-by: Tejun Heo <[email protected]>
1 parent 381b53c commit 1abab1b

File tree

5 files changed

+33
-1
lines changed

5 files changed

+33
-1
lines changed

include/linux/cpuset.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,17 @@ static inline bool cpuset_zone_allowed(struct zone *z, gfp_t gfp_mask)
9999
extern int cpuset_mems_allowed_intersects(const struct task_struct *tsk1,
100100
const struct task_struct *tsk2);
101101

102+
#ifdef CONFIG_CPUSETS_V1
102103
#define cpuset_memory_pressure_bump() \
103104
do { \
104105
if (cpuset_memory_pressure_enabled) \
105106
__cpuset_memory_pressure_bump(); \
106107
} while (0)
107108
extern int cpuset_memory_pressure_enabled;
108109
extern void __cpuset_memory_pressure_bump(void);
110+
#else
111+
static inline void cpuset_memory_pressure_bump(void) { }
112+
#endif
109113

110114
extern void cpuset_task_status_allowed(struct seq_file *m,
111115
struct task_struct *task);

init/Kconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,6 +1143,19 @@ config CPUSETS
11431143

11441144
Say N if unsure.
11451145

1146+
config CPUSETS_V1
1147+
bool "Legacy cgroup v1 cpusets controller"
1148+
depends on CPUSETS
1149+
default n
1150+
help
1151+
Legacy cgroup v1 cpusets controller which has been deprecated by
1152+
cgroup v2 implementation. The v1 is there for legacy applications
1153+
which haven't migrated to the new cgroup v2 interface yet. If you
1154+
do not have any such application then you are completely fine leaving
1155+
this option disabled.
1156+
1157+
Say N if unsure.
1158+
11461159
config PROC_PID_CPUSET
11471160
bool "Include legacy /proc/<pid>/cpuset file"
11481161
depends on CPUSETS

kernel/cgroup/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ obj-y := cgroup.o rstat.o namespace.o cgroup-v1.o freezer.o
44
obj-$(CONFIG_CGROUP_FREEZER) += legacy_freezer.o
55
obj-$(CONFIG_CGROUP_PIDS) += pids.o
66
obj-$(CONFIG_CGROUP_RDMA) += rdma.o
7-
obj-$(CONFIG_CPUSETS) += cpuset.o cpuset-v1.o
7+
obj-$(CONFIG_CPUSETS) += cpuset.o
8+
obj-$(CONFIG_CPUSETS_V1) += cpuset-v1.o
89
obj-$(CONFIG_CGROUP_MISC) += misc.o
910
obj-$(CONFIG_CGROUP_DEBUG) += debug.o

kernel/cgroup/cpuset-internal.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ int cpuset_common_seq_show(struct seq_file *sf, void *v);
279279
/*
280280
* cpuset-v1.c
281281
*/
282+
#ifdef CONFIG_CPUSETS_V1
282283
extern struct cftype cpuset1_files[];
283284
void fmeter_init(struct fmeter *fmp);
284285
void cpuset1_update_task_spread_flags(struct cpuset *cs,
@@ -288,5 +289,16 @@ void cpuset1_hotplug_update_tasks(struct cpuset *cs,
288289
struct cpumask *new_cpus, nodemask_t *new_mems,
289290
bool cpus_updated, bool mems_updated);
290291
int cpuset1_validate_change(struct cpuset *cur, struct cpuset *trial);
292+
#else
293+
static inline void fmeter_init(struct fmeter *fmp) {}
294+
static inline void cpuset1_update_task_spread_flags(struct cpuset *cs,
295+
struct task_struct *tsk) {}
296+
static inline void cpuset1_update_tasks_flags(struct cpuset *cs) {}
297+
static inline void cpuset1_hotplug_update_tasks(struct cpuset *cs,
298+
struct cpumask *new_cpus, nodemask_t *new_mems,
299+
bool cpus_updated, bool mems_updated) {}
300+
static inline int cpuset1_validate_change(struct cpuset *cur,
301+
struct cpuset *trial) { return 0; }
302+
#endif /* CONFIG_CPUSETS_V1 */
291303

292304
#endif /* __CPUSET_INTERNAL_H */

kernel/cgroup/cpuset.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3623,7 +3623,9 @@ struct cgroup_subsys cpuset_cgrp_subsys = {
36233623
.can_fork = cpuset_can_fork,
36243624
.cancel_fork = cpuset_cancel_fork,
36253625
.fork = cpuset_fork,
3626+
#ifdef CONFIG_CPUSETS_V1
36263627
.legacy_cftypes = cpuset1_files,
3628+
#endif
36273629
.dfl_cftypes = dfl_files,
36283630
.early_init = true,
36293631
.threaded = true,

0 commit comments

Comments
 (0)