๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #19000

Re: [net-next v6 12/15] devlink: give user option to allocate resources

#19000
From: netdev-bot+sashiko
Date: Thu, 19 Nov 2026 06:45
129 lines
13168 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] API asymmetry in the new occ_set mode, plus an unsafe misuse
  path.
- [Low] The occ_set paths change size_new without revalidating the
  hierarchy.

--

devlink: give user option to allocate resources

This adds a new mode of operation for devlink resources. In this mode a
driver registers an occ_set() callback together with occ_get() through
devl_resource_occ_set_get_register(). DEVLINK_CMD_RESOURCE_SET then
applies the requested size immediately and does not stage it until
reload. For such resources the getter value is reported as
DEVLINK_ATTR_RESOURCE_SIZE.

> diff --git a/net/devlink/resource.c b/net/devlink/resource.c
> index c3cfda7ea0703..c4502c480a6bb 100644
> --- a/net/devlink/resource.c
> +++ b/net/devlink/resource.c

[ ... ]

> @@ -137,6 +139,16 @@ int devlink_nl_resource_set_doit(struct sk_buff *skb, struct genl_info *info)
>  	if (err)
>  		return err;
>  
> +	if (resource->occ_set) {
> +		err = resource->occ_set(size, info->extack, resource->occ_priv);
> +		if (err)
> +			return err;
> +
> +		resource->size = resource->occ_get(resource->occ_priv);
> +		resource->size_new = resource->size;
> +		return 0;
> +	}
> +
>  	resource->size_new = size;
>  	devlink_resource_validate_children(resource);
>  	if (resource->parent)

[Severity: Low]
Should the occ_set branch also revalidate the hierarchy before it returns?

The legacy branch below sets size_new and then calls
devlink_resource_validate_children() on the resource and on its parent.
The occ_set branch changes size_new and returns before doing either.
The occ_set refresh added to devl_resource_size_get() also overwrites
size_new without revalidating.

