public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
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.


  reply	other threads:[~2015-09-24 17:37 UTC|newest]

Thread overview: 5+ 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 14:56 ` Oleg Nesterov
2015-09-24 15:47   ` Konstantin Khlebnikov
2015-09-24 17:34     ` Oleg Nesterov [this message]
2015-09-25  8:36 ` Chen Fan

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@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=chen.fan.fnst@cn.fujitsu.com \
    --cc=containers@lists.linux-foundation.org \
    --cc=ebiederm@xmission.com \
    --cc=khlebnikov@yandex-team.ru \
    --cc=koct9i@gmail.com \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=serge.hallyn@ubuntu.com \
    --cc=stgraber@ubuntu.com \
    --cc=torvalds@linux-foundation.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox