cpuset: remove /proc/PID/cpuset
Subsystems (5)
RFC PATCH 1/1 cpuset: remove /proc/PID/cpuset
From: Chunguang Xu <[email protected]>
Now we can get all cgroup paths from /proc/PID/cgroup for a long time, so it maybe useless to keep /proc/PID/cpuset, besides the path get from /proc/PID/cpuset is not consistent with /proc/PID/cgroup in default hierarchy, so now we may can safely remove /proc/PID/cpuset to avoid the mismatch.
root@test:~# cat /proc/1186/cgroup 0::/system.slice/lmeter.service
root@test:~# cat /proc/1186/cpuset /system.slice
--- arch/mips/configs/sb1250_swarm_defconfig | 1 - arch/sh/configs/sdk7786_defconfig | 1 - arch/sh/configs/urquell_defconfig | 1 - fs/proc/base.c | 6 ---- kernel/cgroup/cpuset.c | 40 ------------------------ 5 files changed, 49 deletions(-)
arch/mips/configs/sb1250_swarm_defconfig +0 -1
@@ -3,7 +3,6 @@ CONFIG_HIGH_RES_TIMERS=y CONFIG_LOG_BUF_SHIFT=15 CONFIG_CGROUPS=y CONFIG_CPUSETS=y -# CONFIG_PROC_PID_CPUSET is not set CONFIG_CGROUP_CPUACCT=y CONFIG_NAMESPACES=y CONFIG_RELAY=y
arch/sh/configs/sdk7786_defconfig +0 -1
@@ -13,7 +13,6 @@ CONFIG_CGROUP_DEBUG=y CONFIG_CGROUP_FREEZER=y CONFIG_CGROUP_DEVICE=y CONFIG_CPUSETS=y -# CONFIG_PROC_PID_CPUSET is not set CONFIG_CGROUP_CPUACCT=y CONFIG_CGROUP_MEMCG=y CONFIG_CGROUP_SCHED=y
arch/sh/configs/urquell_defconfig +0 -1
@@ -11,7 +11,6 @@ CONFIG_CGROUP_DEBUG=y CONFIG_CGROUP_FREEZER=y CONFIG_CGROUP_DEVICE=y CONFIG_CPUSETS=y -# CONFIG_PROC_PID_CPUSET is not set CONFIG_CGROUP_CPUACCT=y CONFIG_CGROUP_MEMCG=y CONFIG_CGROUP_SCHED=y
fs/proc/base.c +0 -6
@@ -3309,9 +3309,6 @@ static const struct pid_entry tgid_base_stuff[] = {#ifdef CONFIG_LATENCYTOP REG("latency", S_IRUGO, proc_lstats_operations),#endif -#ifdef CONFIG_PROC_PID_CPUSET - ONE("cpuset", S_IRUGO, proc_cpuset_show), -#endif #ifdef CONFIG_CGROUPS ONE("cgroup", S_IRUGO, proc_cgroup_show),#endif
@@ -3658,9 +3655,6 @@ static const struct pid_entry tid_base_stuff[] = {#ifdef CONFIG_LATENCYTOP REG("latency", S_IRUGO, proc_lstats_operations),#endif -#ifdef CONFIG_PROC_PID_CPUSET - ONE("cpuset", S_IRUGO, proc_cpuset_show), -#endif #ifdef CONFIG_CGROUPS ONE("cgroup", S_IRUGO, proc_cgroup_show),#endif
kernel/cgroup/cpuset.c +0 -40
@@ -5066,46 +5066,6 @@ void __cpuset_memory_pressure_bump(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; - - css =task_get_css (tsk, cpuset_cgrp_id); - retval =cgroup_path_ns (css->cgroup, buf,PATH_MAX , - current->nsproxy->cgroup_ns); -css_put (css); -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) {
Signature · 1 line
2.25.1
Tejun Heo
maintainerQuoted 10 lines · brookxu.cn
From: Chunguang Xu <[email protected]>
Now we can get all cgroup paths from
/proc/PID/cgroupfor a long time, so it maybe useless to keep/proc/PID/cpuset, besides the path get from/proc/PID/cpusetis not consistent with/proc/PID/cgroupin default hierarchy, so now we may can safely remove/proc/PID/cpusetto avoid the mismatch.root@test:~# cat /proc/1186/cgroup 0::/system.slice/lmeter.service
I don't think we can remove it, unfortunately. We can try to deprecate it and annoy people who use it over time and eventually remove it, but I don't see a reason why we should do that. It doesn't get in anyone's way, so let's let it be.
Thanks.
Signature · 1 line
tejun
Quoted 7 lines · brookxu.cn
From: Chunguang Xu <[email protected]>
Now we can get all cgroup paths from
/proc/PID/cgroupfor a long time, so it maybe useless to keep/proc/PID/cpuset, besides the path get from/proc/PID/cpusetis not consistent with/proc/PID/cgroupin default hierarchy, so now we may can safely remove/proc/PID/cpusetto avoid the mismatch.
With cgroup v2, the value of /proc/PID/cgroup may not match /proc/PID/cpuset. That is the expected behavior due to the way cgroup v2 works. For example,
Root [CS] --> A [CS] --> B --> C where [CS] means cpuset controller is enabled at that cgroup.
If a process P is in cgroup C, /proc/PID/cgroup will show /A/B/C. However, /proc/PID/cpuset will show /A because it is where the cpuset controller setting will apply to process P. Also removing an existing procfs file may break an existing application that relies on it. So we don't do that unless there is a strong reason to do so.
NAK
Quoted 127 lines
root@test:~# cat /proc/1186/cgroup 0::/system.slice/lmeter.serviceroot@test:~# cat /proc/1186/cpuset /system.sliceSigned-off-by Chunguang Xu <[email protected]>--- arch/mips/configs/sb1250_swarm_defconfig | 1 - arch/sh/configs/sdk7786_defconfig | 1 - arch/sh/configs/urquell_defconfig | 1 - fs/proc/base.c | 6 ---- kernel/cgroup/cpuset.c | 40 ------------------------ 5 files changed, 49 deletions(-)arch/mips/configs/sb1250_swarm_defconfig +0
-1@@ -3,7 +3,6 @@ CONFIG_HIGH_RES_TIMERS=y CONFIG_LOG_BUF_SHIFT=15 CONFIG_CGROUPS=y CONFIG_CPUSETS=y -# CONFIG_PROC_PID_CPUSET is not set CONFIG_CGROUP_CPUACCT=y CONFIG_NAMESPACES=y CONFIG_RELAY=yarch/sh/configs/sdk7786_defconfig +0
-1@@ -13,7 +13,6 @@ CONFIG_CGROUP_DEBUG=y CONFIG_CGROUP_FREEZER=y CONFIG_CGROUP_DEVICE=y CONFIG_CPUSETS=y -# CONFIG_PROC_PID_CPUSET is not set CONFIG_CGROUP_CPUACCT=y CONFIG_CGROUP_MEMCG=y CONFIG_CGROUP_SCHED=yarch/sh/configs/urquell_defconfig +0
-1@@ -11,7 +11,6 @@ CONFIG_CGROUP_DEBUG=y CONFIG_CGROUP_FREEZER=y CONFIG_CGROUP_DEVICE=y CONFIG_CPUSETS=y -# CONFIG_PROC_PID_CPUSET is not set CONFIG_CGROUP_CPUACCT=y CONFIG_CGROUP_MEMCG=y CONFIG_CGROUP_SCHED=yfs/proc/base.c +0
-6@@ -3309,9 +3309,6 @@ static const struct pid_entry tgid_base_stuff[] = {#ifdef CONFIG_LATENCYTOP REG("latency", S_IRUGO, proc_lstats_operations),#endif -#ifdef CONFIG_PROC_PID_CPUSET - ONE("cpuset", S_IRUGO, proc_cpuset_show), -#endif #ifdef CONFIG_CGROUPS ONE("cgroup", S_IRUGO, proc_cgroup_show),#endif @@ -3658,9 +3655,6 @@ static const struct pid_entry tid_base_stuff[] = {#ifdef CONFIG_LATENCYTOP REG("latency", S_IRUGO, proc_lstats_operations),#endif -#ifdef CONFIG_PROC_PID_CPUSET - ONE("cpuset", S_IRUGO, proc_cpuset_show), -#endif #ifdef CONFIG_CGROUPS ONE("cgroup", S_IRUGO, proc_cgroup_show),#endif kernel/cgroup/cpuset.c +0
-40@@ -5066,46 +5066,6 @@ void __cpuset_memory_pressure_bump(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; - - css =task_get_css (tsk, cpuset_cgrp_id); - retval =cgroup_path_ns (css->cgroup, buf,PATH_MAX , - current->nsproxy->cgroup_ns); -css_put (css); -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) {
Hi waiman:
Thanks for analyse in detail, we found some guy use /proc/PID/cpuset to get the path and cause a live issue.
Thanks.
Quoted 153 lines · Waiman Long <[email protected]> 于2024年2月10日周六 12:34写道:
Quoted 7 lines · brookxu.cn
From: Chunguang Xu <[email protected]>
Now we can get all cgroup paths from
/proc/PID/cgroupfor a long time, so it maybe useless to keep/proc/PID/cpuset, besides the path get from/proc/PID/cpusetis not consistent with/proc/PID/cgroupin default hierarchy, so now we may can safely remove/proc/PID/cpusetto avoid the mismatch.With cgroup v2, the value of
/proc/PID/cgroupmay not match/proc/PID/cpuset. That is the expected behavior due to the way cgroup v2 works. For example,Root [CS] --> A [CS] --> B --> C where [CS] means cpuset controller is enabled at that cgroup.
If a process P is in cgroup C,
/proc/PID/cgroupwill show /A/B/C. However,/proc/PID/cpusetwill show /A because it is where the cpuset controller setting will apply to process P. Also removing an existing procfs file may break an existing application that relies on it. So we don't do that unless there is a strong reason to do so.NAK
Quoted 127 lines
root@test:~# cat /proc/1186/cgroup 0::/system.slice/lmeter.serviceroot@test:~# cat /proc/1186/cpuset /system.sliceSigned-off-by Chunguang Xu <[email protected]>--- arch/mips/configs/sb1250_swarm_defconfig | 1 - arch/sh/configs/sdk7786_defconfig | 1 - arch/sh/configs/urquell_defconfig | 1 - fs/proc/base.c | 6 ---- kernel/cgroup/cpuset.c | 40 ------------------------ 5 files changed, 49 deletions(-)arch/mips/configs/sb1250_swarm_defconfig +0
-1@@ -3,7 +3,6 @@ CONFIG_HIGH_RES_TIMERS=y CONFIG_LOG_BUF_SHIFT=15 CONFIG_CGROUPS=y CONFIG_CPUSETS=y -# CONFIG_PROC_PID_CPUSET is not set CONFIG_CGROUP_CPUACCT=y CONFIG_NAMESPACES=y CONFIG_RELAY=yarch/sh/configs/sdk7786_defconfig +0
-1@@ -13,7 +13,6 @@ CONFIG_CGROUP_DEBUG=y CONFIG_CGROUP_FREEZER=y CONFIG_CGROUP_DEVICE=y CONFIG_CPUSETS=y -# CONFIG_PROC_PID_CPUSET is not set CONFIG_CGROUP_CPUACCT=y CONFIG_CGROUP_MEMCG=y CONFIG_CGROUP_SCHED=yarch/sh/configs/urquell_defconfig +0
-1@@ -11,7 +11,6 @@ CONFIG_CGROUP_DEBUG=y CONFIG_CGROUP_FREEZER=y CONFIG_CGROUP_DEVICE=y CONFIG_CPUSETS=y -# CONFIG_PROC_PID_CPUSET is not set CONFIG_CGROUP_CPUACCT=y CONFIG_CGROUP_MEMCG=y CONFIG_CGROUP_SCHED=yfs/proc/base.c +0
-6@@ -3309,9 +3309,6 @@ static const struct pid_entry tgid_base_stuff[] = {#ifdef CONFIG_LATENCYTOP REG("latency", S_IRUGO, proc_lstats_operations),#endif -#ifdef CONFIG_PROC_PID_CPUSET - ONE("cpuset", S_IRUGO, proc_cpuset_show), -#endif #ifdef CONFIG_CGROUPS ONE("cgroup", S_IRUGO, proc_cgroup_show),#endif @@ -3658,9 +3655,6 @@ static const struct pid_entry tid_base_stuff[] = {#ifdef CONFIG_LATENCYTOP REG("latency", S_IRUGO, proc_lstats_operations),#endif -#ifdef CONFIG_PROC_PID_CPUSET - ONE("cpuset", S_IRUGO, proc_cpuset_show), -#endif #ifdef CONFIG_CGROUPS ONE("cgroup", S_IRUGO, proc_cgroup_show),#endif kernel/cgroup/cpuset.c +0
-40@@ -5066,46 +5066,6 @@ void __cpuset_memory_pressure_bump(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; - - css =task_get_css (tsk, cpuset_cgrp_id); - retval =cgroup_path_ns (css->cgroup, buf,PATH_MAX , - current->nsproxy->cgroup_ns); -css_put (css); -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) {
Waiman Long
maintainerQuoted 4 lines · 许春光
Hi waiman:
Thanks for analyse in detail, we found some guy use
/proc/PID/cpusetto get the path and cause a live issue.
Just remember that in cgroup v2, /proc/PID/cpuset may not give you the actual cgroup the process is in. It just give you the cgroup where the corresponding cpuset setting will apply to that "PID" process.
Cheers,
Longman
Quoted 153 lines
Thanks.
Quoted 149 lines · Waiman Long <[email protected]> 于2024年2月10日周六 12:34写道:
Quoted 7 lines · brookxu.cn
From: Chunguang Xu <[email protected]>
Now we can get all cgroup paths from
/proc/PID/cgroupfor a long time, so it maybe useless to keep/proc/PID/cpuset, besides the path get from/proc/PID/cpusetis not consistent with/proc/PID/cgroupin default hierarchy, so now we may can safely remove/proc/PID/cpusetto avoid the mismatch.With cgroup v2, the value of
/proc/PID/cgroupmay not match/proc/PID/cpuset. That is the expected behavior due to the way cgroup v2 works. For example,Root [CS] --> A [CS] --> B --> C where [CS] means cpuset controller is enabled at that cgroup.
If a process P is in cgroup C,
/proc/PID/cgroupwill show /A/B/C. However,/proc/PID/cpusetwill show /A because it is where the cpuset controller setting will apply to process P. Also removing an existing procfs file may break an existing application that relies on it. So we don't do that unless there is a strong reason to do so.NAK
Quoted 126 lines
root@test:~# cat /proc/1186/cgroup 0::/system.slice/lmeter.serviceroot@test:~# cat /proc/1186/cpuset /system.sliceSigned-off-by Chunguang Xu <[email protected]>--- arch/mips/configs/sb1250_swarm_defconfig | 1 - arch/sh/configs/sdk7786_defconfig | 1 - arch/sh/configs/urquell_defconfig | 1 - fs/proc/base.c | 6 ---- kernel/cgroup/cpuset.c | 40 ------------------------ 5 files changed, 49 deletions(-)arch/mips/configs/sb1250_swarm_defconfig +0
-1@@ -3,7 +3,6 @@ CONFIG_HIGH_RES_TIMERS=y CONFIG_LOG_BUF_SHIFT=15 CONFIG_CGROUPS=y CONFIG_CPUSETS=y -# CONFIG_PROC_PID_CPUSET is not set CONFIG_CGROUP_CPUACCT=y CONFIG_NAMESPACES=y CONFIG_RELAY=yarch/sh/configs/sdk7786_defconfig +0
-1@@ -13,7 +13,6 @@ CONFIG_CGROUP_DEBUG=y CONFIG_CGROUP_FREEZER=y CONFIG_CGROUP_DEVICE=y CONFIG_CPUSETS=y -# CONFIG_PROC_PID_CPUSET is not set CONFIG_CGROUP_CPUACCT=y CONFIG_CGROUP_MEMCG=y CONFIG_CGROUP_SCHED=yarch/sh/configs/urquell_defconfig +0
-1@@ -11,7 +11,6 @@ CONFIG_CGROUP_DEBUG=y CONFIG_CGROUP_FREEZER=y CONFIG_CGROUP_DEVICE=y CONFIG_CPUSETS=y -# CONFIG_PROC_PID_CPUSET is not set CONFIG_CGROUP_CPUACCT=y CONFIG_CGROUP_MEMCG=y CONFIG_CGROUP_SCHED=yfs/proc/base.c +0
-6@@ -3309,9 +3309,6 @@ static const struct pid_entry tgid_base_stuff[] = {#ifdef CONFIG_LATENCYTOP REG("latency", S_IRUGO, proc_lstats_operations),#endif -#ifdef CONFIG_PROC_PID_CPUSET - ONE("cpuset", S_IRUGO, proc_cpuset_show), -#endif #ifdef CONFIG_CGROUPS ONE("cgroup", S_IRUGO, proc_cgroup_show),#endif @@ -3658,9 +3655,6 @@ static const struct pid_entry tid_base_stuff[] = {#ifdef CONFIG_LATENCYTOP REG("latency", S_IRUGO, proc_lstats_operations),#endif -#ifdef CONFIG_PROC_PID_CPUSET - ONE("cpuset", S_IRUGO, proc_cpuset_show), -#endif #ifdef CONFIG_CGROUPS ONE("cgroup", S_IRUGO, proc_cgroup_show),#endif kernel/cgroup/cpuset.c +0
-40@@ -5066,46 +5066,6 @@ void __cpuset_memory_pressure_bump(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; - - css =task_get_css (tsk, cpuset_cgrp_id); - retval =cgroup_path_ns (css->cgroup, buf,PATH_MAX , - current->nsproxy->cgroup_ns); -css_put (css); -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) {