From: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
To: Jakub Kicinski <kuba@kernel.org>
Cc: Tony Nguyen <anthony.l.nguyen@intel.com>, <davem@davemloft.net>,
<pabeni@redhat.com>, <edumazet@google.com>,
<netdev@vger.kernel.org>, <magnus.karlsson@intel.com>,
<aleksander.lobakin@intel.com>, <ast@kernel.org>,
<daniel@iogearbox.net>, <hawk@kernel.org>,
<john.fastabend@gmail.com>, <bpf@vger.kernel.org>,
Shannon Nelson <shannon.nelson@amd.com>,
Chandan Kumar Rout <chandanx.rout@intel.com>
Subject: Re: [PATCH net 6/8] ice: improve updating ice_{t, r}x_ring::xsk_pool
Date: Thu, 25 Jul 2024 20:31:31 +0200 [thread overview]
Message-ID: <ZqKaAz8rNOx/Sz5E@boxer> (raw)
In-Reply-To: <20240725063858.65803c85@kernel.org>
On Thu, Jul 25, 2024 at 06:38:58AM -0700, Jakub Kicinski wrote:
> On Wed, 24 Jul 2024 17:49:12 +0200 Maciej Fijalkowski wrote:
> > > So if we are already in the af_xdp handler, and update patch sets pool
> > > to NULL - the af_xdp handler will be fine with the pool becoming NULL?
> > > I guess it may be fine, it's just quite odd to call the function called
> > > _ONCE() multiple times..
> >
> > Update path before NULLing pool will go through rcu grace period, stop
> > napis, disable irqs, etc. Running napi won't be exposed to nulled pool in
> > such case.
>
> Could you make it clearer what condition the patch is fixing, then?
> What can go wrong without this patch?
Sorry for confusion, but without this patch scenario you brought up
initially *could* happen, under some wild circumstances. When I was
responding yesterday my head was around the code with this particular
patch in place, that's why I said such pool state transistion was not
possible.
Updater does this (prior to this patch):
(...)
ring->xsk_pool = ice_get_xp_from_qid(vsi, qid); // set to NULL
(...)
ice_qvec_toggle_napi(vsi, q_vector, true);
ice_qvec_ena_irq(vsi, q_vector);
In theory compiler is allowed to transform the code in a way that xsk_pool
assignment will happen *after* triggering napi. So in ice_napi_poll():
if (tx_ring->xsk_pool)
wd = ice_xmit_zc(tx_ring); // call ZC routine
else if (ice_ring_is_xdp(tx_ring))
wd = true;
else
wd = ice_clean_tx_irq(tx_ring, budget);
You will initiate ZC Tx processing because xsk_pool ptr was still valid
and crash in the middle of its job once it's finally NULLed. To prevent
that:
updater:
(...)
WRITE_ONCE(ring->xsk_pool, ice_get_xp_from_qid(vsi, qid));
(...)
ice_qvec_toggle_napi(vsi, q_vector, true);
ice_qvec_ena_irq(vsi, q_vector);
/* make sure NAPI sees updated ice_{t,x}_ring::xsk_pool */
synchronize_net();
reader:
if (READ_ONCE(tx_ring->xsk_pool))
wd = ice_xmit_zc(tx_ring);
else if (ice_ring_is_xdp(tx_ring))
wd = true;
else
wd = ice_clean_tx_irq(tx_ring, budget);
Does that make any sense now?
next prev parent reply other threads:[~2024-07-25 18:31 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-08 22:14 [PATCH net 0/8][pull request] ice: fix AF_XDP ZC timeout and concurrency issues Tony Nguyen
2024-07-08 22:14 ` [PATCH net 1/8] ice: respect netif readiness in AF_XDP ZC related ndo's Tony Nguyen
2024-07-08 22:14 ` [PATCH net 2/8] ice: don't busy wait for Rx queue disable in ice_qp_dis() Tony Nguyen
2024-07-08 22:14 ` [PATCH net 3/8] ice: replace synchronize_rcu with synchronize_net Tony Nguyen
2024-07-08 22:14 ` [PATCH net 4/8] ice: modify error handling when setting XSK pool in ndo_bpf Tony Nguyen
2024-07-08 22:14 ` [PATCH net 5/8] ice: toggle netif_carrier when setting up XSK pool Tony Nguyen
2024-07-08 22:14 ` [PATCH net 6/8] ice: improve updating ice_{t, r}x_ring::xsk_pool Tony Nguyen
2024-07-10 1:45 ` Jakub Kicinski
2024-07-23 23:46 ` Maciej Fijalkowski
2024-07-24 14:57 ` Jakub Kicinski
2024-07-24 15:49 ` Maciej Fijalkowski
2024-07-25 13:38 ` Jakub Kicinski
2024-07-25 18:31 ` Maciej Fijalkowski [this message]
2024-07-25 23:07 ` Jakub Kicinski
2024-07-26 13:43 ` Maciej Fijalkowski
2024-07-26 14:37 ` Jakub Kicinski
2024-07-08 22:14 ` [PATCH net 7/8] ice: add missing WRITE_ONCE when clearing ice_rx_ring::xdp_prog Tony Nguyen
2024-07-08 22:14 ` [PATCH net 8/8] ice: xsk: fix txq interrupt mapping Tony Nguyen
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=ZqKaAz8rNOx/Sz5E@boxer \
--to=maciej.fijalkowski@intel.com \
--cc=aleksander.lobakin@intel.com \
--cc=anthony.l.nguyen@intel.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=chandanx.rout@intel.com \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hawk@kernel.org \
--cc=john.fastabend@gmail.com \
--cc=kuba@kernel.org \
--cc=magnus.karlsson@intel.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=shannon.nelson@amd.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 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.