Skip to content

Commit 6c552bf

Browse files
committed
cgroup/cpuset: Move procfs cpuset attribute under cgroup-v1.c
JIRA: https://issues.redhat.com/browse/RHEL-80382 commit dae68fb Author: Michal Koutný <mkoutny@suse.com> Date: Mon Jan 20 15:57:49 2025 +0100 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 b0ced9d ("cgroup/cpuset: move v1 interfaces to cpuset-v1.c") and hide CONFIG_PROC_PID_CPUSET under CONFIG_CPUSETS_V1. Drop an obsolete comment too. Signed-off-by: Michal Koutný <mkoutny@suse.com> Acked-by: Waiman Long <longman@redhat.com> Signed-off-by: Tejun Heo <tj@kernel.org> Signed-off-by: Radostin Stoyanov <rstoyano@redhat.com>
1 parent 3602b2f commit 6c552bf

File tree

3 files changed

+44
-47
lines changed

3 files changed

+44
-47
lines changed

init/Kconfig

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,15 +1130,16 @@ config CPUSETS_V1
11301130
help
11311131
Legacy cgroup v1 cpusets controller which has been deprecated by
11321132
cgroup v2 implementation. The v1 is there for legacy applications
1133-
which haven't migrated to the new cgroup v2 interface yet. If you
1133+
which haven't migrated to the new cgroup v2 interface yet. Legacy
1134+
interface includes cpuset filesystem and /proc/<pid>/cpuset. If you
11341135
do not have any such application then you are completely fine leaving
11351136
this option disabled.
11361137

11371138
Say N if unsure.
11381139

11391140
config PROC_PID_CPUSET
11401141
bool "Include legacy /proc/<pid>/cpuset file"
1141-
depends on CPUSETS
1142+
depends on CPUSETS_V1
11421143
default y
11431144

11441145
config CGROUP_DEVICE

kernel/cgroup/cpuset-v1.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// SPDX-License-Identifier: GPL-2.0-or-later
22

3+
#include "cgroup-internal.h"
34
#include "cpuset-internal.h"
45

56
/*
@@ -373,6 +374,46 @@ int cpuset1_validate_change(struct cpuset *cur, struct cpuset *trial)
373374
return ret;
374375
}
375376

377+
#ifdef CONFIG_PROC_PID_CPUSET
378+
/*
379+
* proc_cpuset_show()
380+
* - Print tasks cpuset path into seq_file.
381+
* - Used for /proc/<pid>/cpuset.
382+
*/
383+
int proc_cpuset_show(struct seq_file *m, struct pid_namespace *ns,
384+
struct pid *pid, struct task_struct *tsk)
385+
{
386+
char *buf;
387+
struct cgroup_subsys_state *css;
388+
int retval;
389+
390+
retval = -ENOMEM;
391+
buf = kmalloc(PATH_MAX, GFP_KERNEL);
392+
if (!buf)
393+
goto out;
394+
395+
rcu_read_lock();
396+
spin_lock_irq(&css_set_lock);
397+
css = task_css(tsk, cpuset_cgrp_id);
398+
retval = cgroup_path_ns_locked(css->cgroup, buf, PATH_MAX,
399+
current->nsproxy->cgroup_ns);
400+
spin_unlock_irq(&css_set_lock);
401+
rcu_read_unlock();
402+
403+
if (retval == -E2BIG)
404+
retval = -ENAMETOOLONG;
405+
if (retval < 0)
406+
goto out_free;
407+
seq_puts(m, buf);
408+
seq_putc(m, '\n');
409+
retval = 0;
410+
out_free:
411+
kfree(buf);
412+
out:
413+
return retval;
414+
}
415+
#endif /* CONFIG_PROC_PID_CPUSET */
416+
376417
static u64 cpuset_read_u64(struct cgroup_subsys_state *css, struct cftype *cft)
377418
{
378419
struct cpuset *cs = css_cs(css);

kernel/cgroup/cpuset.c

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
* License. See the file COPYING in the main directory of the Linux
2222
* distribution for more details.
2323
*/
24-
#include "cgroup-internal.h"
2524
#include "cpuset-internal.h"
2625

2726
#include <linux/init.h>
@@ -4350,50 +4349,6 @@ void cpuset_print_current_mems_allowed(void)
43504349
rcu_read_unlock();
43514350
}
43524351

4353-
#ifdef CONFIG_PROC_PID_CPUSET
4354-
/*
4355-
* proc_cpuset_show()
4356-
* - Print tasks cpuset path into seq_file.
4357-
* - Used for /proc/<pid>/cpuset.
4358-
* - No need to task_lock(tsk) on this tsk->cpuset reference, as it
4359-
* doesn't really matter if tsk->cpuset changes after we read it,
4360-
* and we take cpuset_mutex, keeping cpuset_attach() from changing it
4361-
* anyway.
4362-
*/
4363-
int proc_cpuset_show(struct seq_file *m, struct pid_namespace *ns,
4364-
struct pid *pid, struct task_struct *tsk)
4365-
{
4366-
char *buf;
4367-
struct cgroup_subsys_state *css;
4368-
int retval;
4369-
4370-
retval = -ENOMEM;
4371-
buf = kmalloc(PATH_MAX, GFP_KERNEL);
4372-
if (!buf)
4373-
goto out;
4374-
4375-
rcu_read_lock();
4376-
spin_lock_irq(&css_set_lock);
4377-
css = task_css(tsk, cpuset_cgrp_id);
4378-
retval = cgroup_path_ns_locked(css->cgroup, buf, PATH_MAX,
4379-
current->nsproxy->cgroup_ns);
4380-
spin_unlock_irq(&css_set_lock);
4381-
rcu_read_unlock();
4382-
4383-
if (retval == -E2BIG)
4384-
retval = -ENAMETOOLONG;
4385-
if (retval < 0)
4386-
goto out_free;
4387-
seq_puts(m, buf);
4388-
seq_putc(m, '\n');
4389-
retval = 0;
4390-
out_free:
4391-
kfree(buf);
4392-
out:
4393-
return retval;
4394-
}
4395-
#endif /* CONFIG_PROC_PID_CPUSET */
4396-
43974352
/* Display task mems_allowed in /proc/<pid>/status file. */
43984353
void cpuset_task_status_allowed(struct seq_file *m, struct task_struct *task)
43994354
{

0 commit comments

Comments
 (0)