diff mbox series

netfilter: nf_tables: Add __percpu annotation to *stats pointer in nf_tables_updchain()

Message ID 20240806102808.804619-1-ubizjak@gmail.com (mailing list archive)
State Awaiting Upstream
Delegated to: Netdev Maintainers
Headers show
Series netfilter: nf_tables: Add __percpu annotation to *stats pointer in nf_tables_updchain() | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 29 this patch: 29
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 8 of 8 maintainers
netdev/build_clang success Errors and warnings before: 29 this patch: 29
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 45 this patch: 42
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 5 this patch: 5
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-08-06--15-00 (tests: 707)

Commit Message

Uros Bizjak Aug. 6, 2024, 10:26 a.m. UTC
Compiling nf_tables_api.c results in several sparse warnings:

nf_tables_api.c:2740:23: warning: incorrect type in assignment (different address spaces)
nf_tables_api.c:2752:38: warning: incorrect type in assignment (different address spaces)
nf_tables_api.c:2798:21: warning: incorrect type in argument 1 (different address spaces)

Add __percpu annotation to *stats pointer to fix these warnings.

Found by GCC's named address space checks.

There were no changes in the resulting object files.

Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: Jozsef Kadlecsik <kadlec@netfilter.org>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
---
 net/netfilter/nf_tables_api.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Simon Horman Aug. 8, 2024, 3:28 p.m. UTC | #1
