From: Jesper Dangaard Brouer <brouer@redhat.com>
To: John Fastabend <john.fastabend@gmail.com>
Cc: brouer@redhat.com, bpf@vger.kernel.org, bjorn.topel@intel.com,
songliubraving@fb.com, ast@kernel.org, daniel@iogearbox.net,
toke@redhat.com, maciej.fijalkowski@intel.com,
netdev@vger.kernel.org
Subject: Re: [PATCH bpf-next v2 3/3] bpf: xdp, remove no longer required rcu_read_{un}lock()
Date: Sun, 26 Jan 2020 22:30:06 +0100 [thread overview]
Message-ID: <20200126223006.2b8582c5@carbon> (raw)
In-Reply-To: <1580011133-17784-4-git-send-email-john.fastabend@gmail.com>
On Sat, 25 Jan 2020 19:58:53 -0800
John Fastabend <john.fastabend@gmail.com> wrote:
> Now that we depend on rcu_call() and synchronize_rcu() to also wait
> for preempt_disabled region to complete the rcu read critical section
> in __dev_map_flush() is no longer required. Except in a few special
> cases in drivers that need it for other reasons.
>
> These originally ensured the map reference was safe while a map was
> also being free'd. And additionally that bpf program updates via
> ndo_bpf did not happen while flush updates were in flight. But flush
> by new rules can only be called from preempt-disabled NAPI context.
> The synchronize_rcu from the map free path and the rcu_call from the
> delete path will ensure the reference there is safe. So lets remove
> the rcu_read_lock and rcu_read_unlock pair to avoid any confusion
> around how this is being protected.
>
> If the rcu_read_lock was required it would mean errors in the above
> logic and the original patch would also be wrong.
>
> Now that we have done above we put the rcu_read_lock in the driver
> code where it is needed in a driver dependent way. I think this
> helps readability of the code so we know where and why we are
> taking read locks. Most drivers will not need rcu_read_locks here
> and further XDP drivers already have rcu_read_locks in their code
> paths for reading xdp programs on RX side so this makes it symmetric
> where we don't have half of rcu critical sections define in driver
> and the other half in devmap.
>
> Signed-off-by: John Fastabend <john.fastabend@gmail.com>
Acked-by: Jesper Dangaard Brouer <brouer@redhat.com>
--
Best regards,
Jesper Dangaard Brouer
MSc.CS, Principal Kernel Engineer at Red Hat
LinkedIn: http://www.linkedin.com/in/brouer
prev parent reply other threads:[~2020-01-26 21:30 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-26 3:58 [PATCH bpf-next v2 0/3] XDP flush cleanups John Fastabend
2020-01-26 3:58 ` [PATCH bpf-next v2 1/3] bpf: xdp, update devmap comments to reflect napi/rcu usage John Fastabend
2020-01-26 21:28 ` Jesper Dangaard Brouer
2020-01-26 3:58 ` [PATCH bpf-next v2 2/3] bpf: xdp, virtio_net use access ptr macro for xdp enable check John Fastabend
2020-01-26 21:28 ` Jesper Dangaard Brouer
2020-01-26 3:58 ` [PATCH bpf-next v2 3/3] bpf: xdp, remove no longer required rcu_read_{un}lock() John Fastabend
2020-01-26 21:30 ` Jesper Dangaard Brouer [this message]
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=20200126223006.2b8582c5@carbon \
--to=brouer@redhat.com \
--cc=ast@kernel.org \
--cc=bjorn.topel@intel.com \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=john.fastabend@gmail.com \
--cc=maciej.fijalkowski@intel.com \
--cc=netdev@vger.kernel.org \
--cc=songliubraving@fb.com \
--cc=toke@redhat.com \
/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).