From: netdev-bot+sashiko@kernel.org
To: przemyslaw.kitszel@intel.com
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
Subject: Re: [net-next v6 12/15] devlink: give user option to allocate resources
Date: Thu, 19 Nov 2026 06:45:04 +0000 [thread overview]
Message-ID: <179507070407.3136.14784491222272219958@kernel.org> (raw)
In-Reply-To: <20261117094913.100756-13-przemyslaw.kitszel@intel.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] 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
next prev parent reply other threads:[~2026-11-19 6:45 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 9:44 [net-next v6 00/15] devlink, mlx5, iavf, ice: XLVF for iavf Przemek Kitszel
2026-11-17 9:44 ` [net-next v6 01/15] devlink, mlx5: add init/fini ops for shared devlink Przemek Kitszel
2026-11-17 9:44 ` [net-next v6 02/15] ice: use shared devlink to store ice_adapters instead of custom xarray Przemek Kitszel
2026-11-17 9:44 ` [net-next v6 03/15] ice: add VF queue ena/dis helper functions Przemek Kitszel
2026-11-17 9:44 ` [net-next v6 04/15] ice: add helpers for Global RSS LUT alloc, free, vsi_update Przemek Kitszel
2026-11-17 9:44 ` [net-next v6 05/15] ice: rename ICE_MAX_RSS_QS_PER_VF to ICE_MAX_QS_PER_VF_VCV1 Przemek Kitszel
2026-11-19 6:44 ` netdev-bot+sashiko
2026-11-17 9:44 ` [net-next v6 06/15] ice: bump to 256qs for VF Przemek Kitszel
2026-11-19 6:44 ` netdev-bot+sashiko
2026-11-17 9:44 ` [net-next v6 07/15] iavf: extend iavf_configure_queues() to support more queues Przemek Kitszel
2026-11-17 9:44 ` [net-next v6 08/15] iavf: temporary rename of IAVF_MAX_REQ_QUEUES to IAVF_MAX_REQ_QUEUES_VCV1 Przemek Kitszel
2026-11-17 9:44 ` [net-next v6 09/15] iavf: increase max number of queues to 256 Przemek Kitszel
2026-11-19 6:44 ` netdev-bot+sashiko
2026-11-17 9:44 ` [net-next v6 10/15] iavf: use new opcodes to request more than 16 queues Przemek Kitszel
2026-11-19 6:45 ` netdev-bot+sashiko
2026-11-17 9:44 ` [net-next v6 11/15] ice: introduce handling of virtchnl LARGE VF opcodes Przemek Kitszel
2026-11-19 6:45 ` netdev-bot+sashiko
2026-11-17 9:44 ` [net-next v6 12/15] devlink: give user option to allocate resources Przemek Kitszel
2026-11-19 6:45 ` netdev-bot+sashiko [this message]
2026-11-17 9:44 ` [net-next v6 13/15] ice: represent RSS LUTs as devlink resources Przemek Kitszel
2026-11-19 6:45 ` netdev-bot+sashiko
2026-11-17 9:44 ` [net-next v6 14/15] devlink: add devlink_alloc_drv() Przemek Kitszel
2026-11-19 6:45 ` netdev-bot+sashiko
2026-11-17 9:44 ` [net-next v6 15/15] ice: support up to 256 VF queues Przemek Kitszel
2026-11-19 6: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=179507070407.3136.14784491222272219958@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=aleksandr.loktionov@intel.com \
--cc=andrew+netdev@lunn.ch \
--cc=anthony.l.nguyen@intel.com \
--cc=anzaki@gmail.com \
--cc=brett.creeley@amd.com \
--cc=corbet@lwn.net \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=jacob.e.keller@intel.com \
--cc=jedrzej.jagielski@intel.com \
--cc=jiri@resnulli.us \
--cc=kuba@kernel.org \
--cc=leon@kernel.org \
--cc=mbloch@nvidia.com \
--cc=mschmidt@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=ohartoov@nvidia.com \
--cc=pabeni@redhat.com \
--cc=poros@redhat.com \
--cc=przemyslaw.kitszel@intel.com \
--cc=rdunlap@infradead.org \
--cc=saeedm@nvidia.com \
--cc=skhan@linuxfoundation.org \
--cc=tariqt@nvidia.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