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 14/15] devlink: add devlink_alloc_drv()
Date: Thu, 19 Nov 2026 06:45:07 +0000 [thread overview]
Message-ID: <179507070766.3136.14422997396446697010@kernel.org> (raw)
In-Reply-To: <20261117094913.100756-15-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] devlink_alloc_drv() passes @dev straight to __devlink_alloc()
with no WARN_ON(!dev).
--
devlink: add devlink_alloc_drv()
This adds devlink_alloc_drv(), a variant of devlink_alloc() that takes the
owning driver explicitly. It is meant for a PF driver that creates devlink
instances for its VFs, where the VF device may be bound to another driver
or to none. The devlink-info documentation is updated to say the reported
driver is the creating driver in that case.
> diff --git a/net/devlink/core.c b/net/devlink/core.c
> index 9b844e0c1bd2d..e2a7169287ec7 100644
> --- a/net/devlink/core.c
> +++ b/net/devlink/core.c
> @@ -531,6 +531,30 @@ struct devlink *devlink_alloc_ns(const struct devlink_ops *ops,
> }
> EXPORT_SYMBOL_GPL(devlink_alloc_ns);
>
> +/**
> + * devlink_alloc_drv - Allocate new devlink instance resources for given driver
> + * @ops: ops
> + * @priv_size: size of user private data
> + * @dev: parent device
> + * @drv: driver that owns the instance
> + *
> + * Variant of devlink_alloc() for a driver that creates an instance for
> + * a device bound to another (or no) driver, e.g. a PF driver for its VFs.
> + *
> + * @drv must not be NULL and must outlive the instance, only a pointer to it
> + * is kept. Operations that take the device lock, like reload, lock @dev,
> + * not a device bound to @drv.
> + *
> + * Return: new devlink instance, NULL on failure.
> + */
> +struct devlink *devlink_alloc_drv(const struct devlink_ops *ops,
> + size_t priv_size, struct device *dev,
> + const struct device_driver *drv)
> +{
> + return __devlink_alloc(ops, priv_size, &init_net, dev, drv);
> +}
[Severity: Low]
This isn't a bug, but should devlink_alloc_drv() also have the
WARN_ON(!dev) that devlink_alloc_ns() has?
net/devlink/core.c:devlink_alloc_ns() {
WARN_ON(!dev);
return __devlink_alloc(ops, priv_size, net, dev, dev->driver);
}
The kernel-doc calls @dev the parent device and says reload locks @dev.
If @dev is NULL, __devlink_alloc() goes ahead and creates an index-named
instance, like the one devlink_shd_get() creates. Then devl_dev_lock()
skips the device lock without any warning:
net/devlink/devl_internal.h:devl_dev_lock() {
if (dev_lock && devlink->dev)
device_lock(devlink->dev);
devl_lock(devlink);
}
That doesn't match the kernel-doc.
The same applies to @drv. The kernel-doc says it must not be NULL, but a
NULL @drv only hits the WARN_ON(!ops || !dev_driver) in __devlink_alloc(),
and allocation continues.
The only current caller, ice_init_vf_devlink() in the next patch, returns
early when vf->vfdev is NULL, so no current path passes a NULL @dev. Could
a check for dev be added here (and maybe for drv too) so this variant
behaves like devlink_alloc_ns() and the kernel-doc?
> +EXPORT_SYMBOL_GPL(devlink_alloc_drv);
> +
[ ... ]
--
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
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 [this message]
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=179507070766.3136.14422997396446697010@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