netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, edumazet@google.com,
	lucien.xin@gmail.com, Jakub Kicinski <kuba@kernel.org>
Subject: [PATCH net-next 1/2] net: transition netdev reg state earlier in run_todo
Date: Tue, 15 Feb 2022 14:53:09 -0800	[thread overview]
Message-ID: <20220215225310.3679266-1-kuba@kernel.org> (raw)

In prep for unregistering netdevs out of order move the netdev
state validation and change outside of the loop.

While at it modernize this code and use WARN() instead of
pr_err() + dump_stack().

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 net/core/dev.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/net/core/dev.c b/net/core/dev.c
index 909fb3815910..2749776e2dd2 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -9906,6 +9906,7 @@ static void netdev_wait_allrefs(struct net_device *dev)
  */
 void netdev_run_todo(void)
 {
+	struct net_device *dev, *tmp;
 	struct list_head list;
 #ifdef CONFIG_LOCKDEP
 	struct list_head unlink_list;
@@ -9926,24 +9927,23 @@ void netdev_run_todo(void)
 
 	__rtnl_unlock();
 
-
 	/* Wait for rcu callbacks to finish before next phase */
 	if (!list_empty(&list))
 		rcu_barrier();
 
-	while (!list_empty(&list)) {
-		struct net_device *dev
-			= list_first_entry(&list, struct net_device, todo_list);
-		list_del(&dev->todo_list);
-
+	list_for_each_entry_safe(dev, tmp, &list, todo_list) {
 		if (unlikely(dev->reg_state != NETREG_UNREGISTERING)) {
-			pr_err("network todo '%s' but state %d\n",
-			       dev->name, dev->reg_state);
-			dump_stack();
+			netdev_WARN(dev, "run_todo but not unregistering\n");
+			list_del(&dev->todo_list);
 			continue;
 		}
 
 		dev->reg_state = NETREG_UNREGISTERED;
+	}
+
+	while (!list_empty(&list)) {
+		dev = list_first_entry(&list, struct net_device, todo_list);
+		list_del(&dev->todo_list);
 
 		netdev_wait_allrefs(dev);
 
-- 
2.34.1


             reply	other threads:[~2022-02-15 22:53 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-15 22:53 Jakub Kicinski [this message]
2022-02-15 22:53 ` [PATCH net-next 2/2] net: allow out-of-order netdev unregistration Jakub Kicinski
2022-02-16  0:01   ` Eric Dumazet
2022-02-16  4:13   ` Xin Long
2022-02-18  6:36   ` Eric Dumazet
2022-02-15 23:56 ` [PATCH net-next 1/2] net: transition netdev reg state earlier in run_todo Eric Dumazet
2022-02-16  4:12 ` Xin Long
2022-02-17 16:40 ` 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=20220215225310.3679266-1-kuba@kernel.org \
    --to=kuba@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=lucien.xin@gmail.com \
    --cc=netdev@vger.kernel.org \
    /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).