inet: convert to exit_batch_rtnl
Subsystems (3)
cover inet: convert to exit_batch_rtnl
Even if these four modules exit_batch methods do not unregister devices, it is worth converting them to exit_batch_rtnl to save rtnl_lock()/rtnl_unlock() pairs in netns dismantles.
Eric Dumazet (4):
ip6mr: use exit_batch_rtnl method
ipv6: fib6: use exit_batch_rtnl method
ipmr: use exit_batch_rtnl method
ipv4: fib: use exit_batch_rtnl method
net/ipv4/fib_frontend.c | 8 +++----- net/ipv4/ipmr.c | 7 +++---- net/ipv6/fib6_rules.c | 7 +++---- net/ipv6/ip6mr.c | 7 +++---- 4 files changed, 12 insertions(+), 17 deletions(-)
Signature · 1 line
2.43.0.594.gd9cf4e227d-goog
PATCH 1/4 ip6mr: use exit_batch_rtnl method
Using exit_batch_rtnl method instead of exit_batch avoids one rtnl_lock()/rtnl_unlock() pair in netns dismantle.
--- net/ipv6/ip6mr.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
net/ipv6/ip6mr.c +3 -4
@@ -1353,20 +1353,19 @@ static void __net_exit ip6mr_net_exit(struct net *net)ip6mr_notifier_exit (net); } -static void __net_exit ip6mr_net_exit_batch(struct list_head *net_list) +static void __net_exit ip6mr_net_exit_batch_rtnl(struct list_head *net_list, +struct list_head *dev_to_kill) {struct net *net; -rtnl_lock ();list_for_each_entry (net, net_list, exit_list)ip6mr_rules_exit (net); -rtnl_unlock (); }static struct pernet_operations ip6mr_net_ops = { .init = ip6mr_net_init, .exit = ip6mr_net_exit, - .exit_batch = ip6mr_net_exit_batch, + .exit_batch_rtnl = ip6mr_net_exit_batch_rtnl, };int __init ip6_mr_init (void )
Signature · 1 line
2.43.0.594.gd9cf4e227d-goog
PATCH 2/4 ipv6: fib6: use exit_batch_rtnl method
In reply to Eric DumazetUsing exit_batch_rtnl method instead of exit_batch avoids one rtnl_lock()/rtnl_unlock() pair in netns dismantle.
--- net/ipv6/fib6_rules.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
net/ipv6/fib6_rules.c +3 -4
@@ -493,21 +493,20 @@ static int __net_init fib6_rules_net_init(struct net *net) goto out; } -static void __net_exit fib6_rules_net_exit_batch(struct list_head *net_list) +static void __net_exit fib6_rules_exit_batch_rtnl(struct list_head *net_list, +struct list_head *dev_to_kill) {struct net *net; -rtnl_lock ();list_for_each_entry (net, net_list, exit_list) {fib_rules_unregister (net->ipv6.fib6_rules_ops);cond_resched (); } -rtnl_unlock (); }static struct pernet_operations fib6_rules_net_ops = { .init = fib6_rules_net_init, - .exit_batch = fib6_rules_net_exit_batch, + .exit_batch_rtnl = fib6_rules_exit_batch_rtnl, };int __init fib6_rules_init (void )
Signature · 1 line
2.43.0.594.gd9cf4e227d-goog
PATCH 3/4 ipmr: use exit_batch_rtnl method
In reply to Eric DumazetUsing exit_batch_rtnl method instead of exit_batch avoids one rtnl_lock()/rtnl_unlock() pair in netns dismantle.
--- net/ipv4/ipmr.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
net/ipv4/ipmr.c +3 -4
@@ -3119,20 +3119,19 @@ static void __net_exit ipmr_net_exit(struct net *net)ipmr_notifier_exit (net); } -static void __net_exit ipmr_net_exit_batch(struct list_head *net_list) +static void __net_exit ipmr_exit_batch_rtnl(struct list_head *net_list, +struct list_head *dev_to_kill) {struct net *net; -rtnl_lock ();list_for_each_entry (net, net_list, exit_list)ipmr_rules_exit (net); -rtnl_unlock (); }static struct pernet_operations ipmr_net_ops = { .init = ipmr_net_init, .exit = ipmr_net_exit, - .exit_batch = ipmr_net_exit_batch, + .exit_batch = ipmr_exit_batch_rtnl, };int __init ip_mr_init (void )
Signature · 1 line
2.43.0.594.gd9cf4e227d-goog
Re: [PATCH net-next 3/4] ipmr: use exit_batch_rtnl method
Quoted 11 lines · Eric Dumazet
Using
exit_batch_rtnlmethod instead ofexit_batchavoids one rtnl_lock()/rtnl_unlock() pair in netns dismantle.static struct
pernet_operationsipmr_net_ops= {
.init =ipmr_net_init,
.exit =ipmr_net_exit,
net/ipv4/ipmr.c static void __net_exit ipmr_net_exit(struct net *net) · line 3135
Quoted 3 lines
net/ipv4/ipmr.c +1
-1- .exit_batch = ipmr_net_exit_batch, + .exit_batch = ipmr_exit_batch_rtnl, };
Oh well, I thought I fixed this error, I must have missed a step.
kernel test robot
build botRe: [PATCH net-next 3/4] ipmr: use exit_batch_rtnl method
In reply to Eric Dumazetkernel test robot noticed the following build errors:
Hi Eric,
kernel test robot noticed the following build errors:
[auto build test ERROR on net-next/main]
url: https://github.com/intel-lab-lkp/linux/commits/Eric-Dumazet/ip6mr-use-exit_batch_rtnl-method/20240208-192057 base: net-next/main patch link: https://lore.kernel.org/r/20240208111646.535705-4-edumazet%40google.com patch subject: [PATCH net-next 3/4] ipmr: use exit_batch_rtnl method config: x86_64-defconfig (https://download.01.org/0day-ci/archive/20240209/[email protected]/config) compiler: gcc-11 (Debian 11.3.0-12) 11.3.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240209/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
>> net/ipv4/ipmr.c:3134:23: error: initialization of 'void (*)(struct list_head *)' from incompatible pointer type 'void (*)(struct list_head *, struct list_head *)' [-Werror=incompatible-pointer-types]
3134 | .exit_batch = ipmr_exit_batch_rtnl,
| ^~~~~~~~~~~~~~~~~~~~
net/ipv4/ipmr.c:3134:23: note: (near initialization for 'ipmr_net_ops.exit_batch')
cc1: some warnings being treated as errors
vim +3134 net/ipv4/ipmr.c
3130
3131 static struct pernet_operations ipmr_net_ops = {
3132 .init = ipmr_net_init,
3133 .exit = ipmr_net_exit,
> 3134 .exit_batch = ipmr_exit_batch_rtnl,
3135 };
3136
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botRe: [PATCH net-next 3/4] ipmr: use exit_batch_rtnl method
In reply to Eric Dumazetkernel test robot noticed the following build errors:
Hi Eric,
kernel test robot noticed the following build errors:
[auto build test ERROR on net-next/main]
url: https://github.com/intel-lab-lkp/linux/commits/Eric-Dumazet/ip6mr-use-exit_batch_rtnl-method/20240208-192057 base: net-next/main patch link: https://lore.kernel.org/r/20240208111646.535705-4-edumazet%40google.com patch subject: [PATCH net-next 3/4] ipmr: use exit_batch_rtnl method config: x86_64-rhel-8.3-rust (https://download.01.org/0day-ci/archive/20240209/[email protected]/config) compiler: clang version 17.0.6 (https://github.com/llvm/llvm-project 6009708b4367171ccdbf4b5905cb6a803753fe18) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240209/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
>> net/ipv4/ipmr.c:3134:16: error: incompatible function pointer types initializing 'void (*)(struct list_head *)' with an expression of type 'void (struct list_head *, struct list_head *)' [-Wincompatible-function-pointer-types]
3134 | .exit_batch = ipmr_exit_batch_rtnl,
| ^~~~~~~~~~~~~~~~~~~~
1 error generated.
vim +3134 net/ipv4/ipmr.c
3130
3131 static struct pernet_operations ipmr_net_ops = {
3132 .init = ipmr_net_init,
3133 .exit = ipmr_net_exit,
> 3134 .exit_batch = ipmr_exit_batch_rtnl,
3135 };
3136
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
PATCH 4/4 ipv4: fib: use exit_batch_rtnl method
In reply to Eric DumazetUsing exit_batch_rtnl method instead of exit_batch avoids one rtnl_lock()/rtnl_unlock() pair in netns dismantle.
--- net/ipv4/fib_frontend.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
net/ipv4/fib_frontend.c +3 -5
@@ -1631,21 +1631,19 @@ static void __net_exit fib_net_exit(struct net *net)nl_fib_lookup_exit (net); } -static void __net_exit fib_net_exit_batch(struct list_head *net_list) +static void __net_exit fib_net_exit_batch_rtnl(struct list_head *net_list, +struct list_head *dev_to_kill) {struct net *net; -rtnl_lock ();list_for_each_entry (net, net_list, exit_list)ip_fib_net_exit (net); - -rtnl_unlock (); }static struct pernet_operations fib_net_ops = { .init = fib_net_init, .exit = fib_net_exit, - .exit_batch = fib_net_exit_batch, + .exit_batch_rtnl = fib_net_exit_batch_rtnl, };void __init ip_fib_init (void )
Signature · 1 line
2.43.0.594.gd9cf4e227d-goog
Quoted 5 lines · Eric Dumazet
Even if these four modules
exit_batchmethods do not unregister devices, it is worth converting them toexit_batch_rtnlto save rtnl_lock()/rtnl_unlock() pairs in netns dismantles.
Please ignore the whole series, more work is needed.