Skip to content

Commit dae68fb

Browse files
Werkovhtejun
authored andcommitted
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>
1 parent 4a6780a commit dae68fb

3 files changed

Lines changed: 44 additions & 47 deletions

File tree

init/Kconfig

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

11891190
Say N if unsure.
11901191

11911192
config PROC_PID_CPUSET
11921193
bool "Include legacy /proc/<pid>/cpuset file"
1193-
depends on CPUSETS
1194+
depends on CPUSETS_V1
11941195
default y
11951196

11961197
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>
@@ -4244,50 +4243,6 @@ void cpuset_print_current_mems_allowed(void)
42444243
rcu_read_unlock();
42454244
}
42464245

4247-
#ifdef CONFIG_PROC_PID_CPUSET
4248-
/*
4249-
* proc_cpuset_show()
4250-
* - Print tasks cpuset path into seq_file.
4251-
* - Used for /proc/<pid>/cpuset.
4252-
* - No need to task_lock(tsk) on this tsk->cpuset reference, as it
4253-
* doesn't really matter if tsk->cpuset changes after we read it,
4254-
* and we take cpuset_mutex, keeping cpuset_attach() from changing it
4255-
* anyway.
4256-
*/
4257-
int proc_cpuset_show(struct seq_file *m, struct pid_namespace *ns,
4258-
struct pid *pid, struct task_struct *tsk)
4259-
{
4260-
char *buf;
4261-
struct cgroup_subsys_state *css;
4262-
int retval;
4263-
4264-
retval = -ENOMEM;
4265-
buf = kmalloc(PATH_MAX, GFP_KERNEL);
4266-
if (!buf)
4267-
goto out;
4268-
4269-
rcu_read_lock();
4270-
spin_lock_irq(&css_set_lock);
4271-
css = task_css(tsk, cpuset_cgrp_id);
4272-
retval = cgroup_path_ns_locked(css->cgroup, buf, PATH_MAX,
4273-
current->nsproxy->cgroup_ns);
4274-
spin_unlock_irq(&css_set_lock);
4275-
rcu_read_unlock();
4276-
4277-
if (retval == -E2BIG)
4278-
retval = -ENAMETOOLONG;
4279-
if (retval < 0)
4280-
goto out_free;
4281-
seq_puts(m, buf);
4282-
seq_putc(m, '\n');
4283-
retval = 0;
4284-
out_free:
4285-
kfree(buf);
4286-
out:
4287-
return retval;
4288-
}
4289-
#endif /* CONFIG_PROC_PID_CPUSET */
4290-
42914246
/* Display task mems_allowed in /proc/<pid>/status file. */
42924247
void cpuset_task_status_allowed(struct seq_file *m, struct task_struct *task)
42934248
{

0 commit comments

Comments
 (0)