fs, proc: don't guard /proc/<pid>/task/<tid>/children on CONFIG_CHECKPOINT_RESTORE
Subsystems (3)
RFC PATCH 1/1 fs, proc: don't guard /proc/<pid>/task/<tid>/children on CONFIG_CHECKPOINT_RESTORE
From: Alban Crequy <alban-973cpzSjLbNWk0Htik3J/[email protected]>
commit 818411616baf ("fs, proc: introduce /proc/<pid>/task/<tid>/children entry") introduced the children entry for checkpoint restore and the file is only available on kernels configured with CONFIG_EXPERT and CONFIG_CHECKPOINT_RESTORE.
This is available in most distributions (Fedora, Debian, Ubuntu, CoreOS) because they usually enable CONFIG_EXPERT and CONFIG_CHECKPOINT_RESTORE. But Arch does not enable CONFIG_EXPERT or CONFIG_CHECKPOINT_RESTORE.
However, the children proc file is useful outside of checkpoint restore. I would like to use it in rkt. The rkt process exec() another program it does not control, and that other program will fork()+exec() a child process. I would like to find the pid of the child process from an external tool without iterating in /proc over all processes to find which one has a parent pid equal to rkt.
Since the children proc file is useful outside of checkpoint-restore, I am removing the guard on CONFIG_CHECKPOINT_RESTORE.
--- fs/proc/array.c | 2 -- fs/proc/base.c | 2 -- 2 files changed, 4 deletions(-)
fs/proc/array.c +0 -2
@@ -569,7 +569,6 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,return 0 ; } -#ifdef CONFIG_CHECKPOINT_RESTORE static struct pid *get_children_pid (struct inode *inode,struct pid *pid_prev,loff_t pos) {
@@ -692,4 +691,3 @@ const struct file_operations proc_tid_children_operations = { .llseek = seq_lseek, .release = children_seq_release, }; -#endif /* CONFIG_CHECKPOINT_RESTORE */
fs/proc/base.c +0 -2
@@ -2922,9 +2922,7 @@ static const struct pid_entry tid_base_stuff[] = {ONE ("stat" ,S_IRUGO , proc_tid_stat),ONE ("statm" ,S_IRUGO , proc_pid_statm),REG ("maps" ,S_IRUGO , proc_tid_maps_operations), -#ifdef CONFIG_CHECKPOINT_RESTOREREG ("children" ,S_IRUGO , proc_tid_children_operations), -#endif #ifdef CONFIG_NUMA REG("numa_maps", S_IRUGO, proc_tid_numa_maps_operations), #endif
Signature · 1 line
2.1.4
Quoted 16 lines · On Thu, 21 May 2015 12:30:21 +0200 Alban Crequy <[email protected]> wrote:
commit
818411616baf("fs, proc: introduce /proc/<pid>/task/<tid>/children entry") introduced the children entry for checkpoint restore and the file is only available on kernels configured withCONFIG_EXPERTandCONFIG_CHECKPOINT_RESTORE.This is available in most distributions (Fedora, Debian, Ubuntu, CoreOS) because they usually enable
CONFIG_EXPERTandCONFIG_CHECKPOINT_RESTORE. But Arch does not enableCONFIG_EXPERTorCONFIG_CHECKPOINT_RESTORE.However, the children proc file is useful outside of checkpoint restore. I would like to use it in rkt. The rkt process
exec()another program it does not control, and that other program will fork()+exec() a child process. I would like to find the pid of the child process from an external tool without iterating in /proc over all processes to find which one has a parent pid equal to rkt.
Quoted 2 lines
Since the children proc file is useful outside of checkpoint-restore, I am removing the guard on
CONFIG_CHECKPOINT_RESTORE.
This will add a lump of code to kernels which don't need it.
It's a bit of a pain, but I suppose we should still keep the presence of get_children_pid() configurable. That would be by adding a new CONFIG_PROC_CHILDREN (or similar) and making CONFIG_CHECKPOINT_RESTORE select that.
PATCH 1/1 fs, proc: introduce CONFIG_PROC_CHILDREN
commit 818411616baf ("fs, proc: introduce /proc/<pid>/task/<tid>/children entry") introduced the children entry for checkpoint restore and the file is only available on kernels configured with CONFIG_EXPERT and CONFIG_CHECKPOINT_RESTORE.
This is available in most distributions (Fedora, Debian, Ubuntu, CoreOS) because they usually enable CONFIG_EXPERT and CONFIG_CHECKPOINT_RESTORE. But Arch does not enable CONFIG_EXPERT or CONFIG_CHECKPOINT_RESTORE.
However, the children proc file is useful outside of checkpoint restore. I would like to use it in rkt. The rkt process exec() another program it does not control, and that other program will fork()+exec() a child process. I would like to find the pid of the child process from an external tool without iterating in /proc over all processes to find which one has a parent pid equal to rkt.
This commit introduces CONFIG_PROC_CHILDREN and makes CONFIG_CHECKPOINT_RESTORE depend on it. This allows enabling /proc/<pid>/task/<tid>/children without needing to enable CONFIG_CHECKPOINT_RESTORE and CONFIG_EXPERT.
Alban tested that /proc/<pid>/task/<tid>/children is present when the kernel is configured with CONFIG_PROC_CHILDREN=y but without CONFIG_CHECKPOINT_RESTORE
--- fs/proc/Kconfig | 4 ++++ fs/proc/array.c | 4 ++-- fs/proc/base.c | 2 +- init/Kconfig | 1 + 4 files changed, 8 insertions(+), 3 deletions(-)
fs/proc/Kconfig +4 -0
@@ -71,3 +71,7 @@ config PROC_PAGE_MONITOR /proc/pid/smaps, /proc/pid/clear_refs, /proc/pid/pagemap, /proc/kpagecount, and /proc/kpageflags. Disabling these interfaces will reduce the size of the kernel by approximately 4kb. + +config PROC_CHILDREN + bool "Include /proc/<pid>/task/<tid>/children file" + default n
fs/proc/array.c +2 -2
@@ -569,7 +569,7 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,return 0 ; } -#ifdef CONFIG_CHECKPOINT_RESTORE +#ifdef CONFIG_PROC_CHILDREN static struct pid *get_children_pid (struct inode *inode,struct pid *pid_prev,loff_t pos) {
@@ -692,4 +692,4 @@ const struct file_operations proc_tid_children_operations = { .llseek = seq_lseek, .release = children_seq_release, }; -#endif /* CONFIG_CHECKPOINT_RESTORE */ +#endif /* CONFIG_PROC_CHILDREN */
fs/proc/base.c +1 -1
@@ -2922,7 +2922,7 @@ static const struct pid_entry tid_base_stuff[] = {ONE ("stat" ,S_IRUGO , proc_tid_stat),ONE ("statm" ,S_IRUGO , proc_pid_statm),REG ("maps" ,S_IRUGO , proc_tid_maps_operations), -#ifdef CONFIG_CHECKPOINT_RESTORE +#ifdef CONFIG_PROC_CHILDRENREG ("children" ,S_IRUGO , proc_tid_children_operations), #endif #ifdef CONFIG_NUMA
init/Kconfig +1 -0
@@ -1145,6 +1145,7 @@ endif # CGROUPS config CHECKPOINT_RESTORE bool "Checkpoint/restore support" if EXPERT + depends on PROC_CHILDREN default n help Enables additional kernel features in a sake of checkpoint/restore.
Signature · 6 lines
2.4.1 -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 1432298859-2059-1-git-send-email-iago-973cpzSjLbNWk0Htik3J/[email protected]
Re: [PATCH] fs, proc: introduce CONFIG_PROC_CHILDREN
init/Kconfig endif # CGROUPS · line 1151
Quoted 10 lines · Iago López Galeiras
init/Kconfig +1
-0@@ -1145,6 +1145,7 @@ endif # CGROUPS config CHECKPOINT_RESTORE bool "Checkpoint/restore support" if EXPERT + depends on PROC_CHILDREN default n help Enables additional kernel features in a sake of checkpoint/restore.
Maybe better select PROC_CHILDREN here? Also I must admit I don't understand why similar patch from Andy has not been merged earlier? Andy, there was some problem I forgot about?
(to be clear, I don't mind enabling it since we use it in criu alot ;)
Re: [PATCH] fs, proc: introduce CONFIG_PROC_CHILDREN
Quoted 5 lines · Cyrill Gorcunov
Quoted 4 lines · Iago López Galeiras
init/Kconfig +0
-0@@ -1145,6 +1145,7 @@ endif # CGROUPS
Quoted 10 lines
init/Kconfig endif # CGROUPS · line 1151
Quoted 6 lines
init/Kconfig +1
-0config CHECKPOINT_RESTORE bool "Checkpoint/restore support" if EXPERT + depends on PROC_CHILDREN default n help Enables additional kernel features in a sake of checkpoint/restore.Maybe better select
PROC_CHILDRENhere? Also I must admit I don't understand why similar patch from Andy has not been merged earlier? Andy, there was some problem I forgot about?
From the linked thread, it seems that it was just lost... The discussion ended up about task/<tid> and /proc/<pid>... That patch should have been applied.
BTW this patch adds the CONFIG guard that was requested by Andrew. There is a v3 coming to make it "select" as suggested.
Thanks!
Signature · 6 lines
Djalal Harouni http://opendz.org -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v3 1/1 fs, proc: introduce CONFIG_PROC_CHILDREN
In reply to Cyrill Gorcunovcommit 818411616baf ("fs, proc: introduce /proc/<pid>/task/<tid>/children entry") introduced the children entry for checkpoint restore and the file is only available on kernels configured with CONFIG_EXPERT and CONFIG_CHECKPOINT_RESTORE.
This is available in most distributions (Fedora, Debian, Ubuntu, CoreOS) because they usually enable CONFIG_EXPERT and CONFIG_CHECKPOINT_RESTORE. But Arch does not enable CONFIG_EXPERT or CONFIG_CHECKPOINT_RESTORE.
However, the children proc file is useful outside of checkpoint restore. I would like to use it in rkt. The rkt process exec() another program it does not control, and that other program will fork()+exec() a child process. I would like to find the pid of the child process from an external tool without iterating in /proc over all processes to find which one has a parent pid equal to rkt.
This commit introduces CONFIG_PROC_CHILDREN and makes CONFIG_CHECKPOINT_RESTORE select it. This allows enabling /proc/<pid>/task/<tid>/children without needing to enable CONFIG_CHECKPOINT_RESTORE and CONFIG_EXPERT.
Alban tested that /proc/<pid>/task/<tid>/children is present when the kernel is configured with CONFIG_PROC_CHILDREN=y but without CONFIG_CHECKPOINT_RESTORE
v3: change depend -> select
v2: introduce CONFIG_PROC_CHILDREN http://marc.info/?l=linux-fsdevel&m=143229890217280&w=2
v1: http://marc.info/?l=linux-api&m=143220431121869&w=2
--- fs/proc/Kconfig | 4 ++++ fs/proc/array.c | 4 ++-- fs/proc/base.c | 2 +- init/Kconfig | 1 + 4 files changed, 8 insertions(+), 3 deletions(-)
fs/proc/Kconfig +4 -0
@@ -71,3 +71,7 @@ config PROC_PAGE_MONITOR /proc/pid/smaps, /proc/pid/clear_refs, /proc/pid/pagemap, /proc/kpagecount, and /proc/kpageflags. Disabling these interfaces will reduce the size of the kernel by approximately 4kb. + +config PROC_CHILDREN + bool "Include /proc/<pid>/task/<tid>/children file" + default n
fs/proc/array.c +2 -2
@@ -569,7 +569,7 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,return 0 ; } -#ifdef CONFIG_CHECKPOINT_RESTORE +#ifdef CONFIG_PROC_CHILDREN static struct pid *get_children_pid (struct inode *inode,struct pid *pid_prev,loff_t pos) {
@@ -692,4 +692,4 @@ const struct file_operations proc_tid_children_operations = { .llseek = seq_lseek, .release = children_seq_release, }; -#endif /* CONFIG_CHECKPOINT_RESTORE */ +#endif /* CONFIG_PROC_CHILDREN */
fs/proc/base.c +1 -1
@@ -2922,7 +2922,7 @@ static const struct pid_entry tid_base_stuff[] = {ONE ("stat" ,S_IRUGO , proc_tid_stat),ONE ("statm" ,S_IRUGO , proc_pid_statm),REG ("maps" ,S_IRUGO , proc_tid_maps_operations), -#ifdef CONFIG_CHECKPOINT_RESTORE +#ifdef CONFIG_PROC_CHILDRENREG ("children" ,S_IRUGO , proc_tid_children_operations), #endif #ifdef CONFIG_NUMA
init/Kconfig +1 -0
@@ -1145,6 +1145,7 @@ endif # CGROUPS config CHECKPOINT_RESTORE bool "Checkpoint/restore support" if EXPERT + select PROC_CHILDREN default n help Enables additional kernel features in a sake of checkpoint/restore.
Signature · 6 lines
2.4.1 -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 1432653162-20973-1-git-send-email-iago-973cpzSjLbNWk0Htik3J/[email protected]
Cyrill Gorcunov
Reviewed-byRe: [PATCH v3] fs, proc: introduce CONFIG_PROC_CHILDREN
On Tue, May 26, 2015 at 05:12:42PM +0200, Iago López Galeiras wrote:
...
Quoted 11 lines
Alban tested that /proc/<pid>/task/<tid>/children is present when the kernel is configured with
CONFIG_PROC_CHILDREN=ybut withoutCONFIG_CHECKPOINT_RESTOREv3: change depend -> select
v2: introduceCONFIG_PROC_CHILDRENhttp://marc.info/?l=linux-fsdevel&m=143229890217280&w=2
v1: http://marc.info/?l=linux-api&m=143220431121869&w=2Cc Alban Crequy <alban-973cpzSjLbNWk0Htik3J/[email protected]>
Looks ok to me, thanks.
A message that is not in the archive (sent off-list or not yet received): 1432204221-1933-1-git-send-email-alban-973cpzSjLbNWk0Htik3J/[email protected]
Quoted 18 lines · Alban Crequy
From: Alban Crequy <alban-973cpzSjLbNWk0Htik3J/[email protected]>
commit
818411616baf("fs, proc: introduce /proc/<pid>/task/<tid>/children entry") introduced the children entry for checkpoint restore and the file is only available on kernels configured withCONFIG_EXPERTandCONFIG_CHECKPOINT_RESTORE.This is available in most distributions (Fedora, Debian, Ubuntu, CoreOS) because they usually enable
CONFIG_EXPERTandCONFIG_CHECKPOINT_RESTORE. But Arch does not enableCONFIG_EXPERTorCONFIG_CHECKPOINT_RESTORE.However, the children proc file is useful outside of checkpoint restore. I would like to use it in rkt. The rkt process
exec()another program it does not control, and that other program will fork()+exec() a child process. I would like to find the pid of the child process from an external tool without iterating in /proc over all processes to find which one has a parent pid equal to rkt.
Quoted 2 lines
Since the children proc file is useful outside of checkpoint-restore, I am removing the guard on
CONFIG_CHECKPOINT_RESTORE.
I sent an essentially identical patch a couple years ago, and it got some interesting comments:
See also:
--Andy
A message that is not in the archive (sent off-list or not yet received): CALCETrVbaKnqj7qLBr+ufirPHfdjAYzo6_e362N0muVGnH7HTg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Quoted 7 lines · Andy Lutomirski
Quoted 3 lines
Since the children proc file is useful outside of checkpoint-restore, I am removing the guard on
CONFIG_CHECKPOINT_RESTORE.I sent an essentially identical patch a couple years ago, and it got some interesting comments:
Oh, it is 2k13, I thought it's merged already ;)
Quoted 19 lines · Andy Lutomirski
Quoted 18 lines · Alban Crequy
From: Alban Crequy <alban-973cpzSjLbNWk0Htik3J/[email protected]>
commit
818411616baf("fs, proc: introduce /proc/<pid>/task/<tid>/children entry") introduced the children entry for checkpoint restore and the file is only available on kernels configured withCONFIG_EXPERTandCONFIG_CHECKPOINT_RESTORE.This is available in most distributions (Fedora, Debian, Ubuntu, CoreOS) because they usually enable
CONFIG_EXPERTandCONFIG_CHECKPOINT_RESTORE. But Arch does not enableCONFIG_EXPERTorCONFIG_CHECKPOINT_RESTORE.However, the children proc file is useful outside of checkpoint restore. I would like to use it in rkt. The rkt process
exec()another program it does not control, and that other program will fork()+exec() a child process. I would like to find the pid of the child process from an external tool without iterating in /proc over all processes to find which one has a parent pid equal to rkt.
Quoted 7 lines
Quoted 2 lines
Since the children proc file is useful outside of checkpoint-restore, I am removing the guard on
CONFIG_CHECKPOINT_RESTORE.I sent an essentially identical patch a couple years ago, and it got some interesting comments:
Thanks for the pointer, I didn't see it.
Quoted 3 lines
See also:
Your paragraph seems good to have in the documentation but I am also not qualified to comment on the behavior.