From: Jay Vosburgh <jay.vosburgh@canonical.com>
To: Eric Dumazet <edumazet@google.com>
Cc: "David S . Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Antoine Tenart <atenart@kernel.org>,
netdev@vger.kernel.org, eric.dumazet@gmail.com,
Andy Gospodarek <andy@greyhouse.net>
Subject: Re: [PATCH v2 net-next 05/16] bonding: use exit_batch_rtnl() method
Date: Fri, 02 Feb 2024 11:34:15 -0800 [thread overview]
Message-ID: <30339.1706902455@famine> (raw)
In-Reply-To: <20240202174001.3328528-6-edumazet@google.com>
Eric Dumazet <edumazet@google.com> wrote:
>exit_batch_rtnl() is called while RTNL is held,
>and devices to be unregistered can be queued in the dev_kill_list.
>
>This saves one rtnl_lock()/rtnl_unlock() pair,
>and one unregister_netdevice_many() call.
>
>v2: Added bond_net_pre_exit() method to make sure bond_destroy_sysfs()
> is called before we unregister the devices in bond_net_exit_batch_rtnl
>
>Signed-off-by: Eric Dumazet <edumazet@google.com>
>Link: https://lore.kernel.org/netdev/170688415193.5216.10499830272732622816@kwain/
>Cc: Antoine Tenart <atenart@kernel.org>
>Cc: Jay Vosburgh <j.vosburgh@gmail.com>
>Cc: Andy Gospodarek <andy@greyhouse.net>
Acked-by: Jay Vosburgh <jay.vosburgh@canonical.com>
>---
> drivers/net/bonding/bond_main.c | 37 +++++++++++++++++++++++----------
> 1 file changed, 26 insertions(+), 11 deletions(-)
>
>diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
>index 4e0600c7b050f21c82a8862e224bb055e95d5039..a5e3d000ebd85c09beba379a2e6a7f69a0fd4c88 100644
>--- a/drivers/net/bonding/bond_main.c
>+++ b/drivers/net/bonding/bond_main.c
>@@ -6415,28 +6415,41 @@ static int __net_init bond_net_init(struct net *net)
> return 0;
> }
>
>-static void __net_exit bond_net_exit_batch(struct list_head *net_list)
>+/* According to commit 69b0216ac255 ("bonding: fix bonding_masters
>+ * race condition in bond unloading") we need to remove sysfs files
>+ * before we remove our devices (done later in bond_net_exit_batch_rtnl())
>+ */
>+static void __net_exit bond_net_pre_exit(struct net *net)
>+{
>+ struct bond_net *bn = net_generic(net, bond_net_id);
>+
>+ bond_destroy_sysfs(bn);
>+}
>+
>+static void __net_exit bond_net_exit_batch_rtnl(struct list_head *net_list,
>+ struct list_head *dev_kill_list)
> {
> struct bond_net *bn;
> struct net *net;
>- LIST_HEAD(list);
>-
>- list_for_each_entry(net, net_list, exit_list) {
>- bn = net_generic(net, bond_net_id);
>- bond_destroy_sysfs(bn);
>- }
>
> /* Kill off any bonds created after unregistering bond rtnl ops */
>- rtnl_lock();
> list_for_each_entry(net, net_list, exit_list) {
> struct bonding *bond, *tmp_bond;
>
> bn = net_generic(net, bond_net_id);
> list_for_each_entry_safe(bond, tmp_bond, &bn->dev_list, bond_list)
>- unregister_netdevice_queue(bond->dev, &list);
>+ unregister_netdevice_queue(bond->dev, dev_kill_list);
> }
>- unregister_netdevice_many(&list);
>- rtnl_unlock();
>+}
>+
>+/* According to commit 23fa5c2caae0 ("bonding: destroy proc directory
>+ * only after all bonds are gone") bond_destroy_proc_dir() is called
>+ * after bond_net_exit_batch_rtnl() has completed.
>+ */
>+static void __net_exit bond_net_exit_batch(struct list_head *net_list)
>+{
>+ struct bond_net *bn;
>+ struct net *net;
>
> list_for_each_entry(net, net_list, exit_list) {
> bn = net_generic(net, bond_net_id);
>@@ -6446,6 +6459,8 @@ static void __net_exit bond_net_exit_batch(struct list_head *net_list)
>
> static struct pernet_operations bond_net_ops = {
> .init = bond_net_init,
>+ .pre_exit = bond_net_pre_exit,
>+ .exit_batch_rtnl = bond_net_exit_batch_rtnl,
> .exit_batch = bond_net_exit_batch,
> .id = &bond_net_id,
> .size = sizeof(struct bond_net),
>--
>2.43.0.594.gd9cf4e227d-goog
>
>
next prev parent reply other threads:[~2024-02-02 19:34 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-02 17:39 [PATCH v2 net-next 00/16] net: more factorization in cleanup_net() paths Eric Dumazet
2024-02-02 17:39 ` [PATCH v2 net-next 01/16] net: add exit_batch_rtnl() method Eric Dumazet
2024-02-02 17:39 ` [PATCH v2 net-next 02/16] nexthop: convert nexthop_net_exit_batch to exit_batch_rtnl method Eric Dumazet
2024-02-02 17:39 ` [PATCH v2 net-next 03/16] net: convert default_device_exit_batch() " Eric Dumazet
2024-02-02 17:39 ` [PATCH v2 net-next 04/16] bareudp: use exit_batch_rtnl() method Eric Dumazet
2024-02-02 17:39 ` [PATCH v2 net-next 05/16] bonding: " Eric Dumazet
2024-02-02 19:34 ` Jay Vosburgh [this message]
2024-02-02 17:39 ` [PATCH v2 net-next 06/16] geneve: " Eric Dumazet
2024-02-02 17:39 ` [PATCH v2 net-next 07/16] gtp: " Eric Dumazet
2024-02-02 17:39 ` [PATCH v2 net-next 08/16] ipv4: add __unregister_nexthop_notifier() Eric Dumazet
2024-02-02 17:39 ` [PATCH v2 net-next 09/16] vxlan: use exit_batch_rtnl() method Eric Dumazet
2024-02-02 17:39 ` [PATCH v2 net-next 10/16] ip6_gre: " Eric Dumazet
2024-02-02 17:39 ` [PATCH v2 net-next 11/16] ip6_tunnel: " Eric Dumazet
2024-02-02 17:39 ` [PATCH v2 net-next 12/16] ip6_vti: " Eric Dumazet
2024-02-02 17:39 ` [PATCH v2 net-next 13/16] sit: " Eric Dumazet
2024-02-02 17:39 ` [PATCH v2 net-next 14/16] ip_tunnel: " Eric Dumazet
2024-02-02 17:40 ` [PATCH v2 net-next 15/16] bridge: " Eric Dumazet
2024-02-04 5:10 ` Jakub Kicinski
2024-02-04 10:15 ` Eric Dumazet
2024-02-02 17:40 ` [PATCH v2 net-next 16/16] xfrm: interface: " 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=30339.1706902455@famine \
--to=jay.vosburgh@canonical.com \
--cc=andy@greyhouse.net \
--cc=atenart@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=eric.dumazet@gmail.com \
--cc=kuba@kernel.org \
--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