2015-02-06 10:45:43

by Chen Hanxiao

[permalink] [raw]
Subject: [PATCH v10 0/2] ns, procfs: pid conversion between ns


Chen Hanxiao (1):
/proc/PID/status: show all sets of pid according to ns

Nathan Scott (1):
docs: add missing and new /proc/PID/status file entries, fix typos

Documentation/filesystems/proc.txt | 11 ++++++++---
fs/proc/array.c | 16 ++++++++++++++++
2 files changed, 24 insertions(+), 3 deletions(-)

--
2.1.0


2015-02-06 10:46:15

by Chen Hanxiao

[permalink] [raw]
Subject: [PATCH v10 1/2] /proc/PID/status: show all sets of pid according to ns

If some issues occurred inside a container guest, host user
could not know which process is in trouble just by guest pid:
the users of container guest only knew the pid inside containers.
This will bring obstacle for trouble shooting.

This patch adds four fields: NStgid, NSpid, NSpgid and NSsid:
a) In init_pid_ns, nothing changed;

b) In one pidns, will tell the pid inside containers:
NStgid: 21776 5 1
NSpid: 21776 5 1
NSpgid: 21776 5 1
NSsid: 21729 1 0
** Process id is 21776 in level 0, 5 in level 1, 1 in level 2.

c) If pidns is nested, it depends on which pidns are you in.
NStgid: 5 1
NSpid: 5 1
NSpgid: 5 1
NSsid: 1 0
** Views from level 1

Acked-by: Serge Hallyn <[email protected]>
Acked-by: "Eric W. Biederman" <[email protected]>

Tested-by: Serge Hallyn <[email protected]>
Tested-by: Nathan Scott <[email protected]>

Signed-off-by: Chen Hanxiao <[email protected]>
---
v10: remove trailing space of pid numbers "\t%d " -> "\t%d",
rebased on 3.19-rc7
v9: rebased on 3.19-rc1
No change from v4-v8
v3: add another two fielsd: NSpgid and NSsid.
v2: add two new fields: NStgid and NSpid.
keep fields of Tgid and Pid unchanged for back compatibility.

fs/proc/array.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)

diff --git a/fs/proc/array.c b/fs/proc/array.c
index bd117d0..f3e6d76 100644
--- a/fs/proc/array.c
+++ b/fs/proc/array.c
@@ -208,6 +208,22 @@ static inline void task_state(struct seq_file *m, struct pid_namespace *ns,
from_kgid_munged(user_ns, GROUP_AT(group_info, g)));
put_cred(cred);

+ seq_puts(m, "\nNStgid:");
+ for (g = ns->level; g <= pid->level; g++)
+ seq_printf(m, "\t%d",
+ task_tgid_nr_ns(p, pid->numbers[g].ns));
+ seq_puts(m, "\nNSpid:");
+ for (g = ns->level; g <= pid->level; g++)
+ seq_printf(m, "\t%d",
+ task_pid_nr_ns(p, pid->numbers[g].ns));
+ seq_puts(m, "\nNSpgid:");
+ for (g = ns->level; g <= pid->level; g++)
+ seq_printf(m, "\t%d",
+ task_pgrp_nr_ns(p, pid->numbers[g].ns));
+ seq_puts(m, "\nNSsid:");
+ for (g = ns->level; g <= pid->level; g++)
+ seq_printf(m, "\t%d",
+ task_session_nr_ns(p, pid->numbers[g].ns));
seq_putc(m, '\n');
}

--
2.1.0

2015-02-06 10:45:45

by Chen Hanxiao

[permalink] [raw]
Subject: [PATCH v10 2/2] docs: add missing and new /proc/PID/status file entries, fix typos

From: Nathan Scott <[email protected]>

From: Nathan Scott <[email protected]>

docs: add missing and new /proc/PID/status file entries, fix typos

Signed-off-by: Nathan Scott <[email protected]>
---
Documentation/filesystems/proc.txt | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/Documentation/filesystems/proc.txt b/Documentation/filesystems/proc.txt
index aae9dd1..457cebd 100644
--- a/Documentation/filesystems/proc.txt
+++ b/Documentation/filesystems/proc.txt
@@ -197,12 +197,12 @@ contains details information about the process itself. Its fields are
explained in Table 1-4.

