Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: linusw@kernel.org
Cc: ulli.kroll@googlemail.com, andrew+netdev@lunn.ch,
	davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com,
	mirq-linux@rere.qmqm.pl, mhun512@gmail.com, edumazet@kernel.org,
	netdev@vger.kernel.org
Subject: Re: [PATCH net-next v8 06/19] net: ethernet: cortina: Index free queue fragments with XArray
Date: Mon, 16 Nov 2026 14:45:45 +0000	[thread overview]
Message-ID: <179484034552.3136.9115305674551947540@kernel.org> (raw)
In-Reply-To: <20261112-gemini-ethernet-fixes-3-v8-6-f55bd43e02d3@kernel.org>

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 geth_freeq_alloc_map_page()
  (drivers/net/ethernet/cortina/gemini.c), the patch adds one…
- [Low] geth_setup_freeq() (drivers/net/ethernet/cortina/gemini.c) now
  wraps every geth_freeq_alloc_map_page() call in…

--

net: ethernet: cortina: Index free queue fragments with XArray

This commit replaces the linear scan in geth_freeq_lookup() with an XArray
that indexes each free queue fragment by its DMA address in fragment units.
Index entries are inserted and erased in geth_freeq_alloc_map_page() under
freeq_lock, and geth_setup_freeq() now takes freeq_lock around each page
allocation.

> diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/cortina/gemini.c
> index b96325f652bba..4ee630a9f5897 100644
> --- a/drivers/net/ethernet/cortina/gemini.c
> +++ b/drivers/net/ethernet/cortina/gemini.c

[ ... ]

> @@ -888,9 +898,26 @@ static struct page *geth_freeq_alloc_map_page(struct gemini_ethernet *geth,
>  	 */
>  	frag_len = 1 << geth->freeq_frag_order; /* Usually 2048 */
>  	fpp_order = PAGE_SHIFT - geth->freeq_frag_order;
> +	fragments = 1 << fpp_order;
> +
>  	gpage = &geth->freeq_pages[pn];
> -	if (gpage->page)
> +	for (i = 0; i < fragments; i++) {
> +		mapping = page_mapping + i * frag_len;
> +		ret = xa_insert(&geth->freeq_mappings,
> +				geth_freeq_mapping_index(geth, mapping),
> +				gpage, GFP_ATOMIC);
> +		if (ret)
> +			goto err_mappings;
> +	}

[Severity: Low]
Should the commit message mention what this xa_insert() costs?

The commit message describes the change only as removing an inefficient
linear scan. However, geth_freeq_alloc_map_page() now does GFP_ATOMIC
xa_node allocations on both the NAPI refill path and the setup path:

gmac_napi_poll()
  geth_fill_freeq(geth, true)
    geth_freeq_alloc_map_page()
      xa_insert(..., GFP_ATOMIC)

That works out to roughly one leaf node per 128 KiB of physical address
range touched (64 slots of 2 KiB each).

There is also a new way for this function to fail. If only the index
allocation fails, err_mappings unmaps and frees a page that was allocated
and DMA mapped successfully. geth_fill_freeq() then stops refilling, and
geth_setup_freeq() fails open or resize with -ENOMEM.

The unwind looks correct, and the failure is handled the same way as an
alloc_page(GFP_ATOMIC) failure. So the concern is the commit message, not
the runtime behaviour.

Could the commit message describe the extra atomic allocations and the new
failure mode? The same GFP_ATOMIC xa_insert() is still in
geth_freeq_post_page() at the end of the series.

[ ... ]

> @@ -995,16 +1035,20 @@ static int geth_setup_freeq(struct gemini_ethernet *geth)
>  		goto err_freeq;
>  	}
>  
> -	/* Allocate a mapping to page look-up index */
> +	/* Allocate page metadata referenced by the mapping index */
>  	geth->freeq_pages = kzalloc_objs(*geth->freeq_pages, pages);
>  	if (!geth->freeq_pages)
>  		goto err_freeq;
>  	geth->num_freeq_pages = pages;
>  
>  	dev_info(geth->dev, "allocate %d pages for queue\n", pages);
> -	for (pn = 0; pn < pages; pn++)
> -		if (!geth_freeq_alloc_map_page(geth, pn))
> +	for (pn = 0; pn < pages; pn++) {
> +		spin_lock_irqsave(&geth->freeq_lock, flags);
> +		page = geth_freeq_alloc_map_page(geth, pn);
> +		spin_unlock_irqrestore(&geth->freeq_lock, flags);
> +		if (!page)
>  			goto err_freeq_alloc;
> +	}

[Severity: Low]
Does holding freeq_lock here mean the setup path builds the whole index
from atomic reserves?

