public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Vladimir Oltean <vladimir.oltean@nxp.com>
To: Lorenzo Bianconi <lorenzo@kernel.org>
Cc: netdev@vger.kernel.org, claudiu.manoil@nxp.com,
	davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com, lorenzo.bianconi@redhat.com
Subject: Re: [PATCH v2 net-next] net: ethernet: enetc: unlock XDP_REDIRECT for XDP non-linear buffers
Date: Fri, 9 Dec 2022 02:58:21 +0200	[thread overview]
Message-ID: <20221209005821.virs3rtc2tth2lja@skbuf> (raw)
In-Reply-To: <1dc514b266e19b1e5973d038a0189ab6e4acb93a.1670544817.git.lorenzo@kernel.org>

On Fri, Dec 09, 2022 at 01:19:44AM +0100, Lorenzo Bianconi wrote:
> Even if full XDP_REDIRECT is not supported yet for non-linear XDP buffers
> since we allow redirecting just into CPUMAPs, unlock XDP_REDIRECT for
> S/G XDP buffer and rely on XDP stack to properly take care of the
> frames.
> 
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> ---
> Changes since v1:
> - drop Fixes tag
> - unlock XDP_REDIRECT
> - populate missing XDP metadata
> 
> Please note this patch is just compile tested
> ---

How would you like me to test this patch?

>  drivers/net/ethernet/freescale/enetc/enetc.c | 27 +++++++++-----------
>  1 file changed, 12 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c
> index 8671591cb750..9fd15e1e692d 100644
> --- a/drivers/net/ethernet/freescale/enetc/enetc.c
> +++ b/drivers/net/ethernet/freescale/enetc/enetc.c
> @@ -1412,6 +1412,16 @@ static void enetc_add_rx_buff_to_xdp(struct enetc_bdr *rx_ring, int i,
>  	/* To be used for XDP_TX */
>  	rx_swbd->len = size;
>  
> +	if (!xdp_buff_has_frags(xdp_buff)) {
> +		xdp_buff_set_frags_flag(xdp_buff);
> +		shinfo->xdp_frags_size = size;
> +	} else {
> +		shinfo->xdp_frags_size += size;
> +	}
> +
> +	if (page_is_pfmemalloc(rx_swbd->page))
> +		xdp_buff_set_frag_pfmemalloc(xdp_buff);
> +
>  	skb_frag_off_set(frag, rx_swbd->page_offset);
>  	skb_frag_size_set(frag, size);
>  	__skb_frag_set_page(frag, rx_swbd->page);
> @@ -1601,22 +1611,7 @@ static int enetc_clean_rx_ring_xdp(struct enetc_bdr *rx_ring,
>  			}
>  			break;
>  		case XDP_REDIRECT:
> -			/* xdp_return_frame does not support S/G in the sense
> -			 * that it leaks the fragments (__xdp_return should not
> -			 * call page_frag_free only for the initial buffer).
> -			 * Until XDP_REDIRECT gains support for S/G let's keep
> -			 * the code structure in place, but dead. We drop the
> -			 * S/G frames ourselves to avoid memory leaks which
> -			 * would otherwise leave the kernel OOM.
> -			 */
> -			if (unlikely(cleaned_cnt - orig_cleaned_cnt != 1)) {
> -				enetc_xdp_drop(rx_ring, orig_i, i);
> -				rx_ring->stats.xdp_redirect_sg++;
> -				break;
> -			}
> -
>  			tmp_orig_i = orig_i;
> -
>  			while (orig_i != i) {
>  				enetc_flip_rx_buff(rx_ring,
>  						   &rx_ring->rx_swbd[orig_i]);
> @@ -1628,6 +1623,8 @@ static int enetc_clean_rx_ring_xdp(struct enetc_bdr *rx_ring,
>  				enetc_xdp_free(rx_ring, tmp_orig_i, i);
>  			} else {
>  				xdp_redirect_frm_cnt++;
> +				if (xdp_buff_has_frags(&xdp_buff))
> +					rx_ring->stats.xdp_redirect_sg++;

Ideally we'd remove this counter altogether. Nothing interesting to see.

>  				rx_ring->stats.xdp_redirect++;
>  			}
>  		}
> -- 
> 2.38.1
>

  reply	other threads:[~2022-12-09  0:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-09  0:19 [PATCH v2 net-next] net: ethernet: enetc: unlock XDP_REDIRECT for XDP non-linear buffers Lorenzo Bianconi
2022-12-09  0:58 ` Vladimir Oltean [this message]
2022-12-09  8:58   ` Lorenzo Bianconi

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=20221209005821.virs3rtc2tth2lja@skbuf \
    --to=vladimir.oltean@nxp.com \
    --cc=claudiu.manoil@nxp.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=lorenzo.bianconi@redhat.com \
    --cc=lorenzo@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /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