(for SMP CONFIG users)
-For making accounting scalable, RSS related information are handled in
-asynchronous manner and the vaule may not be very precise. To see a precise
+For making accounting scalable, RSS related information are handled in an
+asynchronous manner and the value may not be very precise. To see a precise
snapshot of a moment, you can see /proc/<pid>/smaps file and scan page table.
It's slow but very precise.

-Table 1-2: Contents of the status files (as of 2.6.30-rc7)
+Table 1-2: Contents of the status files (as of 3.20.0)
..............................................................................
Field Content
Name filename of the executable
@@ -210,6 +210,7 @@ Table 1-2: Contents of the status files (as of 2.6.30-rc7)
in an uninterruptible wait, Z is zombie,
T is traced or stopped)
Tgid thread group ID
+ Ngid NUMA group ID (0 if none)
Pid process id
PPid process id of the parent process
TracerPid PID of process tracing this process (0 if not)
@@ -217,6 +218,10 @@ Table 1-2: Contents of the status files (as of 2.6.30-rc7)
Gid Real, effective, saved set, and file system GIDs
FDSize number of file descriptor slots currently allocated
Groups supplementary group list
+ NStgid descendant namespace thread group ID hierarchy
+ NSpid descendant namespace process ID hierarchy
+ NSpgid descendant namespace process group ID hierarchy
+ NSsid descendant namespace session ID hierarchy
VmPeak peak virtual memory size
VmSize total program size
VmLck locked memory size
--
2.1.0

2015-02-11 05:51:39

by Chen Hanxiao

[permalink] [raw]
Subject: RE: [PATCH v10 0/2] ns, procfs: pid conversion between ns



> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Chen Hanxiao
> Sent: Friday, February 06, 2015 6:46 PM
> To: Eric W. Biederman; Andrew Morton
> Cc: Jonathan Corbet; [email protected]; Serge Hallyn;
> [email protected]; [email protected]; Nathan Scott
> Subject: [PATCH v10 0/2] ns, procfs: pid conversion between ns
>
>
> Chen Hanxiao (1):
> /proc/PID/status: show all sets of pid according to ns
>
> Nathan Scott (1):
> docs: add missing and new /proc/PID/status file entries, fix typos
>
> Documentation/filesystems/proc.txt | 11 ++++++++---
> fs/proc/array.c | 16 ++++++++++++++++
> 2 files changed, 24 insertions(+), 3 deletions(-)
>

Hi Eric,

Could please pick this series up for 3.20?

Thanks,
- Chen
????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?

2015-02-12 01:35:53

by Chen Hanxiao

[permalink] [raw]
Subject: RE: [PATCH v10 0/2] ns, procfs: pid conversion between ns



> -----Original Message-----
> From: Chen, Hanxiao/?? ????
> Sent: Wednesday, February 11, 2015 1:52 PM
>
> > -----Original Message-----
> > From: [email protected]
> >
> > Chen Hanxiao (1):
> > /proc/PID/status: show all sets of pid according to ns
> >
> > Nathan Scott (1):
> > docs: add missing and new /proc/PID/status file entries, fix typos
> >
> > Documentation/filesystems/proc.txt | 11 ++++++++---
> > fs/proc/array.c | 16 ++++++++++++++++
> > 2 files changed, 24 insertions(+), 3 deletions(-)
> >
>
> Hi Eric,
>
> Could please pick this series up for 3.20?
>

Hi Andrew,

Since the patch is already Acked by Eric, Serge and Tested by Serge and Nathan.
Would you please take this series for 3.20?

It's already half a year since we posted the patch for the first time,
and rebased several times. That's really frustrating.
We hope this patch can be merged in this cycle.

Thanks,
- Chen

????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?

2015-02-16 01:59:05

by Gui, Jianfeng/归 剑峰

[permalink] [raw]
Subject: Re: [PATCH v10 0/2] ns, procfs: pid conversion between ns

