netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net 1/2] i40e: need_wakeup flag might not be set for Tx
@ 2019-11-08 19:58 Magnus Karlsson
  2019-11-08 19:58 ` [PATCH net 2/2] ixgbe: " Magnus Karlsson
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Magnus Karlsson @ 2019-11-08 19:58 UTC (permalink / raw)
  To: magnus.karlsson, bjorn.topel, intel-wired-lan
  Cc: maciej.fijalkowski, maciejromanfijalkowski, netdev

The need_wakeup flag for Tx might not be set for AF_XDP sockets that
are only used to send packets. This happens if there is at least one
outstanding packet that has not been completed by the hardware and we
get that corresponding completion (which will not generate an
interrupt since interrupts are disabled in the napi poll loop) between
the time we stopped processing the Tx completions and interrupts are
enabled again. In this case, the need_wakeup flag will have been
cleared at the end of the Tx completion processing as we believe we
will get an interrupt from the outstanding completion at a later point
in time. But if this completion interrupt occurs before interrupts
are enable, we lose it and should at that point really have set the
need_wakeup flag since there are no more outstanding completions that
can generate an interrupt to continue the processing. When this
happens, user space will see a Tx queue need_wakeup of 0 and skip
issuing a syscall, which means will never get into the Tx processing
again and we have a deadlock.

This patch introduces a quick fix for this issue by just setting the
need_wakeup flag for Tx to 1 all the time. I am working on a proper
fix for this that will toggle the flag appropriately, but it is more
challenging than I anticipated and I am afraid that this patch will
not be completed before the merge window closes, therefore this easier
fix for now. This fix has a negative performance impact in the range
of 0% to 4%. Towards the higher end of the scale if you have driver
and application on the same core and issue a lot of packets, and
towards no negative impact if you use two cores, lower transmission
speeds and/or a workload that also receives packets.

Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
---
 drivers/net/ethernet/intel/i40e/i40e_xsk.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_xsk.c b/drivers/net/ethernet/intel/i40e/i40e_xsk.c
index a05dfec..d07e1a8 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_xsk.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_xsk.c
@@ -689,8 +689,6 @@ static bool i40e_xmit_zc(struct i40e_ring *xdp_ring, unsigned int budget)
 		i40e_xdp_ring_update_tail(xdp_ring);
 
 		xsk_umem_consume_tx_done(xdp_ring->xsk_umem);
-		if (xsk_umem_uses_need_wakeup(xdp_ring->xsk_umem))
-			xsk_clear_tx_need_wakeup(xdp_ring->xsk_umem);
 	}
 
 	return !!budget && work_done;
@@ -769,12 +767,8 @@ bool i40e_clean_xdp_tx_irq(struct i40e_vsi *vsi,
 	i40e_update_tx_stats(tx_ring, completed_frames, total_bytes);
 
 out_xmit:
-	if (xsk_umem_uses_need_wakeup(tx_ring->xsk_umem)) {
-		if (tx_ring->next_to_clean == tx_ring->next_to_use)
-			xsk_set_tx_need_wakeup(tx_ring->xsk_umem);
-		else
-			xsk_clear_tx_need_wakeup(tx_ring->xsk_umem);
-	}
+	if (xsk_umem_uses_need_wakeup(tx_ring->xsk_umem))
+		xsk_set_tx_need_wakeup(tx_ring->xsk_umem);
 
 	xmit_done = i40e_xmit_zc(tx_ring, budget);
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH net 2/2] ixgbe: need_wakeup flag might not be set for Tx
  2019-11-08 19:58 [PATCH net 1/2] i40e: need_wakeup flag might not be set for Tx Magnus Karlsson
@ 2019-11-08 19:58 ` Magnus Karlsson
  2019-11-09  0:02   ` [Intel-wired-lan] " Bowers, AndrewX
  2019-11-08 22:11 ` [PATCH net 1/2] i40e: " David Miller
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Magnus Karlsson @ 2019-11-08 19:58 UTC (permalink / raw)
  To: magnus.karlsson, bjorn.topel, intel-wired-lan
  Cc: maciej.fijalkowski, maciejromanfijalkowski, netdev

The need_wakeup flag for Tx might not be set for AF_XDP sockets that
are only used to send packets. This happens if there is at least one
outstanding packet that has not been completed by the hardware and we
get that corresponding completion (which will not generate an
interrupt since interrupts are disabled in the napi poll loop) between
the time we stopped processing the Tx completions and interrupts are
enabled again. In this case, the need_wakeup flag will have been
cleared at the end of the Tx completion processing as we believe we
will get an interrupt from the outstanding completion at a later point
in time. But if this completion interrupt occurs before interrupts
are enable, we lose it and should at that point really have set the
need_wakeup flag since there are no more outstanding completions that
can generate an interrupt to continue the processing. When this
happens, user space will see a Tx queue need_wakeup of 0 and skip
issuing a syscall, which means will never get into the Tx processing
again and we have a deadlock.

