lkml.org 
[lkml]   [2014]   [Nov]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRE: [PATCH v7 1/2] procfs: show hierarchy of pid namespace
Date


> -----Original Message-----
> From: Richard Weinberger [mailto:richard@nod.at]
> Sent: Wednesday, November 12, 2014 7:15 PM
> To: Chen, Hanxiao/陈 晗霄; Eric W. Biederman; Serge Hallyn; Oleg Nesterov
> Cc: containers@lists.linux-foundation.org; linux-kernel@vger.kernel.org; David
> Howells; Richard Weinberger; Pavel Emelyanov; Vasiliy Kulikov; Mateusz Guzik
> Subject: Re: [PATCH v7 1/2] procfs: show hierarchy of pid namespace
>
> Am 12.11.2014 um 11:08 schrieb Chen Hanxiao:
> > 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 different 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:
> >
> > <init_PID> <parent_of_init_PID> <relative PID level>
> >
> > Ex:
> > [root@localhost ~]#cat /proc/pidns_hierarchy
> > 18060 1 1
> > 18102 18060 2
> > 1534 18102 3
> > 1600 18102 3
> > 1550 1 1
> > *Note: numbers represent the pid 1 in different ns
> >
[snip]
> > +
> > +#define NS_HIERARCHY "pidns_hierarchy"
> > +#define MAX(a, b) ((a) > (b) ? (a) : (b))
>
> Please use max() from kernel.h, there is no need to reinvent the wheel.
>

Thanks for your reminding.

> > +
> > +/* list for host pid collection */
> > +struct pidns_list {
> > + struct list_head list;
> > + struct pid *pid;
> > + int show_level;
>
> s/show_level/level, to keep it easy. :-)

Sure, also change the type to unsigned int
for making max() happy.

[snip]
> > +}
> > +
> > +/*
> > + * collect pids and stored in pidns_pid_list,
>
> s/stored/store
Oops...

>
> > + * then remove duplicated ones,
> > + * add the rest to pidns_pid_tree
> > + */
>
> This comment is a bit confusing.
>
> What about "proc_pidns_list_refresh - Finds all init pids, places them into
> pidns_pid_list
> and then stores the hirarchy into pidns_pid_tree."?
>
That's much more clear.

> Beside of my minor comments I like the patch. :-)
> Thanks a lot for doing this work!
>

Thanks for your kindly help. :)

- Chen
\
 
 \ /
  Last update: 2014-11-13 11:21    [W:0.180 / U:1.384 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site