RE: [RFC PATCH 2/3] procfs: show hierarchy of pid namespace

From: Chen, Hanxiao
Date: Thu Sep 11 2014 - 05:49:00 EST




> -----Original Message-----
> From: Serge E. Hallyn [mailto:serge@xxxxxxxxxx]
> Sent: Thursday, September 11, 2014 12:23 AM
> To: Chen, Hanxiao/é æé
> Cc: containers@xxxxxxxxxxxxxxxxxxxxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx;
> Richard Weinberger; Serge Hallyn; Oleg Nesterov; David Howells; Eric W. Biederman;
> Al Viro
> Subject: Re: [RFC PATCH 2/3] procfs: show hierarchy of pid namespace
>
> Quoting Chen Hanxiao (chenhanxiao@xxxxxxxxxxxxxx):
> > This patch will show the hierarchy of pid namespace
> > under /proc/pidns like:
> > /proc/pidns
> > âââ hierarchy
> > â âââ pidns4026532399
> > â â âââ pidns -> /proc/2863/ns/pid
> > â â âââ pidns4026532515
> > â â âââ pidns -> /proc/10611/ns/pid
> > â âââ pidns4026532504
> > â âââ pidns -> /proc/4450/ns/pid
> > âââ refresh
> >
> > a) hierarchy dir:
> > use to show hierarchy infomation using dir and symlinks.
> > dirs are named as pidns($inum)
> > a symlink is created under pidns($inum), and linked to
> > that pid namespace.
> >
> > b) refresh
> > trigger key.
> > We need to write sth to /proc/nspid/refresh,
> > then we could get hierarchy info
> > under /proc/pidns/hierarchy.
>
> Ouch. There may not be a better way, but it sure would be nice if
> we could simply have the list update in real-time.
>
> If we have to 'echo 1 > /proc/pidns/refresh' to update the fs tree under
> /proc/pidns/ to reflect new pidns activity, then why not just make this
> a text file? I suppose if it were a textfile you'd be encouraging ppl
> to 'cat pidlist | while read line; do grep line /proc/pidns; done',
> which would cause a refresh of that file for every grep?

Let's expose it in a text file
and refresh it when user open it.
style like:

level1 level2
/proc/2863/ns/pid /proc/10611/ns/pid
/proc/4450/ns/pid

It provided fairly the same information as dir trees.
And easy to use too.

>
> My concern with this approach is that it is unlike any other pseudo-fs
> that I know of, and people may simply expect the fs contents to be
> uptodate rather than a snapshot.
>
You're right, snapshot is not a good idea.
v2 will use a file /proc/pidns_hierarchy to show.

Thanks,
- Chen

N‹§²æ¸›yú²X¬¶ÇvØ–)Þ{.nlj·¥Š{±‘êX§¶›¡Ü}©ž²ÆzÚj:+v‰¨¾«‘êZ+€Êzf£¢·hšˆ§~†­†Ûÿû®w¥¢¸?™¨è&¢)ßf”ùy§m…á«a¶Úÿ 0¶ìå