devlink_resource_validate_children() computes the parent's size_valid
from the sum of the children's size_new. That flag is reported as
DEVLINK_ATTR_RESOURCE_SIZE_VALID. It is also checked by
devlink_resources_validate(), which gates DEVLINK_CMD_RELOAD in
devlink_nl_reload_doit():

    err = devlink_resources_validate(devlink, NULL, info);
    if (err) {
        NL_SET_ERR_MSG(info->extack, "resources size validation failed");

Nothing stops one hierarchy from mixing the two modes. Take a legacy
parent P with an occ_set child A and a legacy child B. Setting B through
the legacy path marks P invalid. If A is then shrunk through occ_set so
the sum fits again, does P stay invalid, so that reload is refused? In
the other direction, growing A through occ_set would leave P reported
as valid.

No in-tree user mixes the modes today. In this series ice registers rss,
lut_512 and lut_2048 all with devl_resource_occ_set_get_register(), so
this is latent. Should this path revalidate mixed hierarchies, or should
they be rejected or documented as unsupported?

[ ... ]

> @@ -684,9 +748,10 @@ void devl_resource_occ_get_unregister(struct devlink *devlink,
>  	if (WARN_ON(!resource))
>  		return;
>  	WARN_ON(!resource->occ_get);
> +	WARN_ON(resource->occ_set);
>  
>  	resource->occ_get = NULL;
> -	resource->occ_get_priv = NULL;
> +	resource->occ_priv = NULL;
>  }
>  EXPORT_SYMBOL_GPL(devl_resource_occ_get_unregister);

[Severity: Low]
Should this WARN_ON(resource->occ_set) return instead of falling
through?

devl_resource_occ_set_get_register() is exported, but
include/net/devlink.h declares no matching unregister. That leaves
devl_resource_occ_get_unregister() as the only detach helper. If it is
called on a resource registered with
devl_resource_occ_set_get_register(), it warns, clears occ_get and
occ_priv, and leaves occ_set set.

The three mode checks then disagree. devlink_resource_occ_size_put()
requires both callbacks, so it takes the legacy path. But
devlink_nl_resource_set_doit() and devl_resource_size_get() check only
occ_set:

    if (resource->occ_set) {
        err = resource->occ_set(size, info->extack, resource->occ_priv);
        ...
        resource->size = resource->occ_get(resource->occ_priv);

Would a later DEVLINK_CMD_RESOURCE_SET call occ_set() with a NULL priv
and then call through the NULL occ_get pointer?
devl_resource_size_get() would make the same call to occ_get.

Nothing in-tree reaches this today. The only user in the series is ice,
which tears down with devl_resources_unregister() and never calls
devl_resource_occ_get_unregister(). Drivers that follow the existing
convention keep resources registered across reload and unregister the
callbacks in fini or reload_down. The new mode offers no way to do that.

Would it make sense to add a matching unregister helper, or have this
one also clear occ_set? Could all three places use the same mode check?

-- 
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261117094913.100756-1-przemyslaw.kitszel%40intel.com
Technical Details
Message-ID: <179507070407.3136.14784491222272219958@kernel.org>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-366782-linux-kernel-netdev=dewy.ru
References: <20261117094913.100756-13-przemyslaw.kitszel@intel.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-366782-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [net-next v6 12/15] devlink: give user option to allocate resources
Date: Thu, 19 Nov 2026 06:45:04 +0000
Organization: Usenet Network
Message-ID: <179507070407.3136.14784491222272219958@kernel.org>
References: <20261117094913.100756-13-przemyslaw.kitszel@intel.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2809832"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:y3vC6WSh5UPGJMPxz3586XCBfPg= sha256:DPthMAbWnaXB78lQRQo2a4il8r7tSFXvShoKKrH9pos=
	sha1:jUQh/tqF9A7TxI0u6r2sYO0yvRw= sha256:E7MnDTeHtTnFY7KPYEtStbxsUegGckgozD9rkCoj9bo=
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 0CD7A115530; Thu, 19 Nov 2026 09:45:45 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.4
X-Spam-Status: No, score=-3.4 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, URIBL_BLOCKED=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 iVhrh7yWrkQb;
	Thu, 19 Nov 2026 09:45:38 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-366782-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 sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4])
	by mail.dewy.ru (Postfix) with ESMTPS id 40EA711552B; Thu, 19 Nov 2026 09:45:28 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sin.lore.kernel.org (Postfix) with ESMTP id 8A48A1C4E36; Thu, 19 Nov 2026 06:45:23 +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=1795070707;
	b=HWfGF666SK7K2c0QuSHGjaQJVDnRgyUWQFylK+XNCKyIbtdBR3JwfWm32kvi5+n7ullq
	 I7sOwvTZPR/ARp1dlId/aZhbBtAMpw03K+jdDXpiBK7U1U29LwEGm9tqw6m+WZFUwxbCT
	 lOz+1U2jclBlsPQAp9PEhKBQs23ctZthZqu3e0B8Hr5yE5QVO4TkOZoOmZZ/36duCDeXW
	 i0k5sSOuV12IWuM96PIfT9nE0Ou7HUaQxvU5B13ZlW9+kwo2kG/kLwpq6zzbKIkwXOdqB
	 KJEkVLYjKELttY/8i4LzDd1SQOw6zAp02QLxIH2NF0e/za43iJ5HbEnml12Zm9slxPg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795070707;
	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=fsOt81r2UE7NffohmViWawVkV/SETfL9NBoyQgD8Gzs=;
	b=e0LEz+mKFqbOaV/Ng430Nqzck4+Ln7sqm4NSlgeHRWqYZluEO1xP0wXZswTqCwjNsW8f
	 cCzbNTBHDzseM76WWJJ1aPe1bmO71uJre1m4Ozlkr0uAozXwi5AccTwmu9ytRIHyLlrxI
	 g93OarjDJkeUxa+PH1hyVSts7fsU1eCbhebk79/InkLoaMiUasanGJabIkp/rH0HQ+jCa
	 OY1igxxGo8cWv/GtB9pHqTtteD8c4Cbe2RqM+jQIDUdQTPkNhveBJIwEH38x9PzM0cGVu
	 6+v+GYpn7U5Vc/b5ZHYtcyVe6lPzrhnoRq7QDKVBadnyC+iDC21gWnHBuRCZ06TF75A==
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=eHWsZenl;
	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 02E2960A2603;
	Thu, 19 Nov 2026 06:45:07 +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=eHWsZenl
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=1795070706;
	b=uf6LQI2d1JwsQWOhVhpykplbfqmlx2R/YZbdKYLvMn++/QxROOIkw3xzj8d9Xla9RU7S
	 lEj1ZhnLgZeoDjBC5YWthu0P5bQ/Dib5GuWP3QM4A2Y7qx8eFwM0X543piJkp/MUy+322
	 vhdkVn2KTXx4lBM910x0ncOS3N/X6V/31mVcxpT/AopagdMTZS+e09EvkQxFTGTdEYx+b
	 clv2shr5GcA5M4LzfpjAPu619uiMXk9npNvI+M78GjX69hG/RLeSPjMjBSho+7guMKsil
	 xN7c+ql4qwS1h6BoAGHaXZVDQSwnHn+UJFkBu/NIIDn8f7r/6ct1mPV36Agf4vDE8yw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795070706;
	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=fsOt81r2UE7NffohmViWawVkV/SETfL9NBoyQgD8Gzs=;
	b=yWZCDvjVr+bH10x74SaCpOiNgAFz+iWRVSiAe09kp42oyTKX9H2mVqVm3BrDbSc3Fuvx
	 mowtAgQCf8sJ/L77OR/xn4B7xb4v1OexkGMQ7To8nUmE45AGpZXZextR4/1NpT9Q/9+O5
	 1P6XD6GkpueU7bsC0VqYswbtlwj3A042N0ggY6qXwjtTA93TKG1kYjPdKxMu6sg+MVM0Z
	 EYIbVlMB8dSEfnHtaEpU31kIDcPM2t3f09cv60urCqdv/sEO4Sa+K6ORgRL37LOisThRn
	 K0uWfD5PV3yL1RFOtbf6Jpt5L8sexXAdVklUquGLN/fOvgMcHuXniCmry13EOLVBRyw==
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=eHWsZenl;
	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 23FDB60A2624
	for <netdev@vger.kernel.org>; Thu, 19 Nov 2026 06:45:05 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7B3E11F000C4;
	Thu, 19 Nov 2026 06:45:04 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795070705;
	bh=fsOt81r2UE7NffohmViWawVkV/SETfL9NBoyQgD8Gzs=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=eHWsZenlEppWUDsFKFQDcz40+2WslWI46FGsz/DHedoIyjUdg8v+I/no8KyWpqrmt
	 ynG4rWZU0ZFAJLpHdfV5aVR8uLvC2TX8n6d/jlth4o9Gka07iSWh+XnAUKcH5J6kKC
	 1UAB/H3osbAMCPP+gHOVA9eIWrNPsYBpYgucSjL6sGmmr6wUQHCFwwExznYkbeZC2H
	 LWGio2XuiWdBNqp4nmst1rGq211slBOWQjVa1LHi5zCu+myM14UEcPOMWRrn3XWgR2
	 ZRkjPwZ6GUXjm5eCSq3eAPOnY4uFa/e9STiMz7ZXo3tXc3Yg4NGe63qIfz9BrT4fbo
	 dtoKvbPSPvi7Q==
X-Cc: kuba@kernel.org, netdev@vger.kernel.org, aleksandr.loktionov@intel.com,
 andrew+netdev@lunn.ch, anthony.l.nguyen@intel.com, anzaki@gmail.com,
 brett.creeley@amd.com, corbet@lwn.net, davem@davemloft.net,
 edumazet@kernel.org, horms@kernel.org, jacob.e.keller@intel.com,
 jedrzej.jagielski@intel.com, jiri@resnulli.us, leon@kernel.org,
 mbloch@nvidia.com, mschmidt@redhat.com, ohartoov@nvidia.com,
 pabeni@redhat.com, poros@redhat.com, rdunlap@infradead.org, saeedm@nvidia.com,
 skhan@linuxfoundation.org, tariqt@nvidia.com
X-In-Reply-To: <20261117094913.100756-13-przemyslaw.kitszel@intel.com>
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