* [PATCH net 1/3] ice: synchronize_rcu() when terminating rings
2022-04-05 16:38 [PATCH net 0/3][pull request] Intel Wired LAN Driver Updates 2022-04-05 Tony Nguyen
@ 2022-04-05 16:38 ` Tony Nguyen
2022-04-05 16:38 ` [PATCH net 2/3] ice: xsk: fix VSI state check in ice_xsk_wakeup() Tony Nguyen
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Tony Nguyen @ 2022-04-05 16:38 UTC (permalink / raw)
To: davem, kuba, pabeni
Cc: Maciej Fijalkowski, netdev, anthony.l.nguyen, magnus.karlsson,
ast, daniel, hawk, john.fastabend, bpf, Shwetha Nagaraju
From: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
Unfortunately, the ice driver doesn't respect the RCU critical section that
XSK wakeup is surrounded with. To fix this, add synchronize_rcu() calls to
paths that destroy resources that might be in use.
This was addressed in other AF_XDP ZC enabled drivers, for reference see
for example commit b3873a5be757 ("net/i40e: Fix concurrency issues
between config flow and XSK")
Fixes: efc2214b6047 ("ice: Add support for XDP")
Fixes: 2d4238f55697 ("ice: Add support for AF_XDP")
Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
Tested-by: Shwetha Nagaraju <shwetha.nagaraju@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
---
drivers/net/ethernet/intel/ice/ice.h | 2 +-
drivers/net/ethernet/intel/ice/ice_main.c | 4 +++-
drivers/net/ethernet/intel/ice/ice_xsk.c | 4 +++-
3 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/intel/ice/ice.h b/drivers/net/ethernet/intel/ice/ice.h
index 26eaee0b6503..8ed3c9ab7ff7 100644
--- a/drivers/net/ethernet/intel/ice/ice.h
+++ b/drivers/net/ethernet/intel/ice/ice.h
@@ -671,7 +671,7 @@ static inline struct ice_pf *ice_netdev_to_pf(struct net_device *netdev)
static inline bool ice_is_xdp_ena_vsi(struct ice_vsi *vsi)
{
- return !!vsi->xdp_prog;
+ return !!READ_ONCE(vsi->xdp_prog);
}
static inline void ice_set_ring_xdp(struct ice_tx_ring *ring)
diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
index 1d2ca39add95..d2039a9306b8 100644
--- a/drivers/net/ethernet/intel/ice/ice_main.c
+++ b/drivers/net/ethernet/intel/ice/ice_main.c
@@ -2758,8 +2758,10 @@ int ice_destroy_xdp_rings(struct ice_vsi *vsi)
ice_for_each_xdp_txq(vsi, i)
if (vsi->xdp_rings[i]) {
- if (vsi->xdp_rings[i]->desc)
+ if (vsi->xdp_rings[i]->desc) {
+ synchronize_rcu();
ice_free_tx_ring(vsi->xdp_rings[i]);
+ }
kfree_rcu(vsi->xdp_rings[i], rcu);
vsi->xdp_rings[i] = NULL;
}
diff --git a/drivers/net/ethernet/intel/ice/ice_xsk.c b/drivers/net/ethernet/intel/ice/ice_xsk.c
index dfbcaf08520e..33b28a72ffcb 100644
--- a/drivers/net/ethernet/intel/ice/ice_xsk.c
+++ b/drivers/net/ethernet/intel/ice/ice_xsk.c
@@ -41,8 +41,10 @@ static void ice_qp_reset_stats(struct ice_vsi *vsi, u16 q_idx)
static void ice_qp_clean_rings(struct ice_vsi *vsi, u16 q_idx)
{
ice_clean_tx_ring(vsi->tx_rings[q_idx]);
- if (ice_is_xdp_ena_vsi(vsi))
+ if (ice_is_xdp_ena_vsi(vsi)) {
+ synchronize_rcu();
ice_clean_tx_ring(vsi->xdp_rings[q_idx]);
+ }
ice_clean_rx_ring(vsi->rx_rings[q_idx]);
}
--
2.31.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH net 2/3] ice: xsk: fix VSI state check in ice_xsk_wakeup()
2022-04-05 16:38 [PATCH net 0/3][pull request] Intel Wired LAN Driver Updates 2022-04-05 Tony Nguyen
2022-04-05 16:38 ` [PATCH net 1/3] ice: synchronize_rcu() when terminating rings Tony Nguyen
@ 2022-04-05 16:38 ` Tony Nguyen
2022-04-05 16:38 ` [PATCH net 3/3] ice: clear cmd_type_offset_bsz for TX rings Tony Nguyen
2022-04-06 14:20 ` [PATCH net 0/3][pull request] Intel Wired LAN Driver Updates 2022-04-05 patchwork-bot+netdevbpf
3 siblings, 0 replies; 5+ messages in thread
From: Tony Nguyen @ 2022-04-05 16:38 UTC (permalink / raw)
To: davem, kuba, pabeni
Cc: Maciej Fijalkowski, netdev, anthony.l.nguyen, magnus.karlsson,
ast, daniel, hawk, john.fastabend, bpf, Shwetha Nagaraju
From: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
ICE_DOWN is dedicated for pf->state. Check for ICE_VSI_DOWN being set on
vsi->state in ice_xsk_wakeup().
Fixes: 2d4238f55697 ("ice: Add support for AF_XDP")
Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
Tested-by: Shwetha Nagaraju <shwetha.nagaraju@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
---
drivers/net/ethernet/intel/ice/ice_xsk.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/intel/ice/ice_xsk.c b/drivers/net/ethernet/intel/ice/ice_xsk.c
index 33b28a72ffcb..866ee4df9671 100644
--- a/drivers/net/ethernet/intel/ice/ice_xsk.c
+++ b/drivers/net/ethernet/intel/ice/ice_xsk.c
@@ -920,7 +920,7 @@ ice_xsk_wakeup(struct net_device *netdev, u32 queue_id,
struct ice_vsi *vsi = np->vsi;
struct ice_tx_ring *ring;
- if (test_bit(ICE_DOWN, vsi->state))
+ if (test_bit(ICE_VSI_DOWN, vsi->state))
return -ENETDOWN;
if (!ice_is_xdp_ena_vsi(vsi))
--
2.31.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH net 3/3] ice: clear cmd_type_offset_bsz for TX rings
2022-04-05 16:38 [PATCH net 0/3][pull request] Intel Wired LAN Driver Updates 2022-04-05 Tony Nguyen
2022-04-05 16:38 ` [PATCH net 1/3] ice: synchronize_rcu() when terminating rings Tony Nguyen
2022-04-05 16:38 ` [PATCH net 2/3] ice: xsk: fix VSI state check in ice_xsk_wakeup() Tony Nguyen
@ 2022-04-05 16:38 ` Tony Nguyen
2022-04-06 14:20 ` [PATCH net 0/3][pull request] Intel Wired LAN Driver Updates 2022-04-05 patchwork-bot+netdevbpf
3 siblings, 0 replies; 5+ messages in thread
From: Tony Nguyen @ 2022-04-05 16:38 UTC (permalink / raw)
To: davem, kuba, pabeni
Cc: Maciej Fijalkowski, netdev, anthony.l.nguyen, magnus.karlsson,
ast, daniel, hawk, john.fastabend, bpf, Shwetha Nagaraju
From: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
Currently when XDP rings are created, each descriptor gets its DD bit
set, which turns out to be the wrong approach as it can lead to a
situation where more descriptors get cleaned than it was supposed to,
e.g. when AF_XDP busy poll is run with a large batch size. In this
situation, the driver would request for more buffers than it is able to
handle.
Fix this by not setting the DD bits in ice_xdp_alloc_setup_rings(). They
should be initialized to zero instead.
Fixes: 9610bd988df9 ("ice: optimize XDP_TX workloads")
Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
Tested-by: Shwetha Nagaraju <shwetha.nagaraju@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
---
drivers/net/ethernet/intel/ice/ice_main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
index d2039a9306b8..d768925785ca 100644
--- a/drivers/net/ethernet/intel/ice/ice_main.c
+++ b/drivers/net/ethernet/intel/ice/ice_main.c
@@ -2562,7 +2562,7 @@ static int ice_xdp_alloc_setup_rings(struct ice_vsi *vsi)
spin_lock_init(&xdp_ring->tx_lock);
for (j = 0; j < xdp_ring->count; j++) {
tx_desc = ICE_TX_DESC(xdp_ring, j);
- tx_desc->cmd_type_offset_bsz = cpu_to_le64(ICE_TX_DESC_DTYPE_DESC_DONE);
+ tx_desc->cmd_type_offset_bsz = 0;
}
}
--
2.31.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH net 0/3][pull request] Intel Wired LAN Driver Updates 2022-04-05
2022-04-05 16:38 [PATCH net 0/3][pull request] Intel Wired LAN Driver Updates 2022-04-05 Tony Nguyen
` (2 preceding siblings ...)
2022-04-05 16:38 ` [PATCH net 3/3] ice: clear cmd_type_offset_bsz for TX rings Tony Nguyen
@ 2022-04-06 14:20 ` patchwork-bot+netdevbpf
3 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-04-06 14:20 UTC (permalink / raw)
To: Tony Nguyen
Cc: davem, kuba, pabeni, netdev, maciej.fijalkowski, magnus.karlsson,
ast, daniel, hawk, john.fastabend, bpf
Hello:
This series was applied to netdev/net.git (master)
by Tony Nguyen <anthony.l.nguyen@intel.com>:
On Tue, 5 Apr 2022 09:38:00 -0700 you wrote:
> Maciej Fijalkowski says:
>
> We were solving issues around AF_XDP busy poll's not-so-usual scenarios,
> such as very big busy poll budgets applied to very small HW rings. This
> set carries the things that were found during that work that apply to
> net tree.
>
> [...]
Here is the summary with links:
- [net,1/3] ice: synchronize_rcu() when terminating rings
https://git.kernel.org/netdev/net/c/f9124c68f05f
- [net,2/3] ice: xsk: fix VSI state check in ice_xsk_wakeup()
https://git.kernel.org/netdev/net/c/72b915a2b444
- [net,3/3] ice: clear cmd_type_offset_bsz for TX rings
https://git.kernel.org/netdev/net/c/e19778e6c911
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 5+ messages in thread