public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Florian Westphal <fw@strlen.de>
To: <netdev@vger.kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, <linux-kernel@vger.kernel.org>,
	sdf@fomichev.me
Subject: [PATCH net 0/2] net: avoid LOCKDEP MAX_LOCK_DEPTH splat
Date: Fri, 10 Oct 2025 15:54:10 +0200	[thread overview]
Message-ID: <20251010135412.22602-1-fw@strlen.de> (raw)

unshare -n bash -c 'for i in $(seq 1 100);do ip link add foo$i type dummy;done'
Gives:

BUG: MAX_LOCK_DEPTH too low!
turning off the locking correctness validator.
depth: 48  max: 48!
48 locks held by kworker/u16:1/69:
 #0: ffff8880010b7148 ((wq_completion)netns){+.+.}-{0:0}, at: process_one_work+0x7ed/0x1350
 #1: ffffc900004a7d40 (net_cleanup_work){+.+.}-{0:0}, at: process_one_work+0xcf3/0x1350
 #2: ffffffff8bc6fbd0 (pernet_ops_rwsem){++++}-{4:4}, at: cleanup_net+0xab/0x7f0
 #3: ffffffff8bc8daa8 (rtnl_mutex){+.+.}-{4:4}, at: default_device_exit_batch+0x7e/0x2e0
 #4: ffff88800b5e9cb0 (&dev_instance_lock_key#3){+.+.}-{4:4}, at: unregister_netdevice_many_notify+0x1056/0x1b00
[..]

Work around this by splitting the list into lockdep-digestable sublists.
This patchset should have no effect whatsoever for non-lockdep builds.

This issue is a problem for me because of a recent test case added
to nftables userspace which will create/destroy 100 dummy net devices,
so when I run the tests on a debug kernel lockdep coverage is now lost.

Alternative suggestions welcome.

I did not yet encounter another code path that would take so many mutexes
in a row, so I don't see a reason to muck with task_struct->held_locks[].

Florian Westphal (2):
  net: core: move unregister_many inner loops to a helper
  net: core: split unregister_netdevice list into smaller chunks

 net/core/dev.c | 89 ++++++++++++++++++++++++++++++++++++--------------
 1 file changed, 65 insertions(+), 24 deletions(-)

-- 
2.49.1

             reply	other threads:[~2025-10-10 13:54 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-10 13:54 Florian Westphal [this message]
2025-10-10 13:54 ` [PATCH net 1/2] net: core: move unregister_many inner loops to a helper Florian Westphal
2025-10-10 13:54 ` [PATCH net 2/2] net: core: split unregister_netdevice list into smaller chunks Florian Westphal
2025-10-10 22:38   ` Stanislav Fomichev
2025-10-11 14:30     ` Florian Westphal

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=20251010135412.22602-1-fw@strlen.de \
    --to=fw@strlen.de \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sdf@fomichev.me \
    /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