From: Nagarathnam Muthusamy <nagarathnam.muthusamy@oracle.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-api@vger.kernel.org, linux-kernel@vger.kernel.org,
ebiederm@xmission.com, khlebnikov@yandex-team.ru,
serge.hallyn@ubuntu.com, oleg@redhat.com, luto@amacapital.net,
jannh@google.com, prakash.sangappa@oracle.com
Subject: Re: [RESEND PATCH V4] pidns: introduce syscall translate_pid
Date: Tue, 3 Apr 2018 14:45:28 -0700 [thread overview]
Message-ID: <678f275b-8d78-9b0f-177f-5ff5c9c55657@oracle.com> (raw)
In-Reply-To: <20180403143838.614ecc083835d07d409a699c@linux-foundation.org>
On 04/03/2018 02:38 PM, Andrew Morton wrote:
> On Mon, 2 Apr 2018 15:57:29 -0600 nagarathnam.muthusamy@oracle.com wrote:
>
>> pid_t translate_pid(pid_t pid, int source, int target);
>>
>> This syscall converts pid from source pid-ns into pid in target pid-ns.
>> If pid is unreachable from target pid-ns it returns zero.
>>
>> Pid-namespaces are referred file descriptors opened to proc files
>> /proc/[pid]/ns/pid or /proc/[pid]/ns/pid_for_children. Negative argument
>> refers to current pid namespace, same as file /proc/self/ns/pid.
>>
>> Kernel expose virtual pids in /proc/[pid]/status:NSpid, but backward
>> translation requires scanning all tasks. Also pids could be translated
>> by sending them through unix socket between namespaces, this method is
>> slow and insecure because other side is exposed inside pid namespace.
>>
>> Examples:
>> translate_pid(pid, ns, -1) - get pid in our pid namespace
>> translate_pid(pid, -1, ns) - get pid in other pid namespace
>> translate_pid(1, ns, -1) - get pid of init task for namespace
>> translate_pid(pid, -1, ns) > 0 - is pid is reachable from ns?
>> translate_pid(1, ns1, ns2) > 0 - is ns1 inside ns2?
>> translate_pid(1, ns1, ns2) == 0 - is ns1 outside ns2?
>> translate_pid(1, ns1, ns2) == 1 - is ns1 equal ns2?
>>
>> Error codes:
>> EBADF - file descriptor is closed
>> EINVAL - file descriptor isn't pid-namespace
>> ESRCH - task not found in @source namespace
> Presumably a manpage is planned?
>
> This changelog doesn't explain what the value is to our users. I
> assume it is a performance optimization because "backward translation
> requires scanning all tasks"? If so, please show us real-world
> examples of the performance benefit from this patch, and please go to
> great lengths to explain to us why this optimisation is needed by our
> users.
One of the usecase by Oracle database involves multiple levels of
nested pid namespaces and we require pid translation between the
levels. Discussions on the particular usecase, why any of the existing
methods was not usable happened in the following thread.
https://patchwork.kernel.org/patch/10276785/
At the end, it was agreed that this patch along with flocks will solve the
issue.
Thanks,
Nagarathnam.
next prev parent reply other threads:[~2018-04-03 21:45 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-02 21:57 [RESEND PATCH V4] pidns: introduce syscall translate_pid nagarathnam.muthusamy
2018-04-03 21:38 ` Andrew Morton
2018-04-03 21:45 ` Nagarathnam Muthusamy [this message]
2018-04-03 21:52 ` Andrew Morton
2018-04-03 21:51 ` Nagarathnam Muthusamy
2018-04-04 8:28 ` Konstantin Khlebnikov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=678f275b-8d78-9b0f-177f-5ff5c9c55657@oracle.com \
--to=nagarathnam.muthusamy@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=ebiederm@xmission.com \
--cc=jannh@google.com \
--cc=khlebnikov@yandex-team.ru \
--cc=linux-api@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=oleg@redhat.com \
--cc=prakash.sangappa@oracle.com \
--cc=serge.hallyn@ubuntu.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).