From: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
To: Alexander Lobakin <aleksander.lobakin@intel.com>
Cc: <intel-wired-lan@lists.osuosl.org>, <netdev@vger.kernel.org>,
<anthony.l.nguyen@intel.com>, <fred@cloudflare.com>,
<magnus.karlsson@intel.com>
Subject: Re: [Intel-wired-lan] [PATCH iwl-next] ice: allow hot-swapping XDP programs
Date: Tue, 13 Jun 2023 17:20:25 +0200 [thread overview]
Message-ID: <ZIiJOVMs4qK+PDsp@boxer> (raw)
In-Reply-To: <9eee635f-0898-f9d3-f3ba-f6da662c90cc@intel.com>
On Tue, Jun 13, 2023 at 05:15:15PM +0200, Alexander Lobakin wrote:
> From: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
> Date: Tue, 13 Jun 2023 17:10:05 +0200
>
> > Currently ice driver's .ndo_bpf callback brings the interface down and
> > up independently of the presence of XDP resources. This is only needed
> > when either these resources have to be configured or removed. It means
> > that if one is switching XDP programs on-the-fly with running traffic,
> > packets will be dropped.
> >
> > To avoid this, compare early on ice_xdp_setup_prog() state of incoming
> > bpf_prog pointer vs the bpf_prog pointer that is already assigned to
> > VSI. Do the swap in case VSI has bpf_prog and incoming one are non-NULL.
> >
> > Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
>
> [0] :D
>
> But if be serious, are you sure you won't have any pointer tears /
> partial reads/writes without such RCU protection as added in the
> linked commit ?
Since we removed rcu sections from driver sides and given an assumption
that local_bh_{dis,en}able() pair serves this purpose now i believe this
is safe. Are you aware of:
https://lore.kernel.org/bpf/20210624160609.292325-1-toke@redhat.com/
?
>
> > ---
> > drivers/net/ethernet/intel/ice/ice_main.c | 12 +++++-------
> > 1 file changed, 5 insertions(+), 7 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
> > index a1f7c8edc22f..8940ee505811 100644
> > --- a/drivers/net/ethernet/intel/ice/ice_main.c
> > +++ b/drivers/net/ethernet/intel/ice/ice_main.c
> > @@ -2922,6 +2922,11 @@ ice_xdp_setup_prog(struct ice_vsi *vsi, struct bpf_prog *prog,
> > "MTU is too large for linear frames and XDP prog does not support frags");
> > return -EOPNOTSUPP;
> > }
> > +
> > + /* hot swap progs and avoid toggling link */
> > + if (ice_is_xdp_ena_vsi(vsi) == !!prog) {
> > + ice_vsi_assign_bpf_prog(vsi, prog);
> > + return 0;
> > }
> >
> > /* need to stop netdev while setting up the program for Rx rings */
> > @@ -2956,13 +2961,6 @@ ice_xdp_setup_prog(struct ice_vsi *vsi, struct bpf_prog *prog,
> > xdp_ring_err = ice_realloc_zc_buf(vsi, false);
> > if (xdp_ring_err)
> > NL_SET_ERR_MSG_MOD(extack, "Freeing XDP Rx resources failed");
> > - } else {
> > - /* safe to call even when prog == vsi->xdp_prog as
> > - * dev_xdp_install in net/core/dev.c incremented prog's
> > - * refcount so corresponding bpf_prog_put won't cause
> > - * underflow
> > - */
> > - ice_vsi_assign_bpf_prog(vsi, prog);
> > }
> >
> > if (if_running)
>
> [0]
> https://github.com/alobakin/linux/commit/5645adb0943dabeadfb9f6d00202c78fb9594fbe
>
> Thanks,
> Olek
next prev parent reply other threads:[~2023-06-13 15:20 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-13 15:10 [PATCH iwl-next] ice: allow hot-swapping XDP programs Maciej Fijalkowski
2023-06-13 15:15 ` [Intel-wired-lan] " Alexander Lobakin
2023-06-13 15:20 ` Maciej Fijalkowski [this message]
2023-06-13 17:59 ` Toke Høiland-Jørgensen
2023-06-14 12:40 ` Alexander Lobakin
2023-06-14 12:50 ` Maciej Fijalkowski
2023-06-14 13:25 ` Alexander Lobakin
2023-06-14 13:47 ` Toke Høiland-Jørgensen
2023-06-14 14:03 ` Alexander Lobakin
2023-06-14 13:42 ` Toke Høiland-Jørgensen
2023-06-13 16:43 ` kernel test robot
2023-06-13 17:58 ` kernel test robot
2023-06-13 22:19 ` kernel test robot
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=ZIiJOVMs4qK+PDsp@boxer \
--to=maciej.fijalkowski@intel.com \
--cc=aleksander.lobakin@intel.com \
--cc=anthony.l.nguyen@intel.com \
--cc=fred@cloudflare.com \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=magnus.karlsson@intel.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).