This patch introduces a quick fix for this issue by just setting the
need_wakeup flag for Tx to 1 all the time. I am working on a proper
fix for this that will toggle the flag appropriately, but it is more
challenging than I anticipated and I am afraid that this patch will
not be completed before the merge window closes, therefore this easier
fix for now. This fix has a negative performance impact in the range
of 0% to 4%. Towards the higher end of the scale if you have driver
and application on the same core and issue a lot of packets, and
towards no negative impact if you use two cores, lower transmission
speeds and/or a workload that also receives packets.

Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
---
 drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c
index 100ac89..d6feaac 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c
@@ -622,8 +622,6 @@ static bool ixgbe_xmit_zc(struct ixgbe_ring *xdp_ring, unsigned int budget)
 	if (tx_desc) {
 		ixgbe_xdp_ring_update_tail(xdp_ring);
 		xsk_umem_consume_tx_done(xdp_ring->xsk_umem);
-		if (xsk_umem_uses_need_wakeup(xdp_ring->xsk_umem))
-			xsk_clear_tx_need_wakeup(xdp_ring->xsk_umem);
 	}
 
 	return !!budget && work_done;
@@ -691,12 +689,8 @@ bool ixgbe_clean_xdp_tx_irq(struct ixgbe_q_vector *q_vector,
 	if (xsk_frames)
 		xsk_umem_complete_tx(umem, xsk_frames);
 
-	if (xsk_umem_uses_need_wakeup(tx_ring->xsk_umem)) {
-		if (tx_ring->next_to_clean == tx_ring->next_to_use)
-			xsk_set_tx_need_wakeup(tx_ring->xsk_umem);
-		else
-			xsk_clear_tx_need_wakeup(tx_ring->xsk_umem);
-	}
+	if (xsk_umem_uses_need_wakeup(tx_ring->xsk_umem))
+		xsk_set_tx_need_wakeup(tx_ring->xsk_umem);
 
 	return ixgbe_xmit_zc(tx_ring, q_vector->tx.work_limit);
 }
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH net 1/2] i40e: need_wakeup flag might not be set for Tx
  2019-11-08 19:58 [PATCH net 1/2] i40e: need_wakeup flag might not be set for Tx Magnus Karlsson
  2019-11-08 19:58 ` [PATCH net 2/2] ixgbe: " Magnus Karlsson
@ 2019-11-08 22:11 ` David Miller
  2019-11-08 22:46   ` Jeff Kirsher
  2019-11-09  0:01 ` [Intel-wired-lan] " Bowers, AndrewX
  2019-11-25 15:24 ` Maxim Mikityanskiy
  3 siblings, 1 reply; 8+ messages in thread
From: David Miller @ 2019-11-08 22:11 UTC (permalink / raw)
  To: magnus.karlsson
  Cc: bjorn.topel, intel-wired-lan, maciej.fijalkowski,
	maciejromanfijalkowski, netdev, jeffrey.t.kirsher


Jeff, please pick these up.

Thanks.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH net 1/2] i40e: need_wakeup flag might not be set for Tx
  2019-11-08 22:11 ` [PATCH net 1/2] i40e: " David Miller
