RE: [PATCHv5] procfs: show hierarchy of pid namespace
From: Chen, Hanxiao
Date: Tue Nov 04 2014 - 03:31:34 EST
> -----Original Message-----
> From: serge@xxxxxxxxxx [mailto:serge@xxxxxxxxxx]
> Sent: Saturday, November 01, 2014 2:31 AM
> To: containers@xxxxxxxxxxxxxxxxxxxxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx; Chen,
> Hanxiao/é æé
> Cc: Richard Weinberger; Serge Hallyn; Oleg Nesterov; Mateusz Guzik; David Howells;
> Eric W. Biederman
> Subject: Re: [PATCHv5] procfs: show hierarchy of pid namespace
>
> If pidns_list_add fails, the get_pid taken in the caller leaks.
>
Will fix in the next patch.
> It's not clear to me that the loop in 'if curns' will always end in a list_add_tail,
> and if not the get_pid leaks. It does look like it should, but something to catch
> the unexpected failure (especially after someone modifies that code) would be
> nice
The previous version collect all namespace's pids on host,
in one scenario we had to add them into list according to curr_ns;
another scenario we add them into list directly.
But now using find_ge_pid, we only collect pids of current ns,
so these codes are redundant.
Sorry for that mistake.
Thanks,
- Chen
> On 10/16/14 7:01 Chen Hanxiao wrote:
> We lack of pid hierarchy information, and this will lead to:
> a) we don't know pids' relationship, who is whose child:
> /proc/PID/ns/pid only tell us whether two pids live in same ns;
> b) bring trouble to nested lxc container check/restore/migration
> c) bring trouble to pid translation between containers;
>
> This patch will show the hierarchy of pid namespace
> by pidns_hierarchy like:
>
> [root@localhost ~]#cat /proc/pidns_hierarchy
> 18060 18102 1534
> 18060 18102 1600
> 1550
> *Note: numbers represent the pid 1 in different ns
>
> It shows the pid hierarchy below:
>
> init_pid_ns (not showed in /proc/pidns_hierarchy)
> â
> ââââââââââââââ
> ns1 ns2
> â â
> 1550 18060
> â
> â
> ns3
> â
> 18102
> â
> ââââââââââââ
> ns4 ns5
> â â
> 1534 1600
>
> Every pid printed in pidns_hierarchy
> is the init pid of that pid ns level.
>
> Signed-off-by: Chen Hanxiao <chenhanxiao@xxxxxxxxxxxxxx>
> ---
[snip]
N§²æ¸yú²X¬¶ÇvØ)Þ{.nÇ·¥{±êX§¶¡Ü}©²ÆzÚj:+v¨¾«êZ+Êzf£¢·h§~Ûÿû®w¥¢¸?¨è&¢)ßfùy§m
á«a¶Úÿ0¶ìå