netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kuniyuki Iwashima <kuniyu@amazon.com>
To: <kuniyu@amazon.com>
Cc: <davem@davemloft.net>, <edumazet@google.com>, <kuba@kernel.org>,
	<kuni1840@gmail.com>, <netdev@vger.kernel.org>,
	<pabeni@redhat.com>
Subject: Re: [PATCH v2 net-next 2/4] rtnetlink: Add per-netns RTNL.
Date: Fri, 4 Oct 2024 13:51:04 -0700	[thread overview]
Message-ID: <20241004205104.69430-1-kuniyu@amazon.com> (raw)
In-Reply-To: <20241004204526.68765-1-kuniyu@amazon.com>

From: Kuniyuki Iwashima <kuniyu@amazon.com>
Date: Fri, 4 Oct 2024 13:45:26 -0700
> From: Jakub Kicinski <kuba@kernel.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();
}

  reply	other threads:[~2024-10-04 20:51 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-02 15:12 [PATCH v2 net-next 0/4] rtnetlink: Per-netns RTNL Kuniyuki Iwashima
2024-10-02 15:12 ` [PATCH v2 net-next 1/4] Revert "rtnetlink: add guard for RTNL" Kuniyuki Iwashima
2024-10-02 15:14   ` Eric Dumazet
2024-10-02 15:12 ` [PATCH v2 net-next 2/4] rtnetlink: Add per-netns RTNL Kuniyuki Iwashima
2024-10-04 11:08   ` Eric Dumazet
2024-10-04 20:21   ` Jakub Kicinski
2024-10-04 20:45     ` Kuniyuki Iwashima
2024-10-04 20:51       ` Kuniyuki Iwashima [this message]
2024-10-04 20:59         ` Eric Dumazet
2024-10-04 21:22           ` Kuniyuki Iwashima
2024-10-02 15:12 ` [PATCH v2 net-next 3/4] rtnetlink: Add assertion helpers for " Kuniyuki Iwashima
2024-10-04 11:10   ` Eric Dumazet
2024-10-02 15:12 ` [PATCH v2 net-next 4/4] rtnetlink: Add ASSERT_RTNL_NET() placeholder for netdev notifier Kuniyuki Iwashima
2024-10-04 11:14   ` Eric Dumazet

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241004205104.69430-1-kuniyu@amazon.com \
    --to=kuniyu@amazon.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=kuni1840@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).