?? 2015/2/12 9:35, Chen, Hanxiao/?? ???? д??:
>
>
>> -----Original Message-----
>> From: Chen, Hanxiao/?? ????
>> Sent: Wednesday, February 11, 2015 1:52 PM
>>
>>> -----Original Message-----
>>> From: [email protected]
>>>
>>> Chen Hanxiao (1):
>>> /proc/PID/status: show all sets of pid according to ns
>>>
>>> Nathan Scott (1):
>>> docs: add missing and new /proc/PID/status file entries, fix typos
>>>
>>> Documentation/filesystems/proc.txt | 11 ++++++++---
>>> fs/proc/array.c | 16 ++++++++++++++++
>>> 2 files changed, 24 insertions(+), 3 deletions(-)
>>>
>>
>> Hi Eric,
>>
>> Could please pick this series up for 3.20?
>>
>
> Hi Andrew,
>
> Since the patch is already Acked by Eric, Serge and Tested by Serge and Nathan.
> Would you please take this series for 3.20?
>
> It's already half a year since we posted the patch for the first time,
> and rebased several times. That's really frustrating.
> We hope this patch can be merged in this cycle.

Andrew? Eric?

Thanks,
Gui

2015-02-23 21:00:13

by Andrew Morton

[permalink] [raw]
Subject: Re: [PATCH v10 1/2] /proc/PID/status: show all sets of pid according to ns

On Fri, 6 Feb 2015 18:45:49 +0800 Chen Hanxiao <[email protected]> wrote:

> If some issues occurred inside a container guest, host user
> could not know which process is in trouble just by guest pid:
> the users of container guest only knew the pid inside containers.
> This will bring obstacle for trouble shooting.
>
> This patch adds four fields: NStgid, NSpid, NSpgid and NSsid:
> a) In init_pid_ns, nothing changed;
>
> b) In one pidns, will tell the pid inside containers:
> NStgid: 21776 5 1
> NSpid: 21776 5 1
> NSpgid: 21776 5 1
> NSsid: 21729 1 0
> ** Process id is 21776 in level 0, 5 in level 1, 1 in level 2.
>
> c) If pidns is nested, it depends on which pidns are you in.
> NStgid: 5 1
> NSpid: 5 1
> NSpgid: 5 1
> NSsid: 1 0
> ** Views from level 1
>
> ...
>
> --- a/fs/proc/array.c
> +++ b/fs/proc/array.c
> @@ -208,6 +208,22 @@ static inline void task_state(struct seq_file *m, struct pid_namespace *ns,
> from_kgid_munged(user_ns, GROUP_AT(group_info, g)));
> put_cred(cred);
>
> + seq_puts(m, "\nNStgid:");
> + for (g = ns->level; g <= pid->level; g++)
> + seq_printf(m, "\t%d",
> + task_tgid_nr_ns(p, pid->numbers[g].ns));
> + seq_puts(m, "\nNSpid:");
> + for (g = ns->level; g <= pid->level; g++)
> + seq_printf(m, "\t%d",
> + task_pid_nr_ns(p, pid->numbers[g].ns));
> + seq_puts(m, "\nNSpgid:");
> + for (g = ns->level; g <= pid->level; g++)
> + seq_printf(m, "\t%d",
> + task_pgrp_nr_ns(p, pid->numbers[g].ns));
> + seq_puts(m, "\nNSsid:");
> + for (g = ns->level; g <= pid->level; g++)
> + seq_printf(m, "\t%d",
> + task_session_nr_ns(p, pid->numbers[g].ns));
> seq_putc(m, '\n');
> }

Is there any point in including this code if CONFIG_USER_NS=n?

2015-02-23 21:01:49

by Andrew Morton

[permalink] [raw]
Subject: Re: [PATCH v10 2/2] docs: add missing and new /proc/PID/status file entries, fix typos

On Fri, 6 Feb 2015 18:45:50 +0800 Chen Hanxiao <[email protected]> wrote:

> From: Nathan Scott <[email protected]>
>
> From: Nathan Scott <[email protected]>
>
> docs: add missing and new /proc/PID/status file entries, fix typos
>
> Signed-off-by: Nathan Scott <[email protected]>

This should have had your signoff, because you were on the patch
delivery path (Documentation/SubmittingPatches section 11 has details).

