[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220316094859.2128c430@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com>
Date: Wed, 16 Mar 2022 09:48:59 -0700
From: Jakub Kicinski <kuba@...nel.org>
To: Leon Romanovsky <leon@...nel.org>
Cc: davem@...emloft.net, netdev@...r.kernel.org, jiri@...dia.com,
idosch@...dia.com, petrm@...dia.com, simon.horman@...igine.com,
louis.peens@...igine.com
Subject: Re: [PATCH net-next 1/6] devlink: expose instance locking and add
locked port registering
On Wed, 16 Mar 2022 10:29:16 +0200 Leon Romanovsky wrote:
> 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.
It follows the semantics of lockdep_is_held(), note that
rcu_dereference_protected() makes the last parameter dead
code with LOCKDEP=n
#define RCU_LOCKDEP_WARN(c, s) do { } while (0 && (c))
where (c) would be devl_lock_is_held()
so the call to devl_lock_is_held() is eliminated, and we
won't get a linker error. There's no need for IS_ENABLED().
Powered by blists - more mailing lists