@ 2019-11-08 22:46   ` Jeff Kirsher
  0 siblings, 0 replies; 8+ messages in thread
From: Jeff Kirsher @ 2019-11-08 22:46 UTC (permalink / raw)
  To: David Miller, magnus.karlsson
  Cc: bjorn.topel, intel-wired-lan, maciej.fijalkowski,
	maciejromanfijalkowski, netdev

[-- Attachment #1: Type: text/plain, Size: 255 bytes --]

On Fri, 2019-11-08 at 14:11 -0800, David Miller wrote:
> Jeff, please pick these up.
> 
> Thanks.

Yep already have them queued up.  Just waiting confirmation from
validation.  I will have a 6 patch series of fixes for you in the next day
or two.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: [Intel-wired-lan] [PATCH net 1/2] i40e: need_wakeup flag might not be set for Tx
  2019-11-08 19:58 [PATCH net 1/2] i40e: need_wakeup flag might not be set for Tx Magnus Karlsson
  2019-11-08 19:58 ` [PATCH net 2/2] ixgbe: " Magnus Karlsson
  2019-11-08 22:11 ` [PATCH net 1/2] i40e: " David Miller
@ 2019-11-09  0:01 ` Bowers, AndrewX
  2019-11-25 15:24 ` Maxim Mikityanskiy
  3 siblings, 0 replies; 8+ messages in thread
From: Bowers, AndrewX @ 2019-11-09  0:01 UTC (permalink / raw)
  To: intel-wired-lan; +Cc: netdev

> -----Original Message-----
> From: Intel-wired-lan [mailto:intel-wired-lan-bounces@osuosl.org] On
> Behalf Of Magnus Karlsson
> Sent: Friday, November 8, 2019 11:58 AM
> To: Karlsson, Magnus <magnus.karlsson@intel.com>; Topel, Bjorn
> <bjorn.topel@intel.com>; intel-wired-lan@lists.osuosl.org
> Cc: maciejromanfijalkowski@gmail.com; Fijalkowski, Maciej
> <maciej.fijalkowski@intel.com>; netdev@vger.kernel.org
> Subject: [Intel-wired-lan] [PATCH net 1/2] i40e: need_wakeup flag might not
> be set for Tx
> 
> The need_wakeup flag for Tx might not be set for AF_XDP sockets that are
> only used to send packets. This happens if there is at least one outstanding
> packet that has not been completed by the hardware and we get that
> corresponding completion (which will not generate an interrupt since
> interrupts are disabled in the napi poll loop) between the time we stopped
> processing the Tx completions and interrupts are enabled again. In this case,
> the need_wakeup flag will have been cleared at the end of the Tx
> completion processing as we believe we will get an interrupt from the
> outstanding completion at a later point in time. But if this completion
> interrupt occurs before interrupts are enable, we lose it and should at that
> point really have set the need_wakeup flag since there are no more
> outstanding completions that can generate an interrupt to continue the
> processing. When this happens, user space will see a Tx queue
> need_wakeup of 0 and skip issuing a syscall, which means will never get into
> the Tx processing again and we have a deadlock.
> 
> This patch introduces a quick fix for this issue by just setting the
> need_wakeup flag for Tx to 1 all the time. I am working on a proper fix for
> this that will toggle the flag appropriately, but it is more challenging than I
> anticipated and I am afraid that this patch will not be completed before the
> merge window closes, therefore this easier fix for now. This fix has a
> negative performance impact in the range of 0% to 4%. Towards the higher
> end of the scale if you have driver and application on the same core and issue
> a lot of packets, and towards no negative impact if you use two cores, lower
> transmission speeds and/or a workload that also receives packets.
> 
> Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
> ---
>  drivers/net/ethernet/intel/i40e/i40e_xsk.c | 10 ++--------
>  1 file changed, 2 insertions(+), 8 deletions(-)

Tested-by: Andrew Bowers <andrewx.bowers@intel.com>



^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: [Intel-wired-lan] [PATCH net 2/2] ixgbe: need_wakeup flag might not be set for Tx
  2019-11-08 19:58 ` [PATCH net 2/2] ixgbe: " Magnus Karlsson