I have made that change to my copy of this patch.

2015-02-23 21:20:10

by Serge E. Hallyn

[permalink] [raw]
Subject: Re: [PATCH v10 1/2] /proc/PID/status: show all sets of pid according to ns

On Mon, Feb 23, 2015 at 01:00:09PM -0800, Andrew Morton wrote:
> On Fri, 6 Feb 2015 18:45:49 +0800 Chen Hanxiao <[email protected]> wrote:
>
> > If some issues occurred inside a container guest, host user
> > could not know which process is in trouble just by guest pid:
> > the users of container guest only knew the pid inside containers.
> > This will bring obstacle for trouble shooting.
> >
> > This patch adds four fields: NStgid, NSpid, NSpgid and NSsid:
> > a) In init_pid_ns, nothing changed;
> >
> > b) In one pidns, will tell the pid inside containers:
> > NStgid: 21776 5 1
> > NSpid: 21776 5 1
> > NSpgid: 21776 5 1
> > NSsid: 21729 1 0
> > ** Process id is 21776 in level 0, 5 in level 1, 1 in level 2.
> >
> > c) If pidns is nested, it depends on which pidns are you in.
> > NStgid: 5 1
> > NSpid: 5 1
> > NSpgid: 5 1
> > NSsid: 1 0
> > ** Views from level 1
> >
> > ...
> >
> > --- a/fs/proc/array.c
> > +++ b/fs/proc/array.c
> > @@ -208,6 +208,22 @@ static inline void task_state(struct seq_file *m, struct pid_namespace *ns,
> > from_kgid_munged(user_ns, GROUP_AT(group_info, g)));
> > put_cred(cred);
> >
> > + seq_puts(m, "\nNStgid:");
> > + for (g = ns->level; g <= pid->level; g++)
> > + seq_printf(m, "\t%d",
> > + task_tgid_nr_ns(p, pid->numbers[g].ns));
> > + seq_puts(m, "\nNSpid:");
> > + for (g = ns->level; g <= pid->level; g++)
> > + seq_printf(m, "\t%d",
> > + task_pid_nr_ns(p, pid->numbers[g].ns));
> > + seq_puts(m, "\nNSpgid:");
> > + for (g = ns->level; g <= pid->level; g++)
> > + seq_printf(m, "\t%d",
> > + task_pgrp_nr_ns(p, pid->numbers[g].ns));
> > + seq_puts(m, "\nNSsid:");
> > + for (g = ns->level; g <= pid->level; g++)
> > + seq_printf(m, "\t%d",
> > + task_session_nr_ns(p, pid->numbers[g].ns));
> > seq_putc(m, '\n');
> > }
>
> Is there any point in including this code if CONFIG_USER_NS=n?

Not if CONFIG_PID_NS=n, no

2015-02-27 10:05:19

by Chen Hanxiao

[permalink] [raw]
Subject: RE: [PATCH v10 2/2] docs: add missing and new /proc/PID/status file entries, fix typos



> -----Original Message-----
> From: Andrew Morton [mailto:[email protected]]
> Sent: Tuesday, February 24, 2015 5:02 AM
> To: Chen, Hanxiao/?? ????
> Cc: Eric W. Biederman; [email protected];
> [email protected]; [email protected]; Serge Hallyn; Jonathan
> Corbet; Gui, Jianfeng/?? ????; Nathan Scott
> Subject: Re: [PATCH v10 2/2] docs: add missing and new /proc/PID/status file entries,
> fix typos
>
> On Fri, 6 Feb 2015 18:45:50 +0800 Chen Hanxiao <[email protected]> wrote:
>
> > From: Nathan Scott <[email protected]>
> >
> > From: Nathan Scott <[email protected]>
> >
> > docs: add missing and new /proc/PID/status file entries, fix typos
> >
> > Signed-off-by: Nathan Scott <[email protected]>
>
> This should have had your signoff, because you were on the patch
> delivery path (Documentation/SubmittingPatches section 11 has details).
>
> I have made that change to my copy of this patch.

Hi,

Thanks for your help.
I'll be more careful next time.

Thank you very much.

Regards,
- Chen
????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?