Skip to contentSkip to conversation

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

PATCH In review Uros Bizjak 3 participants 5 messages Aug 6, 2024 – Aug 28, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

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

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.

Cc Pablo Neira Ayuso <[email protected]>
Cc Jozsef Kadlecsik <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc Eric Dumazet <[email protected]>
Cc Jakub Kicinski <[email protected]>
Cc Paolo Abeni <[email protected]>
---
 net/netfilter/nf_tables_api.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/nf_tables_api.c +1 -1
index 481ee78e77bc..805227131f10 100644
@@ -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;
Signature · 1 line
2.45.2
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 28 lines · Uros Bizjak

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.

Cc Pablo Neira Ayuso <[email protected]>
Cc Jozsef Kadlecsik <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc Eric Dumazet <[email protected]>
Cc Jakub Kicinski <[email protected]>
Cc Paolo Abeni <[email protected]>
---
 net/netfilter/nf_tables_api.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/nf_tables_api.c +0 -0
index 481ee78e77bc..805227131f10 100644

net/netfilter/nf_tables_api.c static int nf_tables_updchain(struct nft_ctx *ctx, u8 genmask, u8 policy, · line 2648

Quoted 8 lines
net/netfilter/nf_tables_api.c +1 -1
@@ -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.

#2 lore raw
In reply to Uros Bizjak
Quoted 11 lines · Uros Bizjak

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?

Quoted 27 lines
Cc Pablo Neira Ayuso <[email protected]>
Cc Jozsef Kadlecsik <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc Eric Dumazet <[email protected]>
Cc Jakub Kicinski <[email protected]>
Cc Paolo Abeni <[email protected]>
---
 net/netfilter/nf_tables_api.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/nf_tables_api.c +1 -1
index 481ee78e77bc..805227131f10 100644
@@ -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;
Signature · 1 line
2.45.2
#3 lore raw
Quoted 12 lines · Pablo Neira Ayuso
Quoted 10 lines · Uros Bizjak

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.

Quoted 7 lines
Quoted 1 line

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/[email protected]/

Thanks,
Uros.

#4 lore raw
Quoted 25 lines · Uros Bizjak
Quoted 12 lines · Pablo Neira Ayuso
Quoted 10 lines · Uros Bizjak

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.

Quoted 7 lines
Quoted 1 line

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.

Quoted 5 lines

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/[email protected]/

Thanks for explaining.

Post the patch to [email protected] 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