From: netdev-bot+sashiko@kernel.org
To: lorenzo.bianconi@oss.qualcomm.com
Cc: maxime.chevallier@bootlin.com, andrew+netdev@lunn.ch,
davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
pabeni@redhat.com, mcoquelin.stm32@gmail.com,
alexandre.torgue@foss.st.com, ast@kernel.org,
daniel@iogearbox.net, hawk@kernel.org, john.fastabend@gmail.com,
sdf@fomichev.me, Jose.Abreu@synopsys.com,
boon.leong.ong@intel.com, horms@kernel.org, andrii@kernel.org,
eddyz87@gmail.com, memxor@gmail.com, martin.lau@linux.dev,
song@kernel.org, yonghong.song@linux.dev, jolsa@kernel.org,
emil@etsalapatis.com, ihor.solodrai@linux.dev,
matthew.gerlach@altera.com, boon.khai.ng@altera.com,
netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
bpf@vger.kernel.org, nb@tipi-net.de
Subject: Re: [PATCH net-next v13 5/5] net: stmmac: rework stmmac_rx to support XDP rx multi-buff
Date: Thu, 26 Nov 2026 14:50:28 +0000 [thread overview]
Message-ID: <179570462877.3135.11557910879568810263@kernel.org> (raw)
In-Reply-To: <20261125-stmmac-rx-mb-v13-5-0f6bac53e8d5@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] In stmmac_rx()
(drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:6056), the FCS is…
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but the patch
extends it.
--
net: stmmac: rework stmmac_rx to support XDP rx multi-buff
This reworks stmmac_rx() to collect all the descriptors of a frame in an
xdp_buff. XDP programs loaded with BPF_F_XDP_HAS_FRAGS now see the whole
fragmented packet, and the skb is built with xdp_build_skb_from_buff().
The in-progress xdp_buff is saved in rx_q->state across NAPI polls, and
the FCS is stripped with xdp_buff_shrink_tail().
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index 7896364c43e95..56355d80ba161 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
[ ... ]
> @@ -5999,120 +6014,79 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue)
[ ... ]
> + n_descs++;
>
> -drain_data:
> if (likely(status & rx_not_ls))
> goto read_again;
> - if (!skb)
> - goto next;
>
> - /* Got entire packet into SKB. Finish it. */
> + /* ACS is disabled; strip manually. */
> + len -= ETH_FCS_LEN;
> + if (xdp_buff_shrink_tail(&ctx.xdp, ETH_FCS_LEN)) {
> + if (!error)
> + rx_dropped++;
> + error = 1;
> + }
[Severity: Low]
Is skb->truesize overstated when a frame spans several buffers and the
last buffer holds only FCS bytes (1 to 4 bytes)?
For a fragmented xdp_buff, xdp_buff_shrink_tail() calls
xdp_frags_shrink_tail(). That function returns the FCS-only page to the
pool through xdp_buff_shrink_data(), but it only adjusts nr_frags and
xdp_frags_size:
net/core/xdp.c:xdp_frags_shrink_tail() {
...
sinfo->nr_frags -= n_frags_free;
sinfo->xdp_frags_size -= len_free;
...
}
sinfo->xdp_frags_truesize still counts the xdp->frame_sz that
stmmac_build_xdp_frags() charged for that page through
xdp_buff_add_frag(). If at least one fragment is left,
xdp_build_skb_from_buff() uses that value unchanged:
net/core/xdp.c:xdp_build_skb_from_buff() {
...
tsize = sinfo->xdp_frags_truesize ? : nr_frags * xdp->frame_sz;
...
}
As a result, skb->truesize includes a full page_pool allocation
(PAGE_SIZE << order) for a page that has already been released.
In the common case the old code fixed this up. pskb_trim(), removed
below, went through ___pskb_trim()->skb_condense() (skb->sk is NULL on
RX), which pulled small leftover frags into the head and recomputed
truesize.
The commit message says the new truesize "is more accurate". Does that
hold for this case?
>
> - /* Remove FCS if needed */
> - if (!fcs_stripped && pskb_trim(skb, len)) {
> - dev_kfree_skb_any(skb);
> - rx_dropped++;
> + if (unlikely(error))
> + goto error_free_frag;
> +
> + ctx.desc = p;
> + ctx.ndesc = np;
> +
> + skb = stmmac_xdp_run_prog(priv, &ctx.xdp);
> + /* For Not XDP_PASS verdict */
> + if (IS_ERR(skb)) {
> + unsigned int xdp_res = -PTR_ERR(skb);
> +
> + if (xdp_res & STMMAC_XDP_CONSUMED) {
> + __xdp_return_buff(&ctx.xdp, true);
> + rx_dropped++;
> + } else if (xdp_res & (STMMAC_XDP_TX |
> + STMMAC_XDP_REDIRECT)) {
> + xdp_status |= xdp_res;
> + }
> goto next;
> }
[Severity: High]
This issue was not introduced by this patch, but the patch makes it
wider. With the stmmac_xdp_run_prog() change, programs with
xdp_has_frags can now return XDP_TX on fragmented buffs. Is the direct
recycling done when the TX completes safe here?
stmmac_tx_clean() returns XDP_TX frames like this:
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:stmmac_tx_clean() {
...
if (xdpf &&
tx_q->tx_skbuff_dma[entry].buf_type == STMMAC_TXBUF_T_XDP_TX) {
xdp_return_frame_rx_napi(xdpf);
...
}
xdp_return_frame_rx_napi() calls __xdp_return() with napi_direct set to
true. That path ends in page_pool_recycle_in_cache(), which writes
pool->alloc.cache[pool->alloc.count++] with no locking.
stmmac_tx_clean() runs from stmmac_napi_poll_tx() on ch->tx_napi. That
is not the ch->rx_napi which owns and refills rx_q->page_pool.
stmmac_xdp_xmit_back() also picks the TX queue by CPU through
stmmac_xdp_get_tx_queue(priv, smp_processor_id()). The completion can
therefore run on a different channel's tx_napi.
The pool is created without pp_params.napi, so page_pool has no way to
detect the foreign context.
Some setups put the two NAPI contexts on different CPUs:
- MSI with independent rx/tx IRQ affinity, for example 4 RX and 2 TX
queues on 4 CPUs
- irqbalance
- threaded NAPI
- busy polling
In those setups rx_napi can pop from pool->alloc.cache while tx_napi
pushes into it from another CPU. With this patch, rx_napi uses that
cache more, through __xdp_return_buff(&ctx.xdp, true) and
page_pool_put_full_page(..., true).
Could the racing alloc.count updates lose a page, so that the pool never
drains? Could they also hand the same page out twice, so that two RX
descriptors DMA into it, or a page is DMA-written while the stack still
owns it?
This race already exists for head pages. With fragmented XDP_TX,
xdp_return_frame_rx_napi() now also direct-recycles every fragment page
from that context.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261125-stmmac-rx-mb-v13-0-0f6bac53e8d5%40oss.qualcomm.com
next prev parent reply other threads:[~2026-11-26 14:50 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 14:48 [PATCH net-next v13 0/5] net: stmmac: introduce XDP rx multi-buff support Lorenzo Bianconi
2026-11-25 14:48 ` [PATCH net-next v13 1/5] net: stmmac: selftests: Prevent RXC from being disabled in LPI Lorenzo Bianconi
2026-11-25 14:48 ` [PATCH net-next v13 2/5] net: stmmac: remove software VLAN tag stripping Lorenzo Bianconi
2026-11-26 14:50 ` netdev-bot+sashiko
2026-11-25 14:48 ` [PATCH net-next v13 3/5] net: xdp: add xdp_buff_shrink_tail() helper Lorenzo Bianconi
2026-11-25 14:48 ` [PATCH net-next v13 4/5] net: xdp: add __xdp_return_buff() helper Lorenzo Bianconi
2026-11-25 14:48 ` [PATCH net-next v13 5/5] net: stmmac: rework stmmac_rx to support XDP rx multi-buff Lorenzo Bianconi
2026-11-26 14:50 ` netdev-bot+sashiko [this message]
2026-11-25 14:53 ` [PATCH net-next v13 0/5] net: stmmac: introduce XDP rx multi-buff support netdev-bot+sinfo
2026-11-26 8:48 ` 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=179570462877.3135.11557910879568810263@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=Jose.Abreu@synopsys.com \
--cc=alexandre.torgue@foss.st.com \
--cc=andrew+netdev@lunn.ch \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=boon.khai.ng@altera.com \
--cc=boon.leong.ong@intel.com \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=eddyz87@gmail.com \
--cc=edumazet@kernel.org \
--cc=emil@etsalapatis.com \
--cc=hawk@kernel.org \
--cc=horms@kernel.org \
--cc=ihor.solodrai@linux.dev \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=lorenzo.bianconi@oss.qualcomm.com \
--cc=martin.lau@linux.dev \
--cc=matthew.gerlach@altera.com \
--cc=maxime.chevallier@bootlin.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=memxor@gmail.com \
--cc=nb@tipi-net.de \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sdf@fomichev.me \
--cc=song@kernel.org \
--cc=yonghong.song@linux.dev \
/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