All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Toke Høiland-Jørgensen" <toke@redhat.com>
To: 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>,
	"Toke Høiland-Jørgensen" <toke@redhat.com>
Subject: [PATCH bpf-next v2 00/16] Clean up and document RCU-based object protection for XDP_REDIRECT
Date: Tue, 15 Jun 2021 16:54:39 +0200	[thread overview]
Message-ID: <20210615145455.564037-1-toke@redhat.com> (raw)

During the discussion[0] of Hangbin's multicast patch series, Martin pointed out
that the lifetime of the RCU-protected  map entries used by XDP_REDIRECT is by
no means obvious. I promised to look into cleaning this up, and Paul helpfully
provided some hints and a new unrcu_pointer() helper to aid in this.

It seems[1] that back in the early days of XDP, local_bh_disable() did not
provide RCU protection, which is why the rcu_read_lock() calls were added
to drivers in the first place. But according to Paul[2], in recent kernels
a local_bh_disable()/local_bh_enable() pair functions as one big RCU
read-side section, so no further protection is needed. This even applies to
-rt kernels, which has an explicit rcu_read_lock() in place as part of the
local_bh_disable()[3].

This patch series is mostly a documentation exercise, cleaning up the
description of the lifetime expectations and adding __rcu annotations so
sparse and lockdep can help verify it.

Patches 1 and 2 are preparatory: Patch 1 adds Paul's unrcu_pointer()
helper (which has already been added to his tree), which we need for some
of the operations in devmap, and patch 2 adds bh context as a valid
condition for map lookups. Patch 3 is the main bit that adds the __rcu
annotations and updates documentation comments, and the rest are patches
updating the drivers, with one patch per distinct maintainer.

Unfortunately I don't have any hardware to test any of the driver patches;
Jesper helpfully verified that it doesn't break anything on i40e, but the rest
of the driver patches are only compile-tested.

[0] https://lore.kernel.org/bpf/20210415173551.7ma4slcbqeyiba2r@kafai-mbp.dhcp.thefacebook.com/
[1] https://lore.kernel.org/bpf/c5192ab3-1c05-8679-79f2-59d98299095b@iogearbox.net/
[2] https://lore.kernel.org/bpf/20210417002301.GO4212@paulmck-ThinkPad-P17-Gen-1/
[3] https://lore.kernel.org/bpf/20210419165837.GA975577@paulmck-ThinkPad-P17-Gen-1/

Changelog:
v2:
  - Add a comment about RCU protection to the drivers where rcu_read_lock()
    is removed
  - Drop unnecessary patch 3 which changed dev_get_by_index_rcu()
  - Add some more text with the history to cover letter
  - Fix a few places where the wrong RCU checks were used in cpumap and
    xskmap code
  - Carry forward ACKs

Paul E. McKenney (1):
  rcu: Create an unrcu_pointer() to remove __rcu from a pointer

Toke Høiland-Jørgensen (15):
  bpf: allow RCU-protected lookups to happen from bh context
  xdp: add proper __rcu annotations to redirect map entries
  ena: remove rcu_read_lock() around XDP program invocation
  bnxt: remove rcu_read_lock() around XDP program invocation
  thunderx: remove rcu_read_lock() around XDP program invocation
  freescale: remove rcu_read_lock() around XDP program invocation
  net: intel: remove rcu_read_lock() around XDP program invocation
  marvell: remove rcu_read_lock() around XDP program invocation
  mlx4: remove rcu_read_lock() around XDP program invocation
  nfp: remove rcu_read_lock() around XDP program invocation
  qede: remove rcu_read_lock() around XDP program invocation
  sfc: remove rcu_read_lock() around XDP program invocation
  netsec: remove rcu_read_lock() around XDP program invocation
  stmmac: remove rcu_read_lock() around XDP program invocation
  net: ti: remove rcu_read_lock() around XDP program invocation

 drivers/net/ethernet/amazon/ena/ena_netdev.c  |  6 +--
 drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c |  5 +-
 .../net/ethernet/cavium/thunder/nicvf_main.c  |  5 +-
 .../net/ethernet/freescale/dpaa/dpaa_eth.c    | 11 ++--
 .../net/ethernet/freescale/dpaa2/dpaa2-eth.c  |  6 +--
 drivers/net/ethernet/intel/i40e/i40e_txrx.c   |  5 +-
 drivers/net/ethernet/intel/i40e/i40e_xsk.c    | 11 ++--
 drivers/net/ethernet/intel/ice/ice_txrx.c     |  6 +--
 drivers/net/ethernet/intel/ice/ice_xsk.c      |  6 +--
 drivers/net/ethernet/intel/igb/igb_main.c     |  5 +-
 drivers/net/ethernet/intel/igc/igc_main.c     | 10 ++--
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c |  5 +-
 drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c  |  9 ++--
 .../net/ethernet/intel/ixgbevf/ixgbevf_main.c |  5 +-
 drivers/net/ethernet/marvell/mvneta.c         |  6 ++-
 .../net/ethernet/marvell/mvpp2/mvpp2_main.c   |  8 +--
 drivers/net/ethernet/mellanox/mlx4/en_rx.c    |  8 +--
 .../ethernet/netronome/nfp/nfp_net_common.c   |  6 ++-
 drivers/net/ethernet/qlogic/qede/qede_fp.c    |  7 +--
 drivers/net/ethernet/sfc/rx.c                 | 12 ++---
 drivers/net/ethernet/socionext/netsec.c       |  7 +--
 .../net/ethernet/stmicro/stmmac/stmmac_main.c | 13 ++---
 drivers/net/ethernet/ti/cpsw_priv.c           | 13 ++---
 include/linux/rcupdate.h                      | 14 +++++
 include/net/xdp_sock.h                        |  2 +-
 kernel/bpf/cpumap.c                           | 13 +++--
 kernel/bpf/devmap.c                           | 52 ++++++++-----------
 kernel/bpf/hashtab.c                          | 21 +++++---
 kernel/bpf/helpers.c                          |  6 +--
 kernel/bpf/lpm_trie.c                         |  6 ++-
 net/core/filter.c                             | 28 ++++++++++
 net/xdp/xsk.c                                 |  4 +-
 net/xdp/xsk.h                                 |  4 +-
 net/xdp/xskmap.c                              | 29 ++++++-----
 34 files changed, 196 insertions(+), 158 deletions(-)

