Skip to contentSkip to conversation

cgroup/cpuset: Move procfs cpuset attribute under cgroup-v1.c

PATCH Applied Michal Koutný 3 participants 3 messages Jan 20, 2025 – Jan 24, 2025

Subsystems (2)
lore
Share & tools
lore

Michal Koutný

author maintainer
#0 lore raw

PATCH v3 1/1 cgroup/cpuset: Move procfs cpuset attribute under cgroup-v1.c

The cpuset file is a legacy attribute that is bound primarily to cpuset v1 hierarchy (equivalent information is available in /proc/$pid/cgroup path on the unified hierarchy in conjunction with respective cgroup.controllers showing where cpuset controller is enabled).

Followup to commit b0ced9d378d49 ("cgroup/cpuset: move v1 interfaces to cpuset-v1.c") and hide CONFIG_PROC_PID_CPUSET under CONFIG_CPUSETS_V1. Drop an obsolete comment too.

---
 init/Kconfig              |  5 +++--
 kernel/cgroup/cpuset-v1.c | 41 +++++++++++++++++++++++++++++++++++
 kernel/cgroup/cpuset.c    | 45 ---------------------------------------
 3 files changed, 44 insertions(+), 47 deletions(-)

v3 changes:
- move dependency on internal cgroup-internal.h to v1-only too

v2 changes:
- explicitly say what's part of CPUSETS_V1
- commit message wrt effective paths

init/Kconfig +3 -2
index a20e6efd3f0fb..2f3121c49ed23 100644
@@ -1182,7 +1182,8 @@ config CPUSETS_V1
 	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
+	  which haven't migrated to the new cgroup v2 interface yet. Legacy
+	  interface includes cpuset filesystem and /proc/<pid>/cpuset. If you
 	  do not have any such application then you are completely fine leaving
 	  this option disabled.
 
@@ -1190,7 +1191,7 @@ config CPUSETS_V1
 
 config PROC_PID_CPUSET
 	bool "Include legacy /proc/<pid>/cpuset file"
-	depends on CPUSETS
+	depends on CPUSETS_V1
 	default y
 
 config CGROUP_DEVICE
kernel/cgroup/cpuset-v1.c +41 -0

52 lines not on this page · raw message

kernel/cgroup/cpuset.c +0 -45

57 lines not on this page · raw message

Signature · 1 line
2.47.1
Acked-by on v3 1/1
#1 lore raw
Quoted 16 lines · Michal Koutný

The cpuset file is a legacy attribute that is bound primarily to cpuset v1 hierarchy (equivalent information is available in /proc/$pid/cgroup path on the unified hierarchy in conjunction with respective cgroup.controllers showing where cpuset controller is enabled).

Followup to commit b0ced9d378d49 ("cgroup/cpuset: move v1 interfaces to cpuset-v1.c") and hide CONFIG_PROC_PID_CPUSET under CONFIG_CPUSETS_V1. Drop an obsolete comment too.

---
  init/Kconfig              |  5 +++--
  kernel/cgroup/cpuset-v1.c | 41 +++++++++++++++++++++++++++++++++++
  kernel/cgroup/cpuset.c    | 45 ---------------------------------------
  3 files changed, 44 insertions(+), 47 deletions(-)
Quoted 8 lines

v3 changes:
- move dependency on internal cgroup-internal.h to v1-only too

v2 changes:
- explicitly say what's part of CPUSETS_V1
- commit message wrt effective paths

Quoted 145 lines
init/Kconfig +3 -2
index a20e6efd3f0fb..2f3121c49ed23 100644
@@ -1182,7 +1182,8 @@ config CPUSETS_V1
  	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
+	  which haven't migrated to the new cgroup v2 interface yet. Legacy
+	  interface includes cpuset filesystem and /proc/<pid>/cpuset. If you
  	  do not have any such application then you are completely fine leaving
  	  this option disabled.
 
@@ -1190,7 +1191,7 @@ config CPUSETS_V1
 
  config PROC_PID_CPUSET
  	bool "Include legacy /proc/<pid>/cpuset file"
-	depends on CPUSETS
+	depends on CPUSETS_V1
  	default y
 
  config CGROUP_DEVICE
kernel/cgroup/cpuset-v1.c +41 -0
index 25c1d7b77e2f2..81b5e2a50d587 100644
@@ -1,5 +1,6 @@
  // SPDX-License-Identifier: GPL-2.0-or-later
 
