* [PATCH net] ice: xsk: Fix cleaning of XDP_TX frames
@ 2023-02-09 16:01 Larysa Zaremba
2023-02-09 17:07 ` Alexander H Duyck
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Larysa Zaremba @ 2023-02-09 16:01 UTC (permalink / raw)
To: David S. Miller, Jakub Kicinski, Eric Dumazet, Paolo Abeni
Cc: Larysa Zaremba, intel-wired-lan, netdev, bpf, Alexander Lobakin,
Tony Nguyen, Maciej Fijalkowski
Incrementation of xsk_frames inside the for-loop produces
infinite loop, if we have both normal AF_XDP-TX and XDP_TXed
buffers to complete.
Split xsk_frames into 2 variables (xsk_frames and completed_frames)
to eliminate this bug.
Fixes: 29322791bc8b ("ice: xsk: change batched Tx descriptor cleaning")
Acked-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
Signed-off-by: Larysa Zaremba <larysa.zaremba@intel.com>
---
To Tony: this is urgent and should go directly via net. It's tested and acked.
---
drivers/net/ethernet/intel/ice/ice_xsk.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/intel/ice/ice_xsk.c b/drivers/net/ethernet/intel/ice/ice_xsk.c
index 7105de6fb344..374b7f10b549 100644
--- a/drivers/net/ethernet/intel/ice/ice_xsk.c
+++ b/drivers/net/ethernet/intel/ice/ice_xsk.c
@@ -800,6 +800,7 @@ static void ice_clean_xdp_irq_zc(struct ice_tx_ring *xdp_ring)
struct ice_tx_desc *tx_desc;
u16 cnt = xdp_ring->count;
struct ice_tx_buf *tx_buf;
+ u16 completed_frames = 0;
u16 xsk_frames = 0;
u16 last_rs;
int i;
@@ -809,19 +810,21 @@ static void ice_clean_xdp_irq_zc(struct ice_tx_ring *xdp_ring)
if ((tx_desc->cmd_type_offset_bsz &
cpu_to_le64(ICE_TX_DESC_DTYPE_DESC_DONE))) {
if (last_rs >= ntc)
- xsk_frames = last_rs - ntc + 1;
+ completed_frames = last_rs - ntc + 1;
else
- xsk_frames = last_rs + cnt - ntc + 1;
+ completed_frames = last_rs + cnt - ntc + 1;
}
- if (!xsk_frames)
+ if (!completed_frames)
return;
- if (likely(!xdp_ring->xdp_tx_active))
+ if (likely(!xdp_ring->xdp_tx_active)) {
+ xsk_frames = completed_frames;
goto skip;
+ }
ntc = xdp_ring->next_to_clean;
- for (i = 0; i < xsk_frames; i++) {
+ for (i = 0; i < completed_frames; i++) {
tx_buf = &xdp_ring->tx_buf[ntc];
if (tx_buf->raw_buf) {
@@ -837,7 +840,7 @@ static void ice_clean_xdp_irq_zc(struct ice_tx_ring *xdp_ring)
}
skip:
tx_desc->cmd_type_offset_bsz = 0;
- xdp_ring->next_to_clean += xsk_frames;
+ xdp_ring->next_to_clean += completed_frames;
if (xdp_ring->next_to_clean >= cnt)
xdp_ring->next_to_clean -= cnt;
if (xsk_frames)
--
2.35.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH net] ice: xsk: Fix cleaning of XDP_TX frames
2023-02-09 16:01 [PATCH net] ice: xsk: Fix cleaning of XDP_TX frames Larysa Zaremba
@ 2023-02-09 17:07 ` Alexander H Duyck
2023-02-09 17:20 ` Tony Nguyen
2023-02-11 4:00 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 5+ messages in thread
From: Alexander H Duyck @ 2023-02-09 17:07 UTC (permalink / raw)
To: Larysa Zaremba, David S. Miller, Jakub Kicinski, Eric Dumazet,
Paolo Abeni
Cc: intel-wired-lan, netdev, bpf, Alexander Lobakin, Tony Nguyen,
Maciej Fijalkowski
On Thu, 2023-02-09 at 17:01 +0100, Larysa Zaremba wrote:
> Incrementation of xsk_frames inside the for-loop produces
> infinite loop, if we have both normal AF_XDP-TX and XDP_TXed
> buffers to complete.
>
> Split xsk_frames into 2 variables (xsk_frames and completed_frames)
> to eliminate this bug.
>
> Fixes: 29322791bc8b ("ice: xsk: change batched Tx descriptor cleaning")
> Acked-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
> Signed-off-by: Larysa Zaremba <larysa.zaremba@intel.com>
> ---
> To Tony: this is urgent and should go directly via net. It's tested and acked.
> ---
> drivers/net/ethernet/intel/ice/ice_xsk.c | 15 +++++++++------
> 1 file changed, 9 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/net/ethernet/intel/ice/ice_xsk.c b/drivers/net/ethernet/intel/ice/ice_xsk.c
> index 7105de6fb344..374b7f10b549 100644
> --- a/drivers/net/ethernet/intel/ice/ice_xsk.c
> +++ b/drivers/net/ethernet/intel/ice/ice_xsk.c
> @@ -800,6 +800,7 @@ static void ice_clean_xdp_irq_zc(struct ice_tx_ring *xdp_ring)
> struct ice_tx_desc *tx_desc;
> u16 cnt = xdp_ring->count;
> struct ice_tx_buf *tx_buf;
> + u16 completed_frames = 0;
> u16 xsk_frames = 0;
> u16 last_rs;
> int i;
> @@ -809,19 +810,21 @@ static void ice_clean_xdp_irq_zc(struct ice_tx_ring *xdp_ring)
> if ((tx_desc->cmd_type_offset_bsz &
> cpu_to_le64(ICE_TX_DESC_DTYPE_DESC_DONE))) {
> if (last_rs >= ntc)
> - xsk_frames = last_rs - ntc + 1;
> + completed_frames = last_rs - ntc + 1;
> else
> - xsk_frames = last_rs + cnt - ntc + 1;
> + completed_frames = last_rs + cnt - ntc + 1;
> }
>
> - if (!xsk_frames)
> + if (!completed_frames)
> return;
>
> - if (likely(!xdp_ring->xdp_tx_active))
> + if (likely(!xdp_ring->xdp_tx_active)) {
> + xsk_frames = completed_frames;
> goto skip;
> + }
>
> ntc = xdp_ring->next_to_clean;
> - for (i = 0; i < xsk_frames; i++) {
> + for (i = 0; i < completed_frames; i++) {
> tx_buf = &xdp_ring->tx_buf[ntc];
>
> if (tx_buf->raw_buf) {
> @@ -837,7 +840,7 @@ static void ice_clean_xdp_irq_zc(struct ice_tx_ring *xdp_ring)
> }
> skip:
> tx_desc->cmd_type_offset_bsz = 0;
> - xdp_ring->next_to_clean += xsk_frames;
> + xdp_ring->next_to_clean += completed_frames;
> if (xdp_ring->next_to_clean >= cnt)
> xdp_ring->next_to_clean -= cnt;
> if (xsk_frames)
Looks good to me.
Reviewed-by: Alexander Duyck <alexanderduyck@fb.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net] ice: xsk: Fix cleaning of XDP_TX frames
2023-02-09 16:01 [PATCH net] ice: xsk: Fix cleaning of XDP_TX frames Larysa Zaremba
2023-02-09 17:07 ` Alexander H Duyck
@ 2023-02-09 17:20 ` Tony Nguyen
2023-02-09 18:00 ` Jakub Kicinski
2023-02-11 4:00 ` patchwork-bot+netdevbpf
2 siblings, 1 reply; 5+ messages in thread
From: Tony Nguyen @ 2023-02-09 17:20 UTC (permalink / raw)
To: Zaremba, Larysa, David S. Miller, Jakub Kicinski, Eric Dumazet,
Paolo Abeni
Cc: intel-wired-lan@osuosl.org, netdev@vger.kernel.org,
bpf@vger.kernel.org, Lobakin, Alexandr, Fijalkowski, Maciej
On 2/9/2023 8:01 AM, Zaremba, Larysa wrote:
> Incrementation of xsk_frames inside the for-loop produces
> infinite loop, if we have both normal AF_XDP-TX and XDP_TXed
> buffers to complete.
>
> Split xsk_frames into 2 variables (xsk_frames and completed_frames)
> to eliminate this bug.
>
> Fixes: 29322791bc8b ("ice: xsk: change batched Tx descriptor cleaning")
> Acked-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
> Signed-off-by: Larysa Zaremba <larysa.zaremba@intel.com>
> ---
> To Tony: this is urgent and should go directly via net. It's tested and acked.
netdev maintainers,
Since it's been tested and reviewed, did you want to take this directly?
Acked-by: Tony Nguyen <anthony.l.nguyen@intel.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net] ice: xsk: Fix cleaning of XDP_TX frames
2023-02-09 17:20 ` Tony Nguyen
@ 2023-02-09 18:00 ` Jakub Kicinski
0 siblings, 0 replies; 5+ messages in thread
From: Jakub Kicinski @ 2023-02-09 18:00 UTC (permalink / raw)
To: Tony Nguyen
Cc: Zaremba, Larysa, David S. Miller, Eric Dumazet, Paolo Abeni,
intel-wired-lan@osuosl.org, netdev@vger.kernel.org,
bpf@vger.kernel.org, Lobakin, Alexandr, Fijalkowski, Maciej
On Thu, 9 Feb 2023 09:20:27 -0800 Tony Nguyen wrote:
> Since it's been tested and reviewed, did you want to take this directly?
>
> Acked-by: Tony Nguyen <anthony.l.nguyen@intel.com>
Sure thing! Already missed today's PR tho.. :(
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net] ice: xsk: Fix cleaning of XDP_TX frames
2023-02-09 16:01 [PATCH net] ice: xsk: Fix cleaning of XDP_TX frames Larysa Zaremba
2023-02-09 17:07 ` Alexander H Duyck
2023-02-09 17:20 ` Tony Nguyen
@ 2023-02-11 4:00 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-02-11 4:00 UTC (permalink / raw)
To: Larysa Zaremba
Cc: davem, kuba, edumazet, pabeni, intel-wired-lan, netdev, bpf,
alexandr.lobakin, anthony.l.nguyen, maciej.fijalkowski
Hello:
This patch was applied to netdev/net.git (master)
by Jakub Kicinski <kuba@kernel.org>:
On Thu, 9 Feb 2023 17:01:30 +0100 you wrote:
> Incrementation of xsk_frames inside the for-loop produces
> infinite loop, if we have both normal AF_XDP-TX and XDP_TXed
> buffers to complete.
>
> Split xsk_frames into 2 variables (xsk_frames and completed_frames)
> to eliminate this bug.
>
> [...]
Here is the summary with links:
- [net] ice: xsk: Fix cleaning of XDP_TX frames
https://git.kernel.org/netdev/net/c/1f090494170e
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
end of thread, other threads:[~2023-02-11 4:00 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-09 16:01 [PATCH net] ice: xsk: Fix cleaning of XDP_TX frames Larysa Zaremba
2023-02-09 17:07 ` Alexander H Duyck
2023-02-09 17:20 ` Tony Nguyen
2023-02-09 18:00 ` Jakub Kicinski
2023-02-11 4:00 ` patchwork-bot+netdevbpf
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).