[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YjIu4CBxEJ6UTk7c@unreal>
Date: Wed, 16 Mar 2022 20:39:28 +0200
From: Leon Romanovsky <leon@...nel.org>
To: Jakub Kicinski <kuba@...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, Mar 16, 2022 at 09:48:59AM -0700, Jakub Kicinski wrote:
> 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))
Ahhh, I see, thanks for an explanation.
>
> 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