Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1233940
| From | Konstantin Khlebnikov <khlebnikov@yandex-team.ru> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 0/1] ns: introduce proc_get_ns_by_fd() |
| Date | 2015-09-28 10:30 +0200 |
| Message-ID | <qdBYS-h9-25@gated-at.bofh.it> (permalink) |
| References | <qcBHz-3cl-9@gated-at.bofh.it> <qcFBv-zc-1@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On 25.09.2015 20:56, Oleg Nesterov wrote:
> On 09/25, Konstantin Khlebnikov wrote:
>>
>> +struct ns_common *proc_ns_fdget(int fd, int nstype, struct fd *fd_ref)
>> {
>> - struct file *file;
>> + struct ns_common *ns;
>> + struct fd f;
>>
>> - file = fget(fd);
>> - if (!file)
>> + f = fdget(fd);
>> + if (!f.file)
>> return ERR_PTR(-EBADF);
>>
>> - if (file->f_op != &ns_file_operations)
>> + if (f.file->f_op != &ns_file_operations)
>> + goto out_invalid;
>> +
>> + ns = get_proc_ns(file_inode(f.file));
>> + if (nstype && (ns->ops->type != nstype))
>> goto out_invalid;
>>
>> - return file;
>> + *fd_ref = f;
>> + return ns;
>>
>> out_invalid:
>> - fput(file);
>> + fdput(f);
>> return ERR_PTR(-EINVAL);
>> }
>
> Well yes, fdget() makes sense but this is minor.
>
> Honestly, I do not really like the new helper... I understand this
> is subjective, so I won't insist. But how about 1/1? We do not need
> fd/file at all. With this patch your sys_getvpid() can just use
> proc_get_ns_by_fd(fd, CLONE_NEWPID) and put_pid_ns().
Hmm. My version has 0 or 2 atomic ops per get-put sequence.
Your version: 2 or 4 atomic ops. Plus even in worst case pinning by
struct fd theoretically scales better because it touches refcount at
struct file: there're might be many of them for one namespace.
>
> Eric, what do you think?
>
> See also "TODO" in the changelog.
>
> Oleg.
>
--
Konstantin
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH RFC v3 1/2] nsfs: replace proc_ns_fget() with proc_ns_fdget() Konstantin Khlebnikov <khlebnikov@yandex-team.ru> - 2015-09-25 16:00 +0200
[PATCH RFC v3 2/2] pidns: introduce syscall getvpid Konstantin Khlebnikov <khlebnikov@yandex-team.ru> - 2015-09-25 16:00 +0200
Re: [PATCH RFC v3 2/2] pidns: introduce syscall getvpid kbuild test robot <lkp@intel.com> - 2015-09-28 06:20 +0200
Re: [PATCH RFC v3 2/2] pidns: introduce syscall getvpid ebiederm@xmission.com (Eric W. Biederman) - 2015-09-28 18:30 +0200
Re: [PATCH RFC v3 2/2] pidns: introduce syscall getvpid ebiederm@xmission.com (Eric W. Biederman) - 2015-09-28 19:10 +0200
[PATCH 0/1] ns: introduce proc_get_ns_by_fd() Oleg Nesterov <oleg@redhat.com> - 2015-09-25 20:10 +0200
[PATCH 1/1] ns: introduce proc_get_ns_by_fd() Oleg Nesterov <oleg@redhat.com> - 2015-09-25 20:10 +0200
Re: [PATCH 0/1] ns: introduce proc_get_ns_by_fd() Konstantin Khlebnikov <khlebnikov@yandex-team.ru> - 2015-09-28 10:30 +0200
Re: [PATCH 0/1] ns: introduce proc_get_ns_by_fd() ebiederm@xmission.com (Eric W. Biederman) - 2015-09-28 18:50 +0200
Re: [PATCH 0/1] ns: introduce proc_get_ns_by_fd() Oleg Nesterov <oleg@redhat.com> - 2015-09-29 18:50 +0200
Re: [PATCH 0/1] ns: introduce proc_get_ns_by_fd() ebiederm@xmission.com (Eric W. Biederman) - 2015-09-29 19:40 +0200
Re: [PATCH 0/1] ns: introduce proc_get_ns_by_fd() Oleg Nesterov <oleg@redhat.com> - 2015-09-29 20:50 +0200
Re: [PATCH 0/1] ns: introduce proc_get_ns_by_fd() ebiederm@xmission.com (Eric W. Biederman) - 2015-09-29 21:20 +0200
Re: [PATCH 0/1] ns: introduce proc_get_ns_by_fd() Chen Fan <chen.fan.fnst@cn.fujitsu.com> - 2015-09-30 05:00 +0200
csiph-web