diff mbox

[RFC] fs, proc: don't guard /proc/<pid>/task/<tid>/children on CONFIG_CHECKPOINT_RESTORE

Message ID 1432204221-1933-1-git-send-email-alban@endocode.com (mailing list archive)
State New, archived
Headers show

Commit Message

Alban Crequy May 21, 2015, 10:30 a.m. UTC
From: Alban Crequy <alban@endocode.com>

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.

Signed-off-by: Alban Crequy <alban@endocode.com>
Cc: Iago Lopez Galeiras <iago@endocode.com>
---
 fs/proc/array.c | 2 --
 fs/proc/base.c  | 2 --
 2 files changed, 4 deletions(-)

Comments

Andrew Morton May 21, 2015, 8:57 p.m. UTC | #1
On Thu, 21 May 2015 12:30:21 +0200 Alban Crequy <alban.crequy@gmail.com> 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 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.

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.


--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Andy Lutomirski May 21, 2015, 9:47 p.m. UTC | #2
On Thu, May 21, 2015 at 3:30 AM, Alban Crequy <alban.crequy@gmail.com> wrote:
> From: Alban Crequy <alban@endocode.com>
>
> 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.

I sent an essentially identical patch a couple years ago, and it got
some interesting comments:

http://lkml.kernel.org/g/0e00e9073855c02a382d49ba1ede9c4fda3451b7.1372189875.git.luto@amacapital.net

See also:

http://lkml.kernel.org/g/5f9a6b3ab75b12f2c5ba61ea1f6f3b08e9952b55.1372280661.git.luto@amacapital.net

--Andy
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Cyrill Gorcunov May 21, 2015, 10:05 p.m. UTC | #3
On Thu, May 21, 2015 at 02:47:33PM -0700, Andy Lutomirski wrote:
> >
> > 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 ;)

> http://lkml.kernel.org/g/0e00e9073855c02a382d49ba1ede9c4fda3451b7.1372189875.git.luto@amacapital.net
> 
> See also:
> 
> http://lkml.kernel.org/g/5f9a6b3ab75b12f2c5ba61ea1f6f3b08e9952b55.1372280661.git.luto@amacapital.net
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Alban Crequy May 22, 2015, 12:49 p.m. UTC | #4
On Thu, May 21, 2015 at 11:47 PM, Andy Lutomirski <luto@amacapital.net> wrote:
> On Thu, May 21, 2015 at 3:30 AM, Alban Crequy <alban.crequy@gmail.com> wrote:
>> From: Alban Crequy <alban@endocode.com>
>>
>> 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.
>
> I sent an essentially identical patch a couple years ago, and it got
> some interesting comments:
>
> http://lkml.kernel.org/g/0e00e9073855c02a382d49ba1ede9c4fda3451b7.1372189875.git.luto@amacapital.net

Thanks for the pointer, I didn't see it.

> See also:
>
> http://lkml.kernel.org/g/5f9a6b3ab75b12f2c5ba61ea1f6f3b08e9952b55.1372280661.git.luto@amacapital.net

Your paragraph seems good to have in the documentation but I am also
not qualified to comment on the behavior.
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/proc/array.c b/fs/proc/array.c
index fd02a9e..6edec57 100644
--- a/fs/proc/array.c
+++ b/fs/proc/array.c
@@ -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 */
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 093ca14..b743007 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -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_RESTORE
 	REG("children",  S_IRUGO, proc_tid_children_operations),
-#endif
 #ifdef CONFIG_NUMA
 	REG("numa_maps", S_IRUGO, proc_tid_numa_maps_operations),
 #endif