-- 
2.31.1


             reply	other threads:[~2021-06-15 14:55 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-15 14:54 Toke Høiland-Jørgensen [this message]
2021-06-15 14:54 ` [PATCH bpf-next v2 01/16] rcu: Create an unrcu_pointer() to remove __rcu from a pointer Toke Høiland-Jørgensen
2021-06-15 14:54 ` [PATCH bpf-next v2 02/16] bpf: allow RCU-protected lookups to happen from bh context Toke Høiland-Jørgensen
2021-06-15 14:54 ` [PATCH bpf-next v2 03/16] xdp: add proper __rcu annotations to redirect map entries Toke Høiland-Jørgensen
2021-06-17 19:41   ` Martin KaFai Lau
2021-06-17 21:13     ` Toke Høiland-Jørgensen
2021-06-15 14:54 ` [PATCH bpf-next v2 04/16] ena: remove rcu_read_lock() around XDP program invocation Toke Høiland-Jørgensen
2021-06-15 14:54 ` [PATCH bpf-next v2 05/16] bnxt: " Toke Høiland-Jørgensen
2021-06-15 14:54 ` [PATCH bpf-next v2 06/16] thunderx: " Toke Høiland-Jørgensen
2021-06-15 14:54   ` Toke Høiland-Jørgensen
2021-06-15 14:54 ` [PATCH bpf-next v2 07/16] freescale: " Toke Høiland-Jørgensen
2021-06-16 14:58   ` Camelia Alexandra Groza
2021-06-15 14:54 ` [PATCH bpf-next v2 08/16] net: intel: " Toke Høiland-Jørgensen
2021-06-15 14:54   ` [Intel-wired-lan] " Toke =?unknown-8bit?q?H=C3=B8iland-J=C3=B8rgensen?=
2021-06-15 14:54 ` [PATCH bpf-next v2 09/16] marvell: " Toke Høiland-Jørgensen
2021-06-15 14:54 ` [PATCH bpf-next v2 10/16] mlx4: " Toke Høiland-Jørgensen
2021-06-15 14:54 ` [PATCH bpf-next v2 11/16] nfp: " Toke Høiland-Jørgensen
2021-06-15 14:54 ` [PATCH bpf-next v2 12/16] qede: " Toke Høiland-Jørgensen
2021-06-15 14:54 ` [PATCH bpf-next v2 13/16] sfc: " Toke Høiland-Jørgensen
2021-06-15 14:54 ` [PATCH bpf-next v2 14/16] netsec: " Toke Høiland-Jørgensen
2021-06-15 14:54 ` [PATCH bpf-next v2 15/16] stmmac: " Toke Høiland-Jørgensen
2021-06-15 14:54 ` [PATCH bpf-next v2 16/16] 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=20210615145455.564037-1-toke@redhat.com \
    --to=toke@redhat.com \
    --cc=bpf@vger.kernel.org \
    --cc=brouer@redhat.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.