netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexei Starovoitov <alexei.starovoitov@gmail.com>
To: Andrii Nakryiko <andriin@fb.com>
Cc: bpf@vger.kernel.org, netdev@vger.kernel.org, ast@fb.com,
	daniel@iogearbox.net, andrii.nakryiko@gmail.com,
	kernel-team@fb.com
Subject: Re: [PATCH v2 bpf-next 02/10] bpf: allocate ID for bpf_link
Date: Tue, 28 Apr 2020 10:31:20 -0700	[thread overview]
Message-ID: <20200428173120.lof25gzz75bx5ot7@ast-mbp.dhcp.thefacebook.com> (raw)
In-Reply-To: <20200428054944.4015462-3-andriin@fb.com>

On Mon, Apr 27, 2020 at 10:49:36PM -0700, Andrii Nakryiko wrote:
> +int bpf_link_settle(struct bpf_link_primer *primer)
> +{
> +	/* make bpf_link fetchable by ID */
> +	WRITE_ONCE(primer->link->id, primer->id);

what does WRITE_ONCE serve here?
bpf_link_settle can only be called at the end of attach.
If attach is slow than parallel get_fd_by_id can get an new FD
instance for link with zero id.
In such case deref of link->id will race with above assignment?
But I don't see READ_ONCE in patch 3.
It's under link_idr_lock there.
How about grabbing link_idr_lock here as well ?
otherwise it's still racy since WRITE_ONCE is not paired.

The mix of spin_lock_irqsave(&link_idr_lock)
and spin_lock_bh(&link_idr_lock) looks weird.
We do the same for map_idr because maps have complicated freeing logic,
but prog_idr is consistent.
If you see the need for irqsave variant then please use it in all cases.

  reply	other threads:[~2020-04-28 17:31 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-28  5:49 [PATCH v2 bpf-next 00/10] bpf_link observability APIs Andrii Nakryiko
2020-04-28  5:49 ` [PATCH v2 bpf-next 01/10] bpf: refactor bpf_link update handling Andrii Nakryiko
2020-04-28  5:49 ` [PATCH v2 bpf-next 02/10] bpf: allocate ID for bpf_link Andrii Nakryiko
2020-04-28 17:31   ` Alexei Starovoitov [this message]
2020-04-28 18:56     ` Andrii Nakryiko
2020-04-28 20:38       ` Alexei Starovoitov
2020-04-28 22:33         ` Andrii Nakryiko
2020-04-28 22:43           ` Alexei Starovoitov
2020-04-28 23:25             ` Andrii Nakryiko
2020-04-29  0:11               ` Alexei Starovoitov
2020-04-28  5:49 ` [PATCH v2 bpf-next 03/10] bpf: support GET_FD_BY_ID and GET_NEXT_ID " Andrii Nakryiko
2020-04-28  5:49 ` [PATCH v2 bpf-next 04/10] bpf: add support for BPF_OBJ_GET_INFO_BY_FD " Andrii Nakryiko
2020-04-28  9:46   ` Toke Høiland-Jørgensen
2020-04-28 16:27     ` Andrii Nakryiko
2020-04-28 18:31       ` Toke Høiland-Jørgensen
2020-04-28 21:55   ` kbuild test robot
2020-04-28  5:49 ` [PATCH v2 bpf-next 05/10] libbpf: add low-level APIs for new bpf_link commands Andrii Nakryiko
2020-04-28  5:49 ` [PATCH v2 bpf-next 06/10] selftests/bpf: test bpf_link's get_next_id, get_fd_by_id, and get_obj_info Andrii Nakryiko
2020-04-28  5:49 ` [PATCH v2 bpf-next 07/10] bpftool: expose attach_type-to-string array to non-cgroup code Andrii Nakryiko
2020-04-28  8:22   ` Quentin Monnet
2020-04-28  5:49 ` [PATCH v2 bpf-next 08/10] bpftool: add bpf_link show and pin support Andrii Nakryiko
2020-04-28  8:23   ` Quentin Monnet
2020-04-28  5:49 ` [PATCH v2 bpf-next 09/10] bpftool: add bpftool-link manpage Andrii Nakryiko
2020-04-28  8:23   ` Quentin Monnet
2020-04-28  5:49 ` [PATCH v2 bpf-next 10/10] bpftool: add link bash completions Andrii Nakryiko

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=20200428173120.lof25gzz75bx5ot7@ast-mbp.dhcp.thefacebook.com \
    --to=alexei.starovoitov@gmail.com \
    --cc=andrii.nakryiko@gmail.com \
    --cc=andriin@fb.com \
    --cc=ast@fb.com \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kernel-team@fb.com \
    --cc=netdev@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).