geth_setup_freeq() is reached from geth_resize_freeq() in sleepable process
context under RTNL (ndo_open or ethtool -G). With freeq_lock held and IRQs
off, every xa_insert() in geth_freeq_alloc_map_page() has to use GFP_ATOMIC
and cannot do direct reclaim:

geth_resize_freeq()
  geth_setup_freeq()
    spin_lock_irqsave(&geth->freeq_lock, flags)
    geth_freeq_alloc_map_page()
      xa_insert(..., GFP_ATOMIC)

A large ring (up to 2^15 entries, about 16K pages) needs a burst of these
node allocations. Under memory pressure, that makes open or ring resize
more likely to fail with -ENOMEM.

The effect is small, because the RX pages were already allocated with
alloc_page(GFP_ATOMIC) before this patch. The same pattern is still there
at the end of the series via
geth_setup_freeq()->geth_fill_freeq()->geth_freeq_post_page().

On the setup path, could the index entries be reserved with GFP_KERNEL
before taking the lock (for example with xa_reserve())? Alternatively,
could a gfp argument be passed down so that setup can use sleeping
allocations?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261112-gemini-ethernet-fixes-3-v8-0-f55bd43e02d3%40kernel.org

  reply	other threads:[~2026-11-16 14:45 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-12 13:30 [PATCH net-next v8 00/19] net: ethernet: cortina: Fix Gemini RX/TX buffer management Linus Walleij
2026-11-12 13:30 ` [PATCH net-next v8 01/19] net: ethernet: cortina: Keep shared free queue parent-owned Linus Walleij
2026-11-12 13:30 ` [PATCH net-next v8 02/19] net: ethernet: cortina: Keep ports bound for shared IRQ Linus Walleij
2026-11-16 14:45   ` netdev-bot+sashiko
2026-11-12 13:30 ` [PATCH net-next v8 03/19] net: ethernet: cortina: Drain free queue IRQ before resize Linus Walleij
2026-11-12 13:30 ` [PATCH net-next v8 04/19] net: ethernet: cortina: Normalize free queue pointers on rebuild Linus Walleij
2026-11-12 13:30 ` [PATCH net-next v8 05/19] net: ethernet: cortina: Correct free queue DMA mappings Linus Walleij
2026-11-12 13:30 ` [PATCH net-next v8 06/19] net: ethernet: cortina: Index free queue fragments with XArray Linus Walleij
2026-11-16 14:45   ` netdev-bot+sashiko [this message]
2026-11-12 13:30 ` [PATCH net-next v8 07/19] net: ethernet: cortina: Preserve in-flight free queue pages Linus Walleij
2026-11-16 14:45   ` netdev-bot+sashiko
2026-11-12 13:30 ` [PATCH net-next v8 08/19] net: ethernet: cortina: Rotate free queue page allocation Linus Walleij
2026-11-12 13:30 ` [PATCH net-next v8 09/19] net: ethernet: cortina: Recycle claimed free queue pages Linus Walleij
2026-11-12 13:30 ` [PATCH net-next v8 10/19] net: ethernet: cortina: Separate RX buffer capacity from free queue size Linus Walleij
2026-11-16 14:45   ` netdev-bot+sashiko
2026-11-12 13:30 ` [PATCH net-next v8 11/19] net: ethernet: cortina: Validate RX fragment lengths Linus Walleij
2026-11-16 14:45   ` netdev-bot+sashiko
2026-11-12 13:30 ` [PATCH net-next v8 12/19] net: ethernet: cortina: Account RX buffer size in truesize Linus Walleij
2026-11-12 13:30 ` [PATCH net-next v8 13/19] net: ethernet: cortina: Release partial RX frames on stop Linus Walleij
2026-11-12 13:30 ` [PATCH net-next v8 14/19] net: ethernet: cortina: Scale Gemini RX queues to system memory Linus Walleij
2026-11-12 13:30 ` [PATCH net-next v8 15/19] net: ethernet: cortina: Serialize TX completion statistics Linus Walleij
2026-11-16 14:45   ` netdev-bot+sashiko
2026-11-12 13:30 ` [PATCH net-next v8 16/19] net: ethernet: cortina: Scope RX statistics updates Linus Walleij
2026-11-12 13:30 ` [PATCH net-next v8 17/19] net: ethernet: cortina: Drain RX coalescing timer on stop Linus Walleij
2026-11-12 13:30 ` [PATCH net-next v8 18/19] net: ethernet: cortina: Reject TX rings smaller than retained pointers Linus Walleij
2026-11-12 13:30 ` [PATCH net-next v8 19/19] net: ethernet: cortina: Fix ethtool statistics reads Linus Walleij
2026-11-16 14:45   ` netdev-bot+sashiko

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=179484034552.3136.9115305674551947540@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linusw@kernel.org \
    --cc=mhun512@gmail.com \
    --cc=mirq-linux@rere.qmqm.pl \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=ulli.kroll@googlemail.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