🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #17272

Re: [PATCH net-next v8 06/19] net: ethernet: cortina: Index free queue fragments with XArray

#17272
From: netdev-bot+sashiko
Date: Mon, 16 Nov 2026 14:45
129 lines
12791 bytes
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
Technical Details
Message-ID: <179484034552.3136.9115305674551947540@kernel.org>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srv.newsdeef.eu!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-364467-linux-kernel-netdev=dewy.ru
References: <20261112-gemini-ethernet-fixes-3-v8-6-f55bd43e02d3@kernel.org>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srv.newsdeef.eu!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-364467-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
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
Organization: Usenet Network
Message-ID: <179484034552.3136.9115305674551947540@kernel.org>
References: <20261112-gemini-ethernet-fixes-3-v8-6-f55bd43e02d3@kernel.org>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2089682"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:nXJWQKl5HWG9ECsNWZTPus+LS0I= sha256:2CvzW84aWQLIfSOM2Qk0NbqhEJPg4bLvlAOPNvuvcwQ=
	sha1:qm30lTUT42UIH8104ynHEtbZhNA= sha256:tv/tePWAaOKfeA1dwHeWrrMb1eRy4FAGSkkOl8UM4JM=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id C9B49114C94; Mon, 16 Nov 2026 17:46:05 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id NB26CSv3QsPu;
	Mon, 16 Nov 2026 17:46:01 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-364467-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id 87D84114C8E; Mon, 16 Nov 2026 17:45:53 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id A97B0289CC; Mon, 16 Nov 2026 14:45:50 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1794840347;
	b=qxYckBnOSDvSQUUCd64Sxo/A+8SrViPCpFN2HEHWuInpdCkeM5k7wAkgosqrV23dHphR
	 SlnISTmIT+SWIHPPUf+oCR2JYSjJ9fwx0MNoEyQ2eS75/A2L27Uu10//MrVzTb5kUqjxz
	 xNfHLSRUZ4uTwao0Oli9IabPVzoM6y2OWBmBz41JhSMQxV5a3t/fenVufxUMrzLRQBIfm
	 sH+cL37vnHn/E1Ef6kEqoCg1a1T87dYzmypbXn/RTjY0njvcFNUF877/w5eqarFeqAFeg
	 Ja+EcwHbOIlzyeCsEC1NKORBP2DUD77f9TuLwaIrsjfl+N8V1a3vAbrCoGo32PrzEYA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794840347;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=wlQrgMDchbW+yo7SUHlvYilxgMFSkK/xZHB6l4m4/sY=;
	b=qqOElbdtMW+CPg2d+5fiEFseull8c/qfAuGDTzPE3z+1PFL4F+x8l/hzFI+ze5Yeq8JT
	 Z97XF0npKQx52FtDJlVgWTIzxL4li5FHWsenUmtcHOYmBptnx1hiq7A0Qt7dkm4+7Ptu4
	 jLgBmtgIzP0rDSusigI/jkecgHbrYZVSpmWatueDtpQHllZMSl9F3PIahfE5gECpSdcAW
	 k/dJx4vIRzUjAVCJqcAGQnZPI+QzWIE18W5RAKljE5ELL5QnXzbT/SYOEJ3SQh4vNapt7
	 1FL56IhPX85mLG9BMU6oyI+DBmNSMxKFyGXLrseyBuJy9Uo5Fqxb4t/ir+IQW4YLjDA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=orUNkdPv;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id CD3C7606A33F;
	Mon, 16 Nov 2026 14:45:47 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=orUNkdPv
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1794840347;
	b=oPOZTytkgkW6Wa4dIEEAjRNefVP5OtQJBKf+CgrZTE/ZdQZH6m1Lr6QDLSkfBqmA7oQc
	 En5VY2OOuoW/zAw+YssyWB8cTahl0drKIL85VKqWU3Sg//WC510nTGOgdnNnJ5PRW9jZw
	 eRxU0wm/DPtSXAEM2685MpQBWBB6n4/DkIn+jQgNvBB/ymasa7yHpSwlQ8rp/z+jBoF2e
	 ySgF+Sw51kHNROC+m+IsrtUt51oYtfZbMWgBguTKtxqkp+8TeSPLuuENBxxfDijXw3kcM
	 RAfay2kHwXkNv96Gjqq6Y0O7r/rI1wpNhIN9JnBFQjUEOtkovmfeuRvteEtYZHrz81Q==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794840347;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=wlQrgMDchbW+yo7SUHlvYilxgMFSkK/xZHB6l4m4/sY=;
	b=O/2nX0uRsB1bTeheVw+dRrT7Mwdn6YgsUrarSP0JHtjaxUTbXV21B7Ca8l40PsIgWEqT
	 dmDnqeth+LwkTiU8mFNpFBvhHMCb+rx6u86/33GMPrsLkUIcGVFocTREB9cRZrKcAdMP5
	 8xFlAIUUu3iQFgEr7BFKTFtp+fTpEpCSD5MzGUXZ6ClFB/DoegiSNPyxUGPumF4Dv8wEj
	 ntUiH1Q54EnEbMVAXCgoh4e1PmbbyRAwOj2YwwMQuggCMyKPgwBWL74miOHwfPqCoQYdG
	 ymYfyF/joydJ5zz5OtOOQRbvtcw/EDr7fDsHgjw0TgGEk3KxWXoBC6dLVshYj3cPjkw==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=orUNkdPv;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id EB397606A335
	for <netdev@vger.kernel.org>; Mon, 16 Nov 2026 14:45:46 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id F3FE81F000C4;
	Mon, 16 Nov 2026 14:45:45 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1794840346;
	bh=wlQrgMDchbW+yo7SUHlvYilxgMFSkK/xZHB6l4m4/sY=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=orUNkdPvBoWZMBx4ha7w1OTGJa4SpwwrNHcqXxOwaTbsgo//G44LaQq2rxpXDL5K9
	 RX7NrMa68TM64RDbQ4AXd1gPfycjRLwPXqPfBgPTJQnwDYSH4AZPknYKwRZz0Mg4Pk
	 4OZw1LTUqOvzMeK43BFY6ewutLTfS+1fad87NjQYc1lYtnJZ1etUgVdeRrBqgCrZOz
	 NOp8Mg6ss3z7DoOJZcYScFo6KlcQGoyHmiHrYnQgDCBjKizOyo0Eydu7nxAg3tVI2h
	 o0fFRg6Qh15McaIjYXUOV93666TWE3CRvVjuFc0rcbBaHPOWE7q9Ulj0wQ3aMxE/S3
	 JQkZAcD7K7uPQ==
X-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
X-In-Reply-To: <20261112-gemini-ethernet-fixes-3-v8-6-f55bd43e02d3@kernel.org>
X-sashiko-severity: Low
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list