+#include "cgroup-internal.h"
  #include "cpuset-internal.h"
 
  /*
@@ -373,6 +374,46 @@ int cpuset1_validate_change(struct cpuset *cur, struct cpuset *trial)
  	return ret;
  }
 
+#ifdef CONFIG_PROC_PID_CPUSET
+/*
+ * proc_cpuset_show()
+ *  - Print tasks cpuset path into seq_file.
+ *  - Used for /proc/<pid>/cpuset.
+ */
+int proc_cpuset_show(struct seq_file *m, struct pid_namespace *ns,
+		     struct pid *pid, struct task_struct *tsk)
+{
+	char *buf;
+	struct cgroup_subsys_state *css;
+	int retval;
+
+	retval = -ENOMEM;
+	buf = kmalloc(PATH_MAX, GFP_KERNEL);
+	if (!buf)
+		goto out;
+
+	rcu_read_lock();
+	spin_lock_irq(&css_set_lock);
+	css = task_css(tsk, cpuset_cgrp_id);
+	retval = cgroup_path_ns_locked(css->cgroup, buf, PATH_MAX,
+				       current->nsproxy->cgroup_ns);
+	spin_unlock_irq(&css_set_lock);
+	rcu_read_unlock();
+
+	if (retval == -E2BIG)
+		retval = -ENAMETOOLONG;
+	if (retval < 0)
+		goto out_free;
+	seq_puts(m, buf);
+	seq_putc(m, '\n');
+	retval = 0;
+out_free:
+	kfree(buf);
+out:
+	return retval;
+}
+#endif /* CONFIG_PROC_PID_CPUSET */
+
  static u64 cpuset_read_u64(struct cgroup_subsys_state *css, struct cftype *cft)
  {
  	struct cpuset *cs = css_cs(css);
kernel/cgroup/cpuset.c +0 -45
index 0f910c828973a..5a637292faa20 100644
@@ -21,7 +21,6 @@
   *  License.  See the file COPYING in the main directory of the Linux
   *  distribution for more details.
   */
-#include "cgroup-internal.h"
  #include "cpuset-internal.h"
 
  #include <linux/init.h>
@@ -4244,50 +4243,6 @@ void cpuset_print_current_mems_allowed(void)
  	rcu_read_unlock();
  }
 
-#ifdef CONFIG_PROC_PID_CPUSET
-/*
- * proc_cpuset_show()
- *  - Print tasks cpuset path into seq_file.
- *  - Used for /proc/<pid>/cpuset.
- *  - No need to task_lock(tsk) on this tsk->cpuset reference, as it
- *    doesn't really matter if tsk->cpuset changes after we read it,
- *    and we take cpuset_mutex, keeping cpuset_attach() from changing it
- *    anyway.
- */
-int proc_cpuset_show(struct seq_file *m, struct pid_namespace *ns,
-		     struct pid *pid, struct task_struct *tsk)
-{
-	char *buf;
-	struct cgroup_subsys_state *css;
-	int retval;
-
-	retval = -ENOMEM;
-	buf = kmalloc(PATH_MAX, GFP_KERNEL);
-	if (!buf)
-		goto out;
-
-	rcu_read_lock();
-	spin_lock_irq(&css_set_lock);
-	css = task_css(tsk, cpuset_cgrp_id);
-	retval = cgroup_path_ns_locked(css->cgroup, buf, PATH_MAX,
-				       current->nsproxy->cgroup_ns);
-	spin_unlock_irq(&css_set_lock);
-	rcu_read_unlock();
-
-	if (retval == -E2BIG)
-		retval = -ENAMETOOLONG;
-	if (retval < 0)
-		goto out_free;
-	seq_puts(m, buf);
-	seq_putc(m, '\n');
-	retval = 0;
-out_free:
-	kfree(buf);
-out:
-	return retval;
-}
-#endif /* CONFIG_PROC_PID_CPUSET */
-
  /* Display task mems_allowed in /proc/<pid>/status file. */
  void cpuset_task_status_allowed(struct seq_file *m, struct task_struct *task)
  {
maintainer Applied
#2 lore raw
In reply to Michal Koutný
Quoted 10 lines · Michal Koutný

The cpuset file is a legacy attribute that is bound primarily to cpuset v1 hierarchy (equivalent information is available in /proc/$pid/cgroup path on the unified hierarchy in conjunction with respective cgroup.controllers showing where cpuset controller is enabled).

Followup to commit b0ced9d378d49 ("cgroup/cpuset: move v1 interfaces to cpuset-v1.c") and hide CONFIG_PROC_PID_CPUSET under CONFIG_CPUSETS_V1. Drop an obsolete comment too.

Applied to cgroup/for-6.15.

Thanks.

Signature · 1 line
tejun