netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Toke Høiland-Jørgensen" <toke@redhat.com>
To: Daniel Borkmann <daniel@iogearbox.net>,
	bpf@vger.kernel.org, netdev@vger.kernel.org
Cc: Martin KaFai Lau <kafai@fb.com>,
	Hangbin Liu <liuhangbin@gmail.com>,
	Jesper Dangaard Brouer <brouer@redhat.com>,
	Magnus Karlsson <magnus.karlsson@gmail.com>,
	"Paul E . McKenney" <paulmck@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>
Subject: Re: [PATCH bpf-next v4 05/19] xdp: add proper __rcu annotations to redirect map entries
Date: Thu, 24 Jun 2021 16:52:52 +0200	[thread overview]
Message-ID: <87eecrmi0r.fsf@toke.dk> (raw)
In-Reply-To: <f26af869-5ea2-878a-a263-ae6f099043e9@iogearbox.net>

Daniel Borkmann <daniel@iogearbox.net> writes:

> On 6/23/21 1:07 PM, Toke Høiland-Jørgensen wrote:
>> XDP_REDIRECT works by a three-step process: the bpf_redirect() and
>> bpf_redirect_map() helpers will lookup the target of the redirect and store
>> it (along with some other metadata) in a per-CPU struct bpf_redirect_info.
>> Next, when the program returns the XDP_REDIRECT return code, the driver
>> will call xdp_do_redirect() which will use the information thus stored to
>> actually enqueue the frame into a bulk queue structure (that differs
>> slightly by map type, but shares the same principle). Finally, before
>> exiting its NAPI poll loop, the driver will call xdp_do_flush(), which will
>> flush all the different bulk queues, thus completing the redirect.
> [...]
>> 
>> Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
> [...]
>> diff --git a/include/linux/filter.h b/include/linux/filter.h
>> index c5ad7df029ed..b01e266dad9e 100644
>> --- a/include/linux/filter.h
>> +++ b/include/linux/filter.h
>> @@ -762,12 +762,10 @@ DECLARE_BPF_DISPATCHER(xdp)
>>   
>>   static __always_inline u32 bpf_prog_run_xdp(const struct bpf_prog *prog,
>>   					    struct xdp_buff *xdp)
>> -{
>> -	/* Caller needs to hold rcu_read_lock() (!), otherwise program
>> -	 * can be released while still running, or map elements could be
>> -	 * freed early while still having concurrent users. XDP fastpath
>> -	 * already takes rcu_read_lock() when fetching the program, so
>> -	 * it's not necessary here anymore.
>> +
>> +	/* Driver XDP hooks are invoked within a single NAPI poll cycle and thus
>> +	 * under local_bh_disable(), which provides the needed RCU protection
>> +	 * for accessing map entries.
>>   	 */
>>   	return __BPF_PROG_RUN(prog, xdp, BPF_DISPATCHER_FUNC(xdp));
>>   }
>
> I just went over the series to manually fix up merge conflicts in the driver
> patches since they didn't apply cleanly against bpf-next.
>
> But as it turned out that extra work was needless, since you didn't even compile
> test the series before submission, sigh.
>
> Please fix (and only submit compile- & runtime-tested code in future).

Yikes! I was too much in a hurry with to re-submit and neglected to
re-do the compile check before hitting send. Apologies, that was sloppy
of me - I will do better in the future.

Will rebase and send a v5 that doesn't blow up on compile :)

-Toke


  reply	other threads:[~2021-06-24 14:53 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-23 11:07 [PATCH bpf-next v4 00/19] Clean up and document RCU-based object protection for XDP and TC BPF Toke Høiland-Jørgensen
2021-06-23 11:07 ` [PATCH bpf-next v4 01/19] rcu: Create an unrcu_pointer() to remove __rcu from a pointer Toke Høiland-Jørgensen
2021-06-23 11:07 ` [PATCH bpf-next v4 02/19] doc: Clarify and expand RCU updaters and corresponding readers Toke Høiland-Jørgensen
2021-06-23 11:07 ` [PATCH bpf-next v4 03/19] doc: Give XDP as example of non-obvious RCU reader/updater pairing Toke Høiland-Jørgensen
2021-06-23 11:07 ` [PATCH bpf-next v4 04/19] bpf: allow RCU-protected lookups to happen from bh context Toke Høiland-Jørgensen
2021-06-23 11:07 ` [PATCH bpf-next v4 05/19] xdp: add proper __rcu annotations to redirect map entries Toke Høiland-Jørgensen
2021-06-24 13:12   ` Daniel Borkmann
2021-06-24 14:52     ` Toke Høiland-Jørgensen [this message]
2021-06-23 11:07 ` [PATCH bpf-next v4 06/19] sched: remove unneeded rcu_read_lock() around BPF program invocation Toke Høiland-Jørgensen
2021-06-23 11:07 ` [PATCH bpf-next v4 07/19] ena: remove rcu_read_lock() around XDP " Toke Høiland-Jørgensen
2021-06-23 11:07 ` [PATCH bpf-next v4 08/19] bnxt: " Toke Høiland-Jørgensen
2021-06-23 11:07 ` [PATCH bpf-next v4 09/19] thunderx: " Toke Høiland-Jørgensen
2021-06-23 11:07 ` [PATCH bpf-next v4 10/19] freescale: " Toke Høiland-Jørgensen
2021-06-23 11:07 ` [PATCH bpf-next v4 11/19] net: intel: " Toke Høiland-Jørgensen
2021-06-23 11:07 ` [PATCH bpf-next v4 12/19] marvell: " Toke Høiland-Jørgensen
2021-06-23 11:07 ` [PATCH bpf-next v4 13/19] mlx4: " Toke Høiland-Jørgensen
2021-06-23 11:07 ` [PATCH bpf-next v4 14/19] nfp: " Toke Høiland-Jørgensen
2021-06-23 11:07 ` [PATCH bpf-next v4 15/19] qede: " Toke Høiland-Jørgensen
2021-06-23 11:07 ` [PATCH bpf-next v4 16/19] sfc: " Toke Høiland-Jørgensen
2021-06-23 11:07 ` [PATCH bpf-next v4 17/19] netsec: " Toke Høiland-Jørgensen
2021-06-23 11:07 ` [PATCH bpf-next v4 18/19] stmmac: " Toke Høiland-Jørgensen
2021-06-23 11:07 ` [PATCH bpf-next v4 19/19] net: ti: " Toke Høiland-Jørgensen

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=87eecrmi0r.fsf@toke.dk \
    --to=toke@redhat.com \
    --cc=bpf@vger.kernel.org \
    --cc=brouer@redhat.com \
    --cc=daniel@iogearbox.net \
    --cc=kafai@fb.com \
    --cc=kuba@kernel.org \
    --cc=liuhangbin@gmail.com \
    --cc=magnus.karlsson@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=paulmck@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).