Subject: Re: [RFT net-next 1/6] devlink: expose instance locking and add locked port registering

From: Leon Romanovsky <[email-masked]>
Date: Fri, 11 Mar 2022 19:49:36 +0200

On Fri, Mar 11, 2022 at 09:39:13AM -0800, Jakub Kicinski wrote:
> On Fri, 11 Mar 2022 18:57:35 +0200 Leon Romanovsky wrote:
> > On Fri, Mar 11, 2022 at 08:26:11AM -0800, Jakub Kicinski wrote:
> > > On Fri, 11 Mar 2022 18:09:36 +0200 Leon Romanovsky wrote:  
> > > > What about this?  
> > > 
> > > Is it better?   
> > 
> > I think so. It doesn't create shadow dependency on LOCKDEP.
> > In your variant, all users of this call will generate WARN
> > in production systems that run without lockdep.
> 
> No, no, that function is mostly for rcu dereference checking.
> The calls should be eliminated as dead code on production systems.

On systems without LOCKDEP, the devl_lock_is_held function will be
generated to be like this:
bool devl_lock_is_held(struct devlink *devlink)
{
	return WARN_ON_ONCE(true);
}
EXPORT_SYMBOL_GPL(devl_lock_is_held);

> 
> > So if you want the "eliminate" thing like you wrote in the comment,
> > the ifdef is a common solution.
> 
> I think these days people try to use IS_ENABLED() whenever possible.

I'm one of such people, but here you put always WARN if LOCKDEP is not
enabled.

> 
> > > Can do it you prefer, but I'd lean towards a version
> > > without an ifdef myself.  
> > 
> > So you need to add CONFIG_LOCKDEP dependency in devlink Kconfig.
> 
> I don't see why.

Because of WARN_ON_ONCE.

Thanks