From: Leon Romanovsky <leon@kernel.org>
To: Jakub Kicinski <kuba@kernel.org>
Cc: davem@davemloft.net, netdev@vger.kernel.org, jiri@nvidia.com,
idosch@nvidia.com, petrm@nvidia.com, simon.horman@corigine.com,
louis.peens@corigine.com
Subject: Re: [PATCH net-next 1/6] devlink: expose instance locking and add locked port registering
Date: Wed, 16 Mar 2022 10:29:16 +0200 [thread overview]
Message-ID: <YjGf3OqijAiqSNE/@unreal> (raw)
In-Reply-To: <20220315060009.1028519-2-kuba@kernel.org>
On Mon, Mar 14, 2022 at 11:00:04PM -0700, Jakub Kicinski wrote:
> It should be familiar and beneficial to expose devlink instance
> lock to the drivers. This way drivers can block devlink from
> calling them during critical sections without breakneck locking.
>
> Add port helpers, port splitting callbacks will be the first
> target.
>
> Use 'devl_' prefix for "explicitly locked" API. Initial RFC used
> '__devlink' but that's too much typing.
>
> devl_lock_is_held() is not defined without lockdep, which is
> the same behavior as lockdep_is_held() itself.
>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> ---
> v1: - add a small section to the docs
> - redo the lockdep ifdef
> ---
> Documentation/networking/devlink/index.rst | 16 ++++
> include/net/devlink.h | 11 +++
> net/core/devlink.c | 95 ++++++++++++++++------
> 3 files changed, 98 insertions(+), 24 deletions(-)
<...>
> +void devl_assert_locked(struct devlink *devlink)
> +{
> + lockdep_assert_held(&devlink->lock);
> +}
> +EXPORT_SYMBOL_GPL(devl_assert_locked);
> +
> +#ifdef CONFIG_LOCKDEP
> +/* For use in conjunction with LOCKDEP only e.g. rcu_dereference_protected() */
> +bool devl_lock_is_held(struct devlink *devlink)
> +{
> + return lockdep_is_held(&devlink->lock);
> +}
> +EXPORT_SYMBOL_GPL(devl_lock_is_held);
> +#endif
Sorry that I'm asking you again same question.
How will this devl_lock_is_held() be used in drivers?
Right now, if I decide to use this function in mlx5 (or in any other driver),
the code will be something like this:
void func(...)
{
....
if (IS_ENABLED(CONFIG_LOCKDEP))
if (rcu_dereference_protected(a, devl_lock_is_held(devlink) == b) {
....
}
The line "if (IS_ENABLED(CONFIG_LOCKDEP))" needs to be in every driver
or it won't compile in release mode.
Thanks
next prev parent reply other threads:[~2022-03-16 8:29 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-15 6:00 [PATCH net-next 0/6] devlink: expose instance locking and simplify port splitting Jakub Kicinski
2022-03-15 6:00 ` [PATCH net-next 1/6] devlink: expose instance locking and add locked port registering Jakub Kicinski
2022-03-16 8:29 ` Leon Romanovsky [this message]
2022-03-16 16:48 ` Jakub Kicinski
2022-03-16 18:39 ` Leon Romanovsky
2022-03-16 18:39 ` Leon Romanovsky
2022-03-15 6:00 ` [PATCH net-next 2/6] eth: nfp: wrap locking assertions in helpers Jakub Kicinski
2022-03-15 6:00 ` [PATCH net-next 3/6] eth: nfp: replace driver's "pf" lock with devlink instance lock Jakub Kicinski
2022-03-16 8:34 ` Leon Romanovsky
2022-03-16 16:45 ` Jakub Kicinski
2022-03-15 6:00 ` [PATCH net-next 4/6] eth: mlxsw: switch to explicit locking for port registration Jakub Kicinski
2022-03-15 8:29 ` Ido Schimmel
2022-03-15 6:00 ` [PATCH net-next 5/6] devlink: hold the instance lock in port_split / port_unsplit callbacks Jakub Kicinski
2022-03-15 8:30 ` Ido Schimmel
2022-03-15 6:00 ` [PATCH net-next 6/6] devlink: pass devlink_port to " Jakub Kicinski
2022-03-15 8:32 ` Ido Schimmel
2022-03-16 20:07 ` [PATCH net-next 0/6] devlink: expose instance locking and simplify port splitting Jakub Kicinski
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=YjGf3OqijAiqSNE/@unreal \
--to=leon@kernel.org \
--cc=davem@davemloft.net \
--cc=idosch@nvidia.com \
--cc=jiri@nvidia.com \
--cc=kuba@kernel.org \
--cc=louis.peens@corigine.com \
--cc=netdev@vger.kernel.org \
--cc=petrm@nvidia.com \
--cc=simon.horman@corigine.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;
as well as URLs for NNTP newsgroup(s).