@ 2019-11-09  0:02   ` Bowers, AndrewX
  0 siblings, 0 replies; 8+ messages in thread
From: Bowers, AndrewX @ 2019-11-09  0:02 UTC (permalink / raw)
  To: intel-wired-lan; +Cc: netdev

> -----Original Message-----
> From: Intel-wired-lan [mailto:intel-wired-lan-bounces@osuosl.org] On
> Behalf Of Magnus Karlsson
> Sent: Friday, November 8, 2019 11:58 AM
> To: Karlsson, Magnus <magnus.karlsson@intel.com>; Topel, Bjorn
> <bjorn.topel@intel.com>; intel-wired-lan@lists.osuosl.org
> Cc: maciejromanfijalkowski@gmail.com; Fijalkowski, Maciej
> <maciej.fijalkowski@intel.com>; netdev@vger.kernel.org
> Subject: [Intel-wired-lan] [PATCH net 2/2] ixgbe: need_wakeup flag might
> not be set for Tx
> 
> The need_wakeup flag for Tx might not be set for AF_XDP sockets that are
> only used to send packets. This happens if there is at least one outstanding
> packet that has not been completed by the hardware and we get that
> corresponding completion (which will not generate an interrupt since
> interrupts are disabled in the napi poll loop) between the time we stopped
> processing the Tx completions and interrupts are enabled again. In this case,
> the need_wakeup flag will have been cleared at the end of the Tx
> completion processing as we believe we will get an interrupt from the
> outstanding completion at a later point in time. But if this completion
> interrupt occurs before interrupts are enable, we lose it and should at that
> point really have set the need_wakeup flag since there are no more
> outstanding completions that can generate an interrupt to continue the
> processing. When this happens, user space will see a Tx queue
> need_wakeup of 0 and skip issuing a syscall, which means will never get into
> the Tx processing again and we have a deadlock.
> 
> This patch introduces a quick fix for this issue by just setting the
> need_wakeup flag for Tx to 1 all the time. I am working on a proper fix for
> this that will toggle the flag appropriately, but it is more challenging than I
> anticipated and I am afraid that this patch will not be completed before the
> merge window closes, therefore this easier fix for now. This fix has a
> negative performance impact in the range of 0% to 4%. Towards the higher
> end of the scale if you have driver and application on the same core and issue
> a lot of packets, and towards no negative impact if you use two cores, lower
> transmission speeds and/or a workload that also receives packets.
> 
> Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
> ---
>  drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c | 10 ++--------
>  1 file changed, 2 insertions(+), 8 deletions(-)

Tested-by: Andrew Bowers <andrewx.bowers@intel.com>



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH net 1/2] i40e: need_wakeup flag might not be set for Tx
  2019-11-08 19:58 [PATCH net 1/2] i40e: need_wakeup flag might not be set for Tx Magnus Karlsson
                   ` (2 preceding siblings ...)
  2019-11-09  0:01 ` [Intel-wired-lan] " Bowers, AndrewX
@ 2019-11-25 15:24 ` Maxim Mikityanskiy
  2019-11-25 16:44   ` [Intel-wired-lan] " Magnus Karlsson
  3 siblings, 1 reply; 8+ messages in thread
From: Maxim Mikityanskiy @ 2019-11-25 15:24 UTC (permalink / raw)
  To: Magnus Karlsson, bjorn.topel, intel-wired-lan
  Cc: maciej.fijalkowski, maciejromanfijalkowski, netdev, Tariq Toukan,
	Saeed Mahameed

Hi Magnus,

On 2019-11-08 21:58, Magnus Karlsson wrote:
> This happens if there is at least one
> outstanding packet that has not been completed by the hardware and we
> get that corresponding completion (which will not generate an
> interrupt since interrupts are disabled in the napi poll loop) between
> the time we stopped processing the Tx completions and interrupts are
> enabled again.

> But if this completion interrupt occurs before interrupts
> are enable, we lose it
Why can't it happen for regular traffic? From your description it looks 
to me as if you can miss a completion for non-AF_XDP traffic, too. Is 
there any detail that makes this issue AF_XDP-specific?

Thanks,
Max

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Intel-wired-lan] [PATCH net 1/2] i40e: need_wakeup flag might not be set for Tx
  2019-11-25 15:24 ` Maxim Mikityanskiy
@ 2019-11-25 16:44   ` Magnus Karlsson
  0 siblings, 0 replies; 8+ messages in thread
From: Magnus Karlsson @ 2019-11-25 16:44 UTC (permalink / raw)
  To: Maxim Mikityanskiy
  Cc: Magnus Karlsson, bjorn.topel, intel-wired-lan,
	maciejromanfijalkowski, Tariq Toukan, maciej.fijalkowski,
	Saeed Mahameed, netdev

On Mon, Nov 25, 2019 at 4:40 PM Maxim Mikityanskiy <maximmi@mellanox.com> wrote:
>
> Hi Magnus,
>
> On 2019-11-08 21:58, Magnus Karlsson wrote:
> > This happens if there is at least one
> > outstanding packet that has not been completed by the hardware and we
> > get that corresponding completion (which will not generate an
> > interrupt since interrupts are disabled in the napi poll loop) between
> > the time we stopped processing the Tx completions and interrupts are
> > enabled again.
>
> > But if this completion interrupt occurs before interrupts
> > are enable, we lose it
> Why can't it happen for regular traffic? From your description it looks
> to me as if you can miss a completion for non-AF_XDP traffic, too. Is
> there any detail that makes this issue AF_XDP-specific?

It can happen for regular traffic too, but it does not matter in that
case since the application is not dependent on getting a notification
on completion. The only thing that will happen is that there is some
memory and HW descriptors being used for longer than necessary. It
will get completed and reused next time there is some Tx action.

In the cases where it matters, the skb path code has feature that arms
a later interrupt. I need to introduce something similar for the
AF_XDP ZC path.

/Magnus

> Thanks,
> Max
> _______________________________________________
> Intel-wired-lan mailing list
> Intel-wired-lan@osuosl.org
> https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-11-25 16:44 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-08 19:58 [PATCH net 1/2] i40e: need_wakeup flag might not be set for Tx Magnus Karlsson
2019-11-08 19:58 ` [PATCH net 2/2] ixgbe: " Magnus Karlsson
2019-11-09  0:02   ` [Intel-wired-lan] " Bowers, AndrewX
2019-11-08 22:11 ` [PATCH net 1/2] i40e: " David Miller
2019-11-08 22:46   ` Jeff Kirsher
2019-11-09  0:01 ` [Intel-wired-lan] " Bowers, AndrewX
2019-11-25 15:24 ` Maxim Mikityanskiy
2019-11-25 16:44   ` [Intel-wired-lan] " Magnus Karlsson

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).