Re: Question: How to switch a process namespace by nsfs "device" and inode number directly?
From: Andi Kleen
Date: Mon Sep 10 2018 - 12:02:11 EST
On Mon, Sep 10, 2018 at 04:50:42PM +0800, Chengdong Li wrote:
> Hi folks,
>
> I am getting stuck by the lack of approach to switch process namespace by
> nsfs "device" and inode number in user-space, for example (mnt: 0xf0000000)
>
> From my best understanding, the normal way to do that is by setns system
> call. But setns only accept fd that refer to a opened namespace, sometimes
> we couldn't get it.
>
> For example: After perf record, perf report couldn't work well once the
> process that runs inside a container has exited, as the /proc/pid/ns doesn't
> exist anymore after process exit.
The kernel name space doesn't exist anymore at this point, so there is simply no way
to reconstruct it.
Perhaps would need some higher level side band data for perf, similar as what
is done for JITed code. Somehow the container run time needs to tell perf
where to find the code.
-Andi