netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: Kuniyuki Iwashima <kuniyu@amazon.com>
Cc: "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	David Ahern <dsahern@kernel.org>,
	Kuniyuki Iwashima <kuni1840@gmail.com>,
	netdev@vger.kernel.org, kernel test robot <lkp@intel.com>
Subject: Re: [PATCH v1 net-next 01/12] rtnetlink: Make per-netns RTNL dereference helpers to macro.
Date: Wed, 23 Oct 2024 19:58:50 +0100	[thread overview]
Message-ID: <20241023185850.GC402847@kernel.org> (raw)
In-Reply-To: <20241021183239.79741-2-kuniyu@amazon.com>

On Mon, Oct 21, 2024 at 11:32:28AM -0700, Kuniyuki Iwashima wrote:
> When CONFIG_DEBUG_NET_SMALL_RTNL is off, rtnl_net_dereference() is the
> static inline wrapper of rtnl_dereference() returning a plain (void *)
> pointer to make sure net is always evaluated as requested in [0].
> 
> But, it makes sparse complain [1] when the pointer has __rcu annotation:
> 
>   net/ipv4/devinet.c:674:47: sparse: warning: incorrect type in argument 2 (different address spaces)
>   net/ipv4/devinet.c:674:47: sparse:    expected void *p
>   net/ipv4/devinet.c:674:47: sparse:    got struct in_ifaddr [noderef] __rcu *
> 
> Also, if we evaluate net as (void *) in a macro, then the compiler
> in turn fails to build due to -Werror=unused-value.
> 
>   #define rtnl_net_dereference(net, p)                  \
>         ({                                              \
>                 (void *)net;                            \
>                 rtnl_dereference(p);                    \
>         })
> 
>   net/ipv4/devinet.c: In function ‘inet_rtm_deladdr’:
>   ./include/linux/rtnetlink.h:154:17: error: statement with no effect [-Werror=unused-value]
>     154 |                 (void *)net;                            \
>   net/ipv4/devinet.c:674:21: note: in expansion of macro ‘rtnl_net_dereference’
>     674 |              (ifa = rtnl_net_dereference(net, *ifap)) != NULL;
>         |                     ^~~~~~~~~~~~~~~~~~~~
> 
> Let's go back to the original simplest macro.
> 
> Note that checkpatch complains about this approach, but it's one-shot and
> less noisy than the other two.
> 
>   WARNING: Argument 'net' is not used in function-like macro
>   #76: FILE: include/linux/rtnetlink.h:142:
>   +#define rtnl_net_dereference(net, p)			\
>   +	rtnl_dereference(p)
> 
> Fixes: 844e5e7e656d ("rtnetlink: Add assertion helpers for per-netns RTNL.")
> Link: https://lore.kernel.org/netdev/20241004132145.7fd208e9@kernel.org/ [0]
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202410200325.SaEJmyZS-lkp@intel.com/ [1]
> Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>

Thanks,

I was able to reproduce the build problem as described.

Reviewed-by: Simon Horman <horms@kernel.org>

  reply	other threads:[~2024-10-23 18:58 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-21 18:32 [PATCH v1 net-next 00/12] ipv4: Convert RTM_{NEW,DEL}ADDR and more to per-netns RTNL Kuniyuki Iwashima
2024-10-21 18:32 ` [PATCH v1 net-next 01/12] rtnetlink: Make per-netns RTNL dereference helpers to macro Kuniyuki Iwashima
2024-10-23 18:58   ` Simon Horman [this message]
2024-10-21 18:32 ` [PATCH v1 net-next 02/12] rtnetlink: Define RTNL_FLAG_DOIT_PERNET for per-netns RTNL doit() Kuniyuki Iwashima
2024-10-21 18:32 ` [PATCH v1 net-next 03/12] ipv4: Factorise RTM_NEWADDR validation to inet_validate_rtm() Kuniyuki Iwashima
2024-10-21 18:32 ` [PATCH v1 net-next 04/12] ipv4: Don't allocate ifa for 0.0.0.0 in inet_rtm_newaddr() Kuniyuki Iwashima
2024-10-21 18:32 ` [PATCH v1 net-next 05/12] ipv4: Convert RTM_NEWADDR to per-netns RTNL Kuniyuki Iwashima
2024-10-21 18:32 ` [PATCH v1 net-next 06/12] ipv4: Use per-netns RTNL helpers in inet_rtm_newaddr() Kuniyuki Iwashima
2024-10-21 18:32 ` [PATCH v1 net-next 07/12] ipv4: Convert RTM_DELADDR to per-netns RTNL Kuniyuki Iwashima
2024-10-21 18:32 ` [PATCH v1 net-next 08/12] ipv4: Convert check_lifetime() " Kuniyuki Iwashima
2024-10-21 18:32 ` [PATCH v1 net-next 09/12] rtnetlink: Define rtnl_net_trylock() Kuniyuki Iwashima
2024-10-21 18:32 ` [PATCH v1 net-next 10/12] ipv4: Convert devinet_sysctl_forward() to per-netns RTNL Kuniyuki Iwashima
2024-10-21 18:32 ` [PATCH v1 net-next 11/12] ipv4: Convert devinet_ioctl() to per-netns RTNL except for SIOCSIFFLAGS Kuniyuki Iwashima
2024-10-21 18:32 ` [PATCH v1 net-next 12/12] ipv4: Convert devinet_ioctl to per-netns RTNL Kuniyuki Iwashima
2024-10-29 11:20 ` [PATCH v1 net-next 00/12] ipv4: Convert RTM_{NEW,DEL}ADDR and more " patchwork-bot+netdevbpf

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=20241023185850.GC402847@kernel.org \
    --to=horms@kernel.org \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=kuni1840@gmail.com \
    --cc=kuniyu@amazon.com \
    --cc=lkp@intel.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).