On Tue, Aug 06, 2024 at 12:26:58PM +0200, Uros Bizjak wrote:
> Compiling nf_tables_api.c results in several sparse warnings:
> 
> nf_tables_api.c:2740:23: warning: incorrect type in assignment (different address spaces)
> nf_tables_api.c:2752:38: warning: incorrect type in assignment (different address spaces)
> nf_tables_api.c:2798:21: warning: incorrect type in argument 1 (different address spaces)
> 
> Add __percpu annotation to *stats pointer to fix these warnings.
> 
> Found by GCC's named address space checks.
> 
> There were no changes in the resulting object files.
> 
> Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
> Cc: Pablo Neira Ayuso <pablo@netfilter.org>
> Cc: Jozsef Kadlecsik <kadlec@netfilter.org>
> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: Eric Dumazet <edumazet@google.com>
> Cc: Jakub Kicinski <kuba@kernel.org>
> Cc: Paolo Abeni <pabeni@redhat.com>
> ---
>  net/netfilter/nf_tables_api.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
> index 481ee78e77bc..805227131f10 100644
> --- a/net/netfilter/nf_tables_api.c
> +++ b/net/netfilter/nf_tables_api.c
> @@ -2642,7 +2642,7 @@ static int nf_tables_updchain(struct nft_ctx *ctx, u8 genmask, u8 policy,
>  	struct nft_table *table = ctx->table;
>  	struct nft_chain *chain = ctx->chain;
>  	struct nft_chain_hook hook = {};
> -	struct nft_stats *stats = NULL;
> +	struct nft_stats __percpu *stats = NULL;
>  	struct nft_hook *h, *next;
>  	struct nf_hook_ops *ops;
>  	struct nft_trans *trans;

Thanks, I agree that users of this local variable expect it
to be annotated as __percpu.

Reviewed-by: Simon Horman <horms@kernel.org>
Pablo Neira Ayuso Aug. 28, 2024, 2:53 p.m. UTC | #2
On Tue, Aug 06, 2024 at 12:26:58PM +0200, Uros Bizjak wrote:
> Compiling nf_tables_api.c results in several sparse warnings:
> 
> nf_tables_api.c:2740:23: warning: incorrect type in assignment (different address spaces)
> nf_tables_api.c:2752:38: warning: incorrect type in assignment (different address spaces)
> nf_tables_api.c:2798:21: warning: incorrect type in argument 1 (different address spaces)
> 
> Add __percpu annotation to *stats pointer to fix these warnings.
> 
> Found by GCC's named address space checks.
> 
> There were no changes in the resulting object files.

I never replied to this.

I can see this is getting things better, but still more sparse
warnings show up related tho nft_stats. I'd prefer those are fixed at
ones, would you give it a look?

> Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
> Cc: Pablo Neira Ayuso <pablo@netfilter.org>
> Cc: Jozsef Kadlecsik <kadlec@netfilter.org>
> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: Eric Dumazet <edumazet@google.com>
> Cc: Jakub Kicinski <kuba@kernel.org>
> Cc: Paolo Abeni <pabeni@redhat.com>
> ---
>  net/netfilter/nf_tables_api.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
> index 481ee78e77bc..805227131f10 100644
> --- a/net/netfilter/nf_tables_api.c
> +++ b/net/netfilter/nf_tables_api.c
> @@ -2642,7 +2642,7 @@ static int nf_tables_updchain(struct nft_ctx *ctx, u8 genmask, u8 policy,
>  	struct nft_table *table = ctx->table;
>  	struct nft_chain *chain = ctx->chain;
>  	struct nft_chain_hook hook = {};
> -	struct nft_stats *stats = NULL;
> +	struct nft_stats __percpu *stats = NULL;
>  	struct nft_hook *h, *next;
>  	struct nf_hook_ops *ops;
>  	struct nft_trans *trans;
> -- 
> 2.45.2
>
Uros Bizjak Aug. 28, 2024, 7:29 p.m. UTC | #3
On Wed, Aug 28, 2024 at 4:53 PM Pablo Neira Ayuso <pablo@netfilter.org> wrote:
>
> On Tue, Aug 06, 2024 at 12:26:58PM +0200, Uros Bizjak wrote:
> > Compiling nf_tables_api.c results in several sparse warnings:
> >
> > nf_tables_api.c:2740:23: warning: incorrect type in assignment (different address spaces)
> > nf_tables_api.c:2752:38: warning: incorrect type in assignment (different address spaces)
> > nf_tables_api.c:2798:21: warning: incorrect type in argument 1 (different address spaces)
> >
> > Add __percpu annotation to *stats pointer to fix these warnings.
> >
> > Found by GCC's named address space checks.
> >
> > There were no changes in the resulting object files.
>
> I never replied to this.
>
> I can see this is getting things better, but still more sparse
> warnings show up related tho nft_stats. I'd prefer those are fixed at
> ones, would you give it a look?

Yes, I have a follow-up patch that also fixes the remaining warnings,
but it depends on a patch [1] that is on the way to mainline through
the mm tree.

I can post the complete patch that uses percpu variants of ERR_PTR,
IS_ERR and PTR_ERR where needed if this dependency can temporarily be
tolerated.

[1] https://lore.kernel.org/lkml/20240818210235.33481-1-ubizjak@gmail.com/

Thanks,
Uros.
Pablo Neira Ayuso Aug. 28, 2024, 9:51 p.m. UTC | #4
On Wed, Aug 28, 2024 at 09:29:14PM +0200, Uros Bizjak wrote:
> On Wed, Aug 28, 2024 at 4:53 PM Pablo Neira Ayuso <pablo@netfilter.org> wrote:
> >
> > On Tue, Aug 06, 2024 at 12:26:58PM +0200, Uros Bizjak wrote:
> > > Compiling nf_tables_api.c results in several sparse warnings:
> > >
> > > nf_tables_api.c:2740:23: warning: incorrect type in assignment (different address spaces)
> > > nf_tables_api.c:2752:38: warning: incorrect type in assignment (different address spaces)
> > > nf_tables_api.c:2798:21: warning: incorrect type in argument 1 (different address spaces)
> > >
> > > Add __percpu annotation to *stats pointer to fix these warnings.
> > >
> > > Found by GCC's named address space checks.
> > >
> > > There were no changes in the resulting object files.
> >
> > I never replied to this.
> >
> > I can see this is getting things better, but still more sparse
> > warnings show up related tho nft_stats. I'd prefer those are fixed at
> > ones, would you give it a look?
> 
> Yes, I have a follow-up patch that also fixes the remaining warnings,
> but it depends on a patch [1] that is on the way to mainline through
> the mm tree.
> 
> I can post the complete patch that uses percpu variants of ERR_PTR,
> IS_ERR and PTR_ERR where needed if this dependency can temporarily be
> tolerated.
> 
> [1] https://lore.kernel.org/lkml/20240818210235.33481-1-ubizjak@gmail.com/

Thanks for explaining.

Post the patch to netfilter-devel@vger.kernel.org explaining the
dependency so it sits there and I remember about it while it gets
upstream.

If there is any issue and this patch does not reach mm tree, let me
know.

Thanks
diff mbox series

Patch

diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index 481ee78e77bc..805227131f10 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -2642,7 +2642,7 @@  static int nf_tables_updchain(struct nft_ctx *ctx, u8 genmask, u8 policy,
 	struct nft_table *table = ctx->table;
 	struct nft_chain *chain = ctx->chain;
 	struct nft_chain_hook hook = {};
-	struct nft_stats *stats = NULL;
+	struct nft_stats __percpu *stats = NULL;
 	struct nft_hook *h, *next;
 	struct nf_hook_ops *ops;
 	struct nft_trans *trans;