netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
To: Kurt Kanzenbach <kurt@linutronix.de>
Cc: Tony Nguyen <anthony.l.nguyen@intel.com>,
	Przemek Kitszel <przemyslaw.kitszel@intel.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>,
	"Paolo Abeni" <pabeni@redhat.com>,
	Alexei Starovoitov <ast@kernel.org>,
	"Daniel Borkmann" <daniel@iogearbox.net>,
	Jesper Dangaard Brouer <hawk@kernel.org>,
	John Fastabend <john.fastabend@gmail.com>,
	Richard Cochran <richardcochran@gmail.com>,
	Sriram Yagnaraman <sriram.yagnaraman@ericsson.com>,
	Benjamin Steinke <benjamin.steinke@woks-audio.com>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	<intel-wired-lan@lists.osuosl.org>, <netdev@vger.kernel.org>,
	<bpf@vger.kernel.org>,
	Sriram Yagnaraman <sriram.yagnaraman@est.tech>
Subject: Re: [PATCH iwl-next v6 1/6] igb: Always call igb_xdp_ring_update_tail() under Tx lock
Date: Mon, 19 Aug 2024 15:07:00 +0200	[thread overview]
Message-ID: <ZsNDdPTHu2OACpPq@boxer> (raw)
In-Reply-To: <20240711-b4-igb_zero_copy-v6-1-4bfb68773b18@linutronix.de>

On Fri, Aug 16, 2024 at 11:24:00AM +0200, Kurt Kanzenbach wrote:
> From: Sriram Yagnaraman <sriram.yagnaraman@est.tech>
> 
> Always call igb_xdp_ring_update_tail() under __netif_tx_lock(), add a
> comment to indicate that. This is needed to share the same TX ring between
> XDP, XSK and slow paths.

Sorry for being a-hole here but I think this should go to -net as a fix...
I should have brought it up earlier, current igb XDP support is racy on
tail updates which you're fixing here.

Do you agree...or not?:)

> 
> Signed-off-by: Sriram Yagnaraman <sriram.yagnaraman@est.tech>
> [Kurt: Split patches]
> Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de>
> ---
>  drivers/net/ethernet/intel/igb/igb_main.c | 14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
> index 11be39f435f3..4d5e5691c9bd 100644
> --- a/drivers/net/ethernet/intel/igb/igb_main.c
> +++ b/drivers/net/ethernet/intel/igb/igb_main.c
> @@ -2914,6 +2914,7 @@ static int igb_xdp(struct net_device *dev, struct netdev_bpf *xdp)
>  	}
>  }
>  
> +/* This function assumes __netif_tx_lock is held by the caller. */
>  static void igb_xdp_ring_update_tail(struct igb_ring *ring)
>  {
>  	/* Force memory writes to complete before letting h/w know there
> @@ -3000,11 +3001,11 @@ static int igb_xdp_xmit(struct net_device *dev, int n,
>  		nxmit++;
>  	}
>  
> -	__netif_tx_unlock(nq);
> -
>  	if (unlikely(flags & XDP_XMIT_FLUSH))
>  		igb_xdp_ring_update_tail(tx_ring);
>  
> +	__netif_tx_unlock(nq);
> +
>  	return nxmit;
>  }
>  
> @@ -8853,12 +8854,14 @@ static void igb_put_rx_buffer(struct igb_ring *rx_ring,
>  
>  static int igb_clean_rx_irq(struct igb_q_vector *q_vector, const int budget)
>  {
> +	unsigned int total_bytes = 0, total_packets = 0;
>  	struct igb_adapter *adapter = q_vector->adapter;
>  	struct igb_ring *rx_ring = q_vector->rx.ring;
> -	struct sk_buff *skb = rx_ring->skb;
> -	unsigned int total_bytes = 0, total_packets = 0;
>  	u16 cleaned_count = igb_desc_unused(rx_ring);
> +	struct sk_buff *skb = rx_ring->skb;
> +	int cpu = smp_processor_id();
>  	unsigned int xdp_xmit = 0;
> +	struct netdev_queue *nq;
>  	struct xdp_buff xdp;
>  	u32 frame_sz = 0;
>  	int rx_buf_pgcnt;
> @@ -8986,7 +8989,10 @@ static int igb_clean_rx_irq(struct igb_q_vector *q_vector, const int budget)
>  	if (xdp_xmit & IGB_XDP_TX) {
>  		struct igb_ring *tx_ring = igb_xdp_tx_queue_mapping(adapter);
>  
> +		nq = txring_txq(tx_ring);
> +		__netif_tx_lock(nq, cpu);
>  		igb_xdp_ring_update_tail(tx_ring);
> +		__netif_tx_unlock(nq);
>  	}
>  
>  	u64_stats_update_begin(&rx_ring->rx_syncp);
> 
> -- 
> 2.39.2
> 

  parent reply	other threads:[~2024-08-19 13:07 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-16  9:23 [PATCH iwl-next v6 0/6] igb: Add support for AF_XDP zero-copy Kurt Kanzenbach
2024-08-16  9:24 ` [PATCH iwl-next v6 1/6] igb: Always call igb_xdp_ring_update_tail() under Tx lock Kurt Kanzenbach
2024-08-16  9:38   ` Sebastian Andrzej Siewior
2024-08-16  9:56     ` Kurt Kanzenbach
2024-08-19 13:07   ` Maciej Fijalkowski [this message]
2024-08-19 14:21     ` Kurt Kanzenbach
2024-08-16  9:24 ` [PATCH iwl-next v6 2/6] igb: Remove static qualifiers Kurt Kanzenbach
2024-08-19 13:10   ` Maciej Fijalkowski
2024-08-19 14:23     ` Kurt Kanzenbach
2024-08-16  9:24 ` [PATCH iwl-next v6 3/6] igb: Introduce igb_xdp_is_enabled() Kurt Kanzenbach
2024-08-19 13:11   ` Maciej Fijalkowski
2024-08-16  9:24 ` [PATCH iwl-next v6 4/6] igb: Introduce XSK data structures and helpers Kurt Kanzenbach
2024-08-19 13:19   ` Maciej Fijalkowski
2024-08-19 13:41     ` Kurt Kanzenbach
2024-08-19 14:10       ` Maciej Fijalkowski
2024-08-19 14:27         ` Kurt Kanzenbach
2024-08-19 19:34         ` Sriram Yagnaraman
2024-08-20 12:24           ` Kurt Kanzenbach
2024-08-20 12:33             ` Fijalkowski, Maciej
2024-08-16  9:24 ` [PATCH iwl-next v6 5/6] igb: Add AF_XDP zero-copy Rx support Kurt Kanzenbach
2024-08-19 14:47   ` Maciej Fijalkowski
2024-08-16  9:24 ` [PATCH iwl-next v6 6/6] igb: Add AF_XDP zero-copy Tx support Kurt Kanzenbach
2024-08-19 16:30   ` Maciej Fijalkowski
2024-08-16 12:17 ` [PATCH iwl-next v6 0/6] igb: Add support for AF_XDP zero-copy Maciej Fijalkowski

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=ZsNDdPTHu2OACpPq@boxer \
    --to=maciej.fijalkowski@intel.com \
    --cc=anthony.l.nguyen@intel.com \
    --cc=ast@kernel.org \
    --cc=benjamin.steinke@woks-audio.com \
    --cc=bigeasy@linutronix.de \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hawk@kernel.org \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=john.fastabend@gmail.com \
    --cc=kuba@kernel.org \
    --cc=kurt@linutronix.de \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=przemyslaw.kitszel@intel.com \
    --cc=richardcochran@gmail.com \
    --cc=sriram.yagnaraman@ericsson.com \
    --cc=sriram.yagnaraman@est.tech \
    /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 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).