From: Oleg Nesterov <oleg-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: Konstantin Khlebnikov <koct9i-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: "Konstantin Khlebnikov"
<khlebnikov-XoJtRXgx1JseBXzfvpsJ4g@public.gmane.org>,
"Linux API" <linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
"Linux Containers"
<containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org>,
"Linux Kernel Mailing List"
<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
"Serge Hallyn"
<serge.hallyn-GeWIH/nMZzLQT0dZR+AlfA@public.gmane.org>,
"Eric W. Biederman"
<ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>,
"Chen Fan"
<chen.fan.fnst-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>,
"Andrew Morton"
<akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>,
"Linus Torvalds"
<torvalds-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>,
"Stéphane Graber"
<stgraber-GeWIH/nMZzLQT0dZR+AlfA@public.gmane.org>
Subject: Re: [PATCH RFC v2] pidns: introduce syscall getvpid
Date: Thu, 24 Sep 2015 19:34:30 +0200 [thread overview]
Message-ID: <20150924173430.GA31073@redhat.com> (raw)
In-Reply-To: <CALYGNiPCVFNLi=1iL1gOf411iU6tT+DbVx1JuGG+f73Rpvx3dw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
On 09/24, Konstantin Khlebnikov wrote:
>
> On Thu, Sep 24, 2015 at 5:56 PM, Oleg Nesterov <oleg-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> wrote:
> > On 09/24, Konstantin Khlebnikov wrote:
> >>
> >> +SYSCALL_DEFINE3(getvpid, pid_t, pid, int, source, int, target)
> >> +{
> >> + struct file *source_file = NULL, *target_file = NULL;
> >> + struct pid_namespace *source_ns, *target_ns;
> >> + struct pid *struct_pid;
> >> + struct ns_common *ns;
> >> + pid_t result;
> >> +
> >> + if (source >= 0) {
> >> + source_file = proc_ns_fget(source);
> >> + result = PTR_ERR(source_file);
> >> + if (IS_ERR(source_file))
> >> + goto out;
> >> + ns = get_proc_ns(file_inode(source_file));
> >> + result = -EINVAL;
> >> + if (ns->ops->type != CLONE_NEWPID)
> >> + goto out;
> >> + source_ns = container_of(ns, struct pid_namespace, ns);
> >> + } else
> >> + source_ns = task_active_pid_ns(current);
> >> +
> >> + if (target >= 0) {
> >> + target_file = proc_ns_fget(target);
> >> + result = PTR_ERR(target_file);
> >> + if (IS_ERR(target_file))
> >> + goto out;
> >> + ns = get_proc_ns(file_inode(target_file));
> >> + result = -EINVAL;
> >> + if (ns->ops->type != CLONE_NEWPID)
> >> + goto out;
> >> + target_ns = container_of(ns, struct pid_namespace, ns);
> >> + } else
> >> + target_ns = task_active_pid_ns(current);
> >> +
> >
> > Hmm. Eric, Konstantin, how about (uncompiled/untested) patch below
> > in a preparation? The code above doesn't look very readable.
>
> I've tried to do something like that but that comes too far so send patch as is.
OK, I won't insist.
The code above asks for cleanup/factorization, but we can do this
later.
> Actually we can go deeper and replace struct file* with struct fd: this saves
> couple atomic ops for singlethreaded task.
it's not about performance...
But yes, we can do more and create get_pid_ns_by_fd() similar to
get_net_ns_by_fd(). We do not need file at all, we need pid_ns.
Oleg.
WARNING: multiple messages have this Message-ID (diff)
From: Oleg Nesterov <oleg@redhat.com>
To: Konstantin Khlebnikov <koct9i@gmail.com>
Cc: "Konstantin Khlebnikov" <khlebnikov@yandex-team.ru>,
"Linux API" <linux-api@vger.kernel.org>,
"Linux Containers" <containers@lists.linux-foundation.org>,
"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>,
"Serge Hallyn" <serge.hallyn@ubuntu.com>,
"Eric W. Biederman" <ebiederm@xmission.com>,
"Chen Fan" <chen.fan.fnst@cn.fujitsu.com>,
"Andrew Morton" <akpm@linux-foundation.org>,
"Linus Torvalds" <torvalds@linux-foundation.org>,
"Stéphane Graber" <stgraber@ubuntu.com>
Subject: Re: [PATCH RFC v2] pidns: introduce syscall getvpid
Date: Thu, 24 Sep 2015 19:34:30 +0200 [thread overview]
Message-ID: <20150924173430.GA31073@redhat.com> (raw)
In-Reply-To: <CALYGNiPCVFNLi=1iL1gOf411iU6tT+DbVx1JuGG+f73Rpvx3dw@mail.gmail.com>
On 09/24, Konstantin Khlebnikov wrote:
>
> On Thu, Sep 24, 2015 at 5:56 PM, Oleg Nesterov <oleg@redhat.com> wrote:
> > On 09/24, Konstantin Khlebnikov wrote:
> >>
> >> +SYSCALL_DEFINE3(getvpid, pid_t, pid, int, source, int, target)
> >> +{
> >> + struct file *source_file = NULL, *target_file = NULL;
> >> + struct pid_namespace *source_ns, *target_ns;
> >> + struct pid *struct_pid;
> >> + struct ns_common *ns;
> >> + pid_t result;
> >> +
> >> + if (source >= 0) {
> >> + source_file = proc_ns_fget(source);
> >> + result = PTR_ERR(source_file);
> >> + if (IS_ERR(source_file))
> >> + goto out;
> >> + ns = get_proc_ns(file_inode(source_file));
> >> + result = -EINVAL;
> >> + if (ns->ops->type != CLONE_NEWPID)
> >> + goto out;
> >> + source_ns = container_of(ns, struct pid_namespace, ns);
> >> + } else
> >> + source_ns = task_active_pid_ns(current);
> >> +
> >> + if (target >= 0) {
> >> + target_file = proc_ns_fget(target);
> >> + result = PTR_ERR(target_file);
> >> + if (IS_ERR(target_file))
> >> + goto out;
> >> + ns = get_proc_ns(file_inode(target_file));
> >> + result = -EINVAL;
> >> + if (ns->ops->type != CLONE_NEWPID)
> >> + goto out;
> >> + target_ns = container_of(ns, struct pid_namespace, ns);
> >> + } else
> >> + target_ns = task_active_pid_ns(current);
> >> +
> >
> > Hmm. Eric, Konstantin, how about (uncompiled/untested) patch below
> > in a preparation? The code above doesn't look very readable.
>
> I've tried to do something like that but that comes too far so send patch as is.
OK, I won't insist.
The code above asks for cleanup/factorization, but we can do this
later.
> Actually we can go deeper and replace struct file* with struct fd: this saves
> couple atomic ops for singlethreaded task.
it's not about performance...
But yes, we can do more and create get_pid_ns_by_fd() similar to
get_net_ns_by_fd(). We do not need file at all, we need pid_ns.
Oleg.
next prev parent reply other threads:[~2015-09-24 17:34 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-24 13:53 [PATCH RFC v2] pidns: introduce syscall getvpid Konstantin Khlebnikov
2015-09-24 13:53 ` Konstantin Khlebnikov
2015-09-24 14:56 ` Oleg Nesterov
2015-09-24 14:56 ` Oleg Nesterov
[not found] ` <20150924145647.GA24151-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-09-24 15:47 ` Konstantin Khlebnikov
2015-09-24 15:47 ` Konstantin Khlebnikov
2015-09-24 15:47 ` Konstantin Khlebnikov
[not found] ` <CALYGNiPCVFNLi=1iL1gOf411iU6tT+DbVx1JuGG+f73Rpvx3dw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-09-24 17:34 ` Oleg Nesterov [this message]
2015-09-24 17:34 ` Oleg Nesterov
2015-09-24 17:34 ` Oleg Nesterov
2015-09-25 8:36 ` Chen Fan
2015-09-25 8:36 ` Chen Fan
-- strict thread matches above, loose matches on Subject: below --
2015-09-24 13:53 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=20150924173430.GA31073@redhat.com \
--to=oleg-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
--cc=akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org \
--cc=chen.fan.fnst-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org \
--cc=containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
--cc=ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org \
--cc=khlebnikov-XoJtRXgx1JseBXzfvpsJ4g@public.gmane.org \
--cc=koct9i-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=serge.hallyn-GeWIH/nMZzLQT0dZR+AlfA@public.gmane.org \
--cc=stgraber-GeWIH/nMZzLQT0dZR+AlfA@public.gmane.org \
--cc=torvalds-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.