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 18:57:35 +0200

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.

So if you want the "eliminate" thing like you wrote in the comment,
the ifdef is a common solution.

> 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.

Thanks

> 
> > diff --git a/include/net/devlink.h b/include/net/devlink.h
> > index 8d5349d2fb68..33b47d1a6800 100644
> > --- a/include/net/devlink.h
> > +++ b/include/net/devlink.h
> > @@ -1762,5 +1762,12 @@ devlink_compat_switch_id_get(struct net_device *dev,
> >  }
> >  
> >  #endif
> > -
> > +#if IS_ENABLED(CONFIG_LOCKDEP)
> > +bool devl_lock_is_held(struct devlink *devlink);
> > +#else
> > +static inline bool devl_lock_is_held(struct devlink *devlink)
> > +{
> > +       return true;
> > +}
> > +#endif
> >  #endif /* _NET_DEVLINK_H_ */