[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20241004212217.73348-1-kuniyu@amazon.com>
Date: Fri, 4 Oct 2024 14:22:17 -0700
From: Kuniyuki Iwashima <kuniyu@...zon.com>
To: <edumazet@...gle.com>
CC: <davem@...emloft.net>, <kuba@...nel.org>, <kuni1840@...il.com>,
<kuniyu@...zon.com>, <netdev@...r.kernel.org>, <pabeni@...hat.com>
Subject: Re: [PATCH v2 net-next 2/4] rtnetlink: Add per-netns RTNL.
From: Eric Dumazet <edumazet@...gle.com>
Date: Fri, 4 Oct 2024 22:59:32 +0200
> On Fri, Oct 4, 2024 at 10:51 PM Kuniyuki Iwashima <kuniyu@...zon.com> wrote:
> >
> > From: Kuniyuki Iwashima <kuniyu@...zon.com>
> > Date: Fri, 4 Oct 2024 13:45:26 -0700
> > > From: Jakub Kicinski <kuba@...nel.org>
> > > Date: Fri, 4 Oct 2024 13:21:45 -0700
> > > > On Wed, 2 Oct 2024 08:12:38 -0700 Kuniyuki Iwashima wrote:
> > > > > +#ifdef CONFIG_DEBUG_NET_SMALL_RTNL
> > > > > +void __rtnl_net_lock(struct net *net);
> > > > > +void __rtnl_net_unlock(struct net *net);
> > > > > +void rtnl_net_lock(struct net *net);
> > > > > +void rtnl_net_unlock(struct net *net);
> > > > > +int rtnl_net_lock_cmp_fn(const struct lockdep_map *a, const struct lockdep_map *b);
> > > > > +#else
> > > > > +#define __rtnl_net_lock(net)
> > > > > +#define __rtnl_net_unlock(net)
> > > > > +#define rtnl_net_lock(net) rtnl_lock()
> > > > > +#define rtnl_net_unlock(net) rtnl_unlock()
> > > >
> > > > Let's make sure net is always evaluated?
> > > > At the very least make sure the preprocessor doesn't eat it completely
> > > > otherwise we may end up with config-dependent "unused variable"
> > > > warnings down the line.
> > >
> > > Sure, what comes to mind is void casting, which I guess is old-school
> > > style ? Do you have any other idea or is this acceptable ?
> > >
> > > #define __rtnl_net_lock(net) (void)(net)
> > > #define __rtnl_net_unlock(net) (void)(net)
> > > #define rtnl_net_lock(net) \
> > > do { \
> > > (void)(net); \
> > > rtnl_lock(); \
> > > } while (0)
> > > #define rtnl_net_unlock(net) \
> > > do { \
> > > (void)(net); \
> > > rtnl_unlock(); \
> > > } while (0)
> >
> > or simply define these as static inline functions and
> > probably this is more preferable ?
> >
> > static inline void __rtnl_net_lock(struct net *net) {}
> > static inline void __rtnl_net_unlock(struct net *net) {}
> > static inline void rtnl_net_lock(struct net *net)
> > {
> > rtnl_lock();
> > }
> > static inline void rtnl_net_unlock(struct net *net)
> > {
> > rtnl_unlock();
> > }
>
> static inline functions seem better to me.
Will use them.
Thanks !
Powered by blists - more mailing lists