From: Chen Ridong <chenridong@huawei.com>
To: <tj@kernel.org>, <lizefan.x@bytedance.com>, <hannes@cmpxchg.org>,
<longman@redhat.com>, <adityakali@google.com>,
<sergeh@kernel.org>, <mkoutny@suse.com>
Cc: <cgroups@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<chenridong@huaweicloud.com>
Subject: [PATCH v2 -next 10/11] cgroup/cpuset: guard cpuset-v1 code under CONFIG_CPUSETS_V1
Date: Mon, 26 Aug 2024 13:27:02 +0000 [thread overview]
Message-ID: <20240826132703.558956-11-chenridong@huawei.com> (raw)
In-Reply-To: <20240826132703.558956-1-chenridong@huawei.com>
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 <chenridong@huawei.com>
---
include/linux/cpuset.h | 4 ++++
init/Kconfig | 13 +++++++++++++
kernel/cgroup/Makefile | 3 ++-
kernel/cgroup/cpuset-internal.h | 13 +++++++++++++
kernel/cgroup/cpuset.c | 2 ++
5 files changed, 34 insertions(+), 1 deletion(-)
diff --git a/include/linux/cpuset.h b/include/linux/cpuset.h
index 2a6981eeebf8..835e7b793f6a 100644
--- a/include/linux/cpuset.h
+++ b/include/linux/cpuset.h
@@ -99,6 +99,7 @@ static inline bool cpuset_zone_allowed(struct zone *z, gfp_t gfp_mask)
extern int cpuset_mems_allowed_intersects(const struct task_struct *tsk1,
const struct task_struct *tsk2);
+#ifdef CONFIG_CPUSETS_V1
#define cpuset_memory_pressure_bump() \
do { \
if (cpuset_memory_pressure_enabled) \
@@ -106,6 +107,9 @@ extern int cpuset_mems_allowed_intersects(const struct task_struct *tsk1,
} while (0)
extern int cpuset_memory_pressure_enabled;
extern void __cpuset_memory_pressure_bump(void);
+#else
+static inline void cpuset_memory_pressure_bump(void) { }
+#endif
extern void cpuset_task_status_allowed(struct seq_file *m,
struct task_struct *task);
diff --git a/init/Kconfig b/init/Kconfig
index a465ea9525bd..8bf091354bea 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1143,6 +1143,19 @@ config CPUSETS
Say N if unsure.
+config CPUSETS_V1
+ bool "Legacy cgroup v1 cpusets controller"
+ depends on CPUSETS
+ default n
+ help
+ Legacy cgroup v1 cpusets controller which has been deprecated by
+ cgroup v2 implementation. The v1 is there for legacy applications
+ which haven't migrated to the new cgroup v2 interface yet. If you
+ do not have any such application then you are completely fine leaving
+ this option disabled.
+
+ Say N if unsure.
+
config PROC_PID_CPUSET
bool "Include legacy /proc/<pid>/cpuset file"
depends on CPUSETS
diff --git a/kernel/cgroup/Makefile b/kernel/cgroup/Makefile
index 005ac4c675cb..a5c9359d516f 100644
--- a/kernel/cgroup/Makefile
+++ b/kernel/cgroup/Makefile
@@ -4,6 +4,7 @@ obj-y := cgroup.o rstat.o namespace.o cgroup-v1.o freezer.o
obj-$(CONFIG_CGROUP_FREEZER) += legacy_freezer.o
obj-$(CONFIG_CGROUP_PIDS) += pids.o
obj-$(CONFIG_CGROUP_RDMA) += rdma.o
-obj-$(CONFIG_CPUSETS) += cpuset.o cpuset-v1.o
+obj-$(CONFIG_CPUSETS) += cpuset.o
+obj-$(CONFIG_CPUSETS_V1) += cpuset-v1.o
obj-$(CONFIG_CGROUP_MISC) += misc.o
obj-$(CONFIG_CGROUP_DEBUG) += debug.o
diff --git a/kernel/cgroup/cpuset-internal.h b/kernel/cgroup/cpuset-internal.h
index a6c71c86e58d..7ec702dff877 100644
--- a/kernel/cgroup/cpuset-internal.h
+++ b/kernel/cgroup/cpuset-internal.h
@@ -279,6 +279,7 @@ int cpuset_common_seq_show(struct seq_file *sf, void *v);
/*
* cpuset-v1.c
*/
+#ifdef CONFIG_CPUSETS_V1
extern struct cftype legacy_files[];
void fmeter_init(struct fmeter *fmp);
void cpuset_update_task_spread_flags(struct cpuset *cs,
@@ -289,4 +290,16 @@ void hotplug_update_tasks_legacy(struct cpuset *cs,
bool cpus_updated, bool mems_updated);
int validate_change_legacy(struct cpuset *cur, struct cpuset *trial);
+#else
+static inline void fmeter_init(struct fmeter *fmp) {}
+static inline void cpuset_update_task_spread_flags(struct cpuset *cs,
+ struct task_struct *tsk) {}
+static inline void update_tasks_flags(struct cpuset *cs) {}
+static inline void hotplug_update_tasks_legacy(struct cpuset *cs,
+ struct cpumask *new_cpus, nodemask_t *new_mems,
+ bool cpus_updated, bool mems_updated) {}
+static inline int validate_change_legacy(struct cpuset *cur,
+ struct cpuset *trial) { return 0; }
+
+#endif /* CONFIG_CPUSETS_V1 */
#endif /* __CPUSET_INTERNAL_H */
diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
index 2f52fe488f3a..2cefeaaff742 100644
--- a/kernel/cgroup/cpuset.c
+++ b/kernel/cgroup/cpuset.c
@@ -3617,7 +3617,9 @@ struct cgroup_subsys cpuset_cgrp_subsys = {
.can_fork = cpuset_can_fork,
.cancel_fork = cpuset_cancel_fork,
.fork = cpuset_fork,
+#ifdef CONFIG_CPUSETS_V1
.legacy_cftypes = legacy_files,
+#endif
.dfl_cftypes = dfl_files,
.early_init = true,
.threaded = true,
--
2.34.1
next prev parent reply other threads:[~2024-08-26 13:34 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-26 13:26 [PATCH v2 -next 00/11] cgroup:cpuset:separate legacy cgroup v1 code and put under config option Chen Ridong
2024-08-26 13:26 ` [PATCH v2 -next 01/11] cgroup/cpuset: introduce cpuset-v1.c Chen Ridong
2024-08-26 19:07 ` Waiman Long
2024-08-27 1:45 ` Chen Ridong
2024-08-26 13:26 ` [PATCH v2 -next 02/11] cgroup/cpuset: move common code to cpuset-internal.h Chen Ridong
2024-08-26 13:26 ` [PATCH v2 -next 03/11] cgroup/cpuset: move memory_pressure to cpuset-v1.c Chen Ridong
2024-08-26 13:26 ` [PATCH v2 -next 04/11] cgroup/cpuset: move relax_domain_level " Chen Ridong
2024-08-26 13:26 ` [PATCH v2 -next 05/11] cgroup/cpuset: move memory_spread " Chen Ridong
2024-08-26 13:26 ` [PATCH v2 -next 06/11] cgroup/cpuset: add callback_lock helper Chen Ridong
2024-08-26 13:26 ` [PATCH v2 -next 07/11] cgroup/cpuset: move legacy hotplug update to cpuset-v1.c Chen Ridong
2024-08-26 13:27 ` [PATCH v2 -next 08/11] cgroup/cpuset: move validate_change_legacy " Chen Ridong
2024-08-26 13:27 ` [PATCH v2 -next 09/11] cgroup/cpuset: move v1 interfaces " Chen Ridong
2024-08-26 19:30 ` Waiman Long
2024-08-26 19:40 ` Tejun Heo
2024-08-26 19:47 ` Waiman Long
2024-08-27 1:47 ` chenridong
2024-08-26 13:27 ` Chen Ridong [this message]
2024-08-26 13:27 ` [PATCH v2 -next 11/11] cgroup/cpuset: add sefltest for cpuset v1 Chen Ridong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240826132703.558956-11-chenridong@huawei.com \
--to=chenridong@huawei.com \
--cc=adityakali@google.com \
--cc=cgroups@vger.kernel.org \
--cc=chenridong@huaweicloud.com \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lizefan.x@bytedance.com \
--cc=longman@redhat.com \
--cc=mkoutny@suse.com \
--cc=sergeh@kernel.org \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox