Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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.

Signed-off-by: Michal Koutný <mkoutny@suse.com>
Acked-by: Waiman Long <longman@redhat.com>
Signed-off-by: Tejun Heo <tj@kernel.org>

authored by

Michal Koutný and committed by
Tejun Heo
dae68fba 4a6780a3

+44 -47
+3 -2
init/Kconfig
··· 1182 1182 help 1183 1183 Legacy cgroup v1 cpusets controller which has been deprecated by 1184 1184 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 1186 1187 do not have any such application then you are completely fine leaving 1187 1188 this option disabled. 1188 1189 ··· 1191 1190 1192 1191 config PROC_PID_CPUSET 1193 1192 bool "Include legacy /proc/<pid>/cpuset file" 1194 - depends on CPUSETS 1193 + depends on CPUSETS_V1 1195 1194 default y 1196 1195 1197 1196 config CGROUP_DEVICE
+41
kernel/cgroup/cpuset-v1.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0-or-later 2 2 3 + #include "cgroup-internal.h" 3 4 #include "cpuset-internal.h" 4 5 5 6 /* ··· 373 372 out: 374 373 return ret; 375 374 } 375 + 376 + #ifdef CONFIG_PROC_PID_CPUSET 377 + /* 378 + * proc_cpuset_show() 379 + * - Print tasks cpuset path into seq_file. 380 + * - Used for /proc/<pid>/cpuset. 381 + */ 382 + int proc_cpuset_show(struct seq_file *m, struct pid_namespace *ns, 383 + struct pid *pid, struct task_struct *tsk) 384 + { 385 + char *buf; 386 + struct cgroup_subsys_state *css; 387 + int retval; 388 + 389 + retval = -ENOMEM; 390 + buf = kmalloc(PATH_MAX, GFP_KERNEL); 391 + if (!buf) 392 + goto out; 393 + 394 + rcu_read_lock(); 395 + spin_lock_irq(&css_set_lock); 396 + css = task_css(tsk, cpuset_cgrp_id); 397 + retval = cgroup_path_ns_locked(css->cgroup, buf, PATH_MAX, 398 + current->nsproxy->cgroup_ns); 399 + spin_unlock_irq(&css_set_lock); 400 + rcu_read_unlock(); 401 + 402 + if (retval == -E2BIG) 403 + retval = -ENAMETOOLONG; 404 + if (retval < 0) 405 + goto out_free; 406 + seq_puts(m, buf); 407 + seq_putc(m, '\n'); 408 + retval = 0; 409 + out_free: 410 + kfree(buf); 411 + out: 412 + return retval; 413 + } 414 + #endif /* CONFIG_PROC_PID_CPUSET */ 376 415 377 416 static u64 cpuset_read_u64(struct cgroup_subsys_state *css, struct cftype *cft) 378 417 {
-45
kernel/cgroup/cpuset.c
··· 21 21 * License. See the file COPYING in the main directory of the Linux 22 22 * distribution for more details. 23 23 */ 24 - #include "cgroup-internal.h" 25 24 #include "cpuset-internal.h" 26 25 27 26 #include <linux/init.h> ··· 4242 4243 4243 4244 rcu_read_unlock(); 4244 4245 } 4245 - 4246 - #ifdef CONFIG_PROC_PID_CPUSET 4247 - /* 4248 - * proc_cpuset_show() 4249 - * - Print tasks cpuset path into seq_file. 4250 - * - Used for /proc/<pid>/cpuset. 4251 - * - No need to task_lock(tsk) on this tsk->cpuset reference, as it 4252 - * doesn't really matter if tsk->cpuset changes after we read it, 4253 - * and we take cpuset_mutex, keeping cpuset_attach() from changing it 4254 - * anyway. 4255 - */ 4256 - int proc_cpuset_show(struct seq_file *m, struct pid_namespace *ns, 4257 - struct pid *pid, struct task_struct *tsk) 4258 - { 4259 - char *buf; 4260 - struct cgroup_subsys_state *css; 4261 - int retval; 4262 - 4263 - retval = -ENOMEM; 4264 - buf = kmalloc(PATH_MAX, GFP_KERNEL); 4265 - if (!buf) 4266 - goto out; 4267 - 4268 - rcu_read_lock(); 4269 - spin_lock_irq(&css_set_lock); 4270 - css = task_css(tsk, cpuset_cgrp_id); 4271 - retval = cgroup_path_ns_locked(css->cgroup, buf, PATH_MAX, 4272 - current->nsproxy->cgroup_ns); 4273 - spin_unlock_irq(&css_set_lock); 4274 - rcu_read_unlock(); 4275 - 4276 - if (retval == -E2BIG) 4277 - retval = -ENAMETOOLONG; 4278 - if (retval < 0) 4279 - goto out_free; 4280 - seq_puts(m, buf); 4281 - seq_putc(m, '\n'); 4282 - retval = 0; 4283 - out_free: 4284 - kfree(buf); 4285 - out: 4286 - return retval; 4287 - } 4288 - #endif /* CONFIG_PROC_PID_CPUSET */ 4289 4246 4290 4247 /* Display task mems_allowed in /proc/<pid>/status file. */ 4291 4248 void cpuset_task_status_allowed(struct seq_file *m, struct task_struct *task)