* [PATCH 1/2] Fix race in igc_xdp_xmit_zc
@ 2022-04-15 21:04 ` Jeff Evanson
0 siblings, 0 replies; 6+ messages in thread
From: Jeff Evanson @ 2022-04-15 21:04 UTC (permalink / raw)
To: Jesse Brandeburg, Tony Nguyen, David S. Miller, Jakub Kicinski,
Alexei Starovoitov, Daniel Borkmann, Jesper Dangaard Brouer,
John Fastabend, intel-wired-lan, netdev, linux-kernel, bpf
Cc: jeff.evanson, jeff.evanson
in igc_xdp_xmit_zc, initialize next_to_use while holding the netif_tx_lock
to prevent racing with other users of the tx ring
Signed-off-by: Jeff Evanson <jeff.evanson@qsc.com>
---
drivers/net/ethernet/intel/igc/igc_main.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c
index 1c00ee310c19..a36a18c84aeb 100644
--- a/drivers/net/ethernet/intel/igc/igc_main.c
+++ b/drivers/net/ethernet/intel/igc/igc_main.c
@@ -2598,7 +2598,7 @@ static void igc_xdp_xmit_zc(struct igc_ring *ring)
struct netdev_queue *nq = txring_txq(ring);
union igc_adv_tx_desc *tx_desc = NULL;
int cpu = smp_processor_id();
- u16 ntu = ring->next_to_use;
+ u16 ntu;
struct xdp_desc xdp_desc;
u16 budget;
@@ -2607,6 +2607,8 @@ static void igc_xdp_xmit_zc(struct igc_ring *ring)
__netif_tx_lock(nq, cpu);
+ ntu = ring->next_to_use;
+
budget = igc_desc_unused(ring);
while (xsk_tx_peek_desc(pool, &xdp_desc) && budget--) {
--
2.17.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Intel-wired-lan] [PATCH 1/2] Fix race in igc_xdp_xmit_zc
@ 2022-04-15 21:04 ` Jeff Evanson
0 siblings, 0 replies; 6+ messages in thread
From: Jeff Evanson @ 2022-04-15 21:04 UTC (permalink / raw)
To: intel-wired-lan
in igc_xdp_xmit_zc, initialize next_to_use while holding the netif_tx_lock
to prevent racing with other users of the tx ring
Signed-off-by: Jeff Evanson <jeff.evanson@qsc.com>
---
drivers/net/ethernet/intel/igc/igc_main.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c
index 1c00ee310c19..a36a18c84aeb 100644
--- a/drivers/net/ethernet/intel/igc/igc_main.c
+++ b/drivers/net/ethernet/intel/igc/igc_main.c
@@ -2598,7 +2598,7 @@ static void igc_xdp_xmit_zc(struct igc_ring *ring)
struct netdev_queue *nq = txring_txq(ring);
union igc_adv_tx_desc *tx_desc = NULL;
int cpu = smp_processor_id();
- u16 ntu = ring->next_to_use;
+ u16 ntu;
struct xdp_desc xdp_desc;
u16 budget;
@@ -2607,6 +2607,8 @@ static void igc_xdp_xmit_zc(struct igc_ring *ring)
__netif_tx_lock(nq, cpu);
+ ntu = ring->next_to_use;
+
budget = igc_desc_unused(ring);
while (xsk_tx_peek_desc(pool, &xdp_desc) && budget--) {
--
2.17.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] Fix race in igc_xdp_xmit_zc
2022-04-15 21:04 ` [Intel-wired-lan] " Jeff Evanson
@ 2022-04-18 17:39 ` Vinicius Costa Gomes
-1 siblings, 0 replies; 6+ messages in thread
From: Vinicius Costa Gomes @ 2022-04-18 17:39 UTC (permalink / raw)
To: Jeff Evanson, Jesse Brandeburg, Tony Nguyen, David S. Miller,
Jakub Kicinski, Alexei Starovoitov, Daniel Borkmann,
Jesper Dangaard Brouer, John Fastabend, intel-wired-lan, netdev,
linux-kernel, bpf
Cc: jeff.evanson, jeff.evanson
Hi Jeff,
Jeff Evanson <jeff.evanson@gmail.com> writes:
> in igc_xdp_xmit_zc, initialize next_to_use while holding the netif_tx_lock
> to prevent racing with other users of the tx ring
Some style things to change:
- Some more details on what is the effect of the race condition, and
perhaps the conditions to reproduce it (what I could imagine is that
you would need two applications (one using AF_XDP and another one using
AF_PACKET, for example) sending packets to the same queue.
- I think this patch is solving a real problem, so directing this patch
to the net-queue (using 'PATCH net-queue' as subject prefix) would make
sense.
- Please add the 'Fixes:' tag so this commit can be applied to any
stable tree that makes sense.
Apart from those style changes, the code looks good.
Acked-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
>
> Signed-off-by: Jeff Evanson <jeff.evanson@qsc.com>
> ---
> drivers/net/ethernet/intel/igc/igc_main.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c
> index 1c00ee310c19..a36a18c84aeb 100644
> --- a/drivers/net/ethernet/intel/igc/igc_main.c
> +++ b/drivers/net/ethernet/intel/igc/igc_main.c
> @@ -2598,7 +2598,7 @@ static void igc_xdp_xmit_zc(struct igc_ring *ring)
> struct netdev_queue *nq = txring_txq(ring);
> union igc_adv_tx_desc *tx_desc = NULL;
> int cpu = smp_processor_id();
> - u16 ntu = ring->next_to_use;
> + u16 ntu;
> struct xdp_desc xdp_desc;
> u16 budget;
>
> @@ -2607,6 +2607,8 @@ static void igc_xdp_xmit_zc(struct igc_ring *ring)
>
> __netif_tx_lock(nq, cpu);
>
> + ntu = ring->next_to_use;
> +
> budget = igc_desc_unused(ring);
>
> while (xsk_tx_peek_desc(pool, &xdp_desc) && budget--) {
> --
> 2.17.1
>
--
Vinicius
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Intel-wired-lan] [PATCH 1/2] Fix race in igc_xdp_xmit_zc
@ 2022-04-18 17:39 ` Vinicius Costa Gomes
0 siblings, 0 replies; 6+ messages in thread
From: Vinicius Costa Gomes @ 2022-04-18 17:39 UTC (permalink / raw)
To: intel-wired-lan
Hi Jeff,
Jeff Evanson <jeff.evanson@gmail.com> writes:
> in igc_xdp_xmit_zc, initialize next_to_use while holding the netif_tx_lock
> to prevent racing with other users of the tx ring
Some style things to change:
- Some more details on what is the effect of the race condition, and
perhaps the conditions to reproduce it (what I could imagine is that
you would need two applications (one using AF_XDP and another one using
AF_PACKET, for example) sending packets to the same queue.
- I think this patch is solving a real problem, so directing this patch
to the net-queue (using 'PATCH net-queue' as subject prefix) would make
sense.
- Please add the 'Fixes:' tag so this commit can be applied to any
stable tree that makes sense.
Apart from those style changes, the code looks good.
Acked-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
>
> Signed-off-by: Jeff Evanson <jeff.evanson@qsc.com>
> ---
> drivers/net/ethernet/intel/igc/igc_main.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c
> index 1c00ee310c19..a36a18c84aeb 100644
> --- a/drivers/net/ethernet/intel/igc/igc_main.c
> +++ b/drivers/net/ethernet/intel/igc/igc_main.c
> @@ -2598,7 +2598,7 @@ static void igc_xdp_xmit_zc(struct igc_ring *ring)
> struct netdev_queue *nq = txring_txq(ring);
> union igc_adv_tx_desc *tx_desc = NULL;
> int cpu = smp_processor_id();
> - u16 ntu = ring->next_to_use;
> + u16 ntu;
> struct xdp_desc xdp_desc;
> u16 budget;
>
> @@ -2607,6 +2607,8 @@ static void igc_xdp_xmit_zc(struct igc_ring *ring)
>
> __netif_tx_lock(nq, cpu);
>
> + ntu = ring->next_to_use;
> +
> budget = igc_desc_unused(ring);
>
> while (xsk_tx_peek_desc(pool, &xdp_desc) && budget--) {
> --
> 2.17.1
>
--
Vinicius
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Intel-wired-lan] [PATCH 1/2] Fix race in igc_xdp_xmit_zc
2022-04-15 21:04 ` [Intel-wired-lan] " Jeff Evanson
@ 2022-04-20 10:37 ` Alexander Lobakin
-1 siblings, 0 replies; 6+ messages in thread
From: Alexander Lobakin @ 2022-04-20 10:37 UTC (permalink / raw)
To: Jeff Evanson
Cc: Alexander Lobakin, Jesse Brandeburg, Tony Nguyen,
David S. Miller, Jakub Kicinski, Alexei Starovoitov,
Daniel Borkmann, Jesper Dangaard Brouer, John Fastabend,
intel-wired-lan, netdev, linux-kernel, bpf
From: Jeff Evanson <jeff.evanson@gmail.com>
Date: Fri, 15 Apr 2022 15:04:21 -0600
> in igc_xdp_xmit_zc, initialize next_to_use while holding the netif_tx_lock
> to prevent racing with other users of the tx ring
>
> Signed-off-by: Jeff Evanson <jeff.evanson@qsc.com>
> ---
> drivers/net/ethernet/intel/igc/igc_main.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c
> index 1c00ee310c19..a36a18c84aeb 100644
> --- a/drivers/net/ethernet/intel/igc/igc_main.c
> +++ b/drivers/net/ethernet/intel/igc/igc_main.c
> @@ -2598,7 +2598,7 @@ static void igc_xdp_xmit_zc(struct igc_ring *ring)
> struct netdev_queue *nq = txring_txq(ring);
> union igc_adv_tx_desc *tx_desc = NULL;
> int cpu = smp_processor_id();
> - u16 ntu = ring->next_to_use;
> + u16 ntu;
Please don't break the RCT (reverse christmas tree) style here. You
should move it to the bottom of the declaration block, ideally
combine it with the declaration of @budget as they're both u16s.
> struct xdp_desc xdp_desc;
> u16 budget;
>
> @@ -2607,6 +2607,8 @@ static void igc_xdp_xmit_zc(struct igc_ring *ring)
>
> __netif_tx_lock(nq, cpu);
>
> + ntu = ring->next_to_use;
> +
There's no need for this empty newline I believe.
> budget = igc_desc_unused(ring);
>
> while (xsk_tx_peek_desc(pool, &xdp_desc) && budget--) {
> --
> 2.17.1
Thanks,
Al
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Intel-wired-lan] [PATCH 1/2] Fix race in igc_xdp_xmit_zc
@ 2022-04-20 10:37 ` Alexander Lobakin
0 siblings, 0 replies; 6+ messages in thread
From: Alexander Lobakin @ 2022-04-20 10:37 UTC (permalink / raw)
To: intel-wired-lan
From: Jeff Evanson <jeff.evanson@gmail.com>
Date: Fri, 15 Apr 2022 15:04:21 -0600
> in igc_xdp_xmit_zc, initialize next_to_use while holding the netif_tx_lock
> to prevent racing with other users of the tx ring
>
> Signed-off-by: Jeff Evanson <jeff.evanson@qsc.com>
> ---
> drivers/net/ethernet/intel/igc/igc_main.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c
> index 1c00ee310c19..a36a18c84aeb 100644
> --- a/drivers/net/ethernet/intel/igc/igc_main.c
> +++ b/drivers/net/ethernet/intel/igc/igc_main.c
> @@ -2598,7 +2598,7 @@ static void igc_xdp_xmit_zc(struct igc_ring *ring)
> struct netdev_queue *nq = txring_txq(ring);
> union igc_adv_tx_desc *tx_desc = NULL;
> int cpu = smp_processor_id();
> - u16 ntu = ring->next_to_use;
> + u16 ntu;
Please don't break the RCT (reverse christmas tree) style here. You
should move it to the bottom of the declaration block, ideally
combine it with the declaration of @budget as they're both u16s.
> struct xdp_desc xdp_desc;
> u16 budget;
>
> @@ -2607,6 +2607,8 @@ static void igc_xdp_xmit_zc(struct igc_ring *ring)
>
> __netif_tx_lock(nq, cpu);
>
> + ntu = ring->next_to_use;
> +
There's no need for this empty newline I believe.
> budget = igc_desc_unused(ring);
>
> while (xsk_tx_peek_desc(pool, &xdp_desc) && budget--) {
> --
> 2.17.1
Thanks,
Al
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-04-20 10:41 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-15 21:04 [PATCH 1/2] Fix race in igc_xdp_xmit_zc Jeff Evanson
2022-04-15 21:04 ` [Intel-wired-lan] " Jeff Evanson
2022-04-18 17:39 ` Vinicius Costa Gomes
2022-04-18 17:39 ` [Intel-wired-lan] " Vinicius Costa Gomes
2022-04-20 10:37 ` Alexander Lobakin
2022-04-20 10:37 ` Alexander Lobakin
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.