public inbox for [email protected]
 help / color / mirror / Atom feed
From: Andrii Nakryiko <[email protected]>
To: Christoph Hellwig <[email protected]>
Cc: Alexander Viro <[email protected]>,
	[email protected],
	open list <[email protected]>,
	[email protected], [email protected],
	[email protected], [email protected],
	[email protected], [email protected],
	Networking <[email protected]>, bpf <[email protected]>
Subject: Re: [PATCH 04/12] bpf: use __anon_inode_getfd
Date: Fri, 8 May 2020 10:32:41 -0700	[thread overview]
Message-ID: <CAEf4BzZ-gE87RVLPHGBfoNhHB+H7AnPbb7UUE7EGq8T5p_en_w@mail.gmail.com> (raw)
In-Reply-To: <[email protected]>

On Fri, May 8, 2020 at 8:39 AM Christoph Hellwig <[email protected]> wrote:
>
> Use __anon_inode_getfd instead of opencoding the logic using
> get_unused_fd_flags + anon_inode_getfile.  Also switch the
> bpf_link_new_file calling conventions to match __anon_inode_getfd.
>
> Signed-off-by: Christoph Hellwig <[email protected]>
> ---
>  include/linux/bpf.h  |  2 +-
>  kernel/bpf/cgroup.c  |  6 +++---
>  kernel/bpf/syscall.c | 31 +++++++++----------------------
>  3 files changed, 13 insertions(+), 26 deletions(-)
>

[...]

> diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
> index 64783da342020..cb2364e17423c 100644
> --- a/kernel/bpf/syscall.c
> +++ b/kernel/bpf/syscall.c
> @@ -2307,23 +2307,10 @@ int bpf_link_new_fd(struct bpf_link *link)
>   * complicated and expensive operations and should be delayed until all the fd
>   * reservation and anon_inode creation succeeds.
>   */

The comment above explains the reason why we do want to split getting
fd, getting file, and installing fd later. I'd like to keep it this
way. Also, this code was refactored in bpf-next by [0] (it still uses
get_unused_fd_flag + anon_inode_getfile + fd_install, by design).

  [0] https://patchwork.ozlabs.org/project/netdev/patch/[email protected]/

> -struct file *bpf_link_new_file(struct bpf_link *link, int *reserved_fd)
> +int bpf_link_new_file(struct bpf_link *link, struct file **file)
>  {
> -       struct file *file;
> -       int fd;
> -
> -       fd = get_unused_fd_flags(O_CLOEXEC);
> -       if (fd < 0)
> -               return ERR_PTR(fd);
> -
> -       file = anon_inode_getfile("bpf_link", &bpf_link_fops, link, O_CLOEXEC);
> -       if (IS_ERR(file)) {
> -               put_unused_fd(fd);
> -               return file;
> -       }
> -
> -       *reserved_fd = fd;
> -       return file;
> +       return __anon_inode_getfd("bpf_link", &bpf_link_fops, link, O_CLOEXEC,
> +                       file);
>  }
>

[...]

  reply	other threads:[~2020-05-08 17:32 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-08 15:36 Add a __anon_inode_getfd helper Christoph Hellwig
2020-05-08 15:36 ` [PATCH 01/12] fd: add a new " Christoph Hellwig
2020-05-08 15:36 ` [PATCH 02/12] kvm: use __anon_inode_getfd Christoph Hellwig
2020-05-08 15:36 ` [PATCH 03/12] pidfd: " Christoph Hellwig
2020-05-08 15:36 ` [PATCH 04/12] bpf: " Christoph Hellwig
2020-05-08 17:32   ` Andrii Nakryiko [this message]
2020-05-08 15:36 ` [PATCH 05/12] io_uring: " Christoph Hellwig
2020-05-08 15:36 ` [PATCH 06/12] eventpoll: " Christoph Hellwig
2020-05-08 15:36 ` [PATCH 07/12] eventfd: " Christoph Hellwig
2020-05-08 15:36 ` [PATCH 08/12] vfio: " Christoph Hellwig
2020-05-08 15:55   ` Alex Williamson
2020-05-08 15:36 ` [PATCH 09/12] rdma: " Christoph Hellwig
2020-05-08 19:52   ` Jason Gunthorpe
2020-05-08 15:36 ` [PATCH 10/12] drm_syncobj: " Christoph Hellwig
2020-05-08 15:36 ` [PATCH 11/12] gpiolib: " Christoph Hellwig
2020-05-08 15:36 ` [PATCH 12/12] vtpm_proxy: " Christoph Hellwig

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=CAEf4BzZ-gE87RVLPHGBfoNhHB+H7AnPbb7UUE7EGq8T5p_en_w@mail.gmail.com \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    /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