# Re: \[PATCH v3\] net: track raw dev\_put()/dev\_hold() usage under CONFIG\_NET\_DEV\_REFCNT\_TRACKER=y

- From: Kuniyuki Iwashima \<kuniyu@google.com\>
- Date: 2026-09-15 16:09:27 
- List: netdev
- Page: https://ratatoskr.run/netdev/2026/09/17580833
- Thread: https://ratatoskr.run/netdev/2026/08/17478075/t.md

```text
From: Aleksandr Nogikh <redacted>
Date: Mon, 14 Sep 2026 20:48:52 +0200
> On Mon, Sep 14, 2026 at 1:44 PM Eric Dumazet [ref] wrote:
> >
> > On Mon, Sep 14, 2026 at 3:24 AM Tetsuo Handa
> > [ref] wrote:
> > >
> > > On 2026/08/29 23:58, Tetsuo Handa wrote:> syzbot is still reporting
> > > >
> > > >   unregister_netdevice: waiting for DEV to become free
> > > >
> > > > problems. There is netdevice_tracker which helps identifying culprit
> > > (...snipped...)
> > > > ---
> > > > To: Eric
> > > >   Please see off-list mail [ref] .
> > > >
> > > > Changes in v3:
> > > >   - Repost as v3, as sashiko's review comments at
> > > >     https://sashiko.dev/#/patchset/56c707e7-1fb0-43ec-b8fb-cf6f451e513e@I-love.SAKURA.ne.jp
> > > >     was addressed. I assume that no more technical problem remains, and only how to split
> > > >     this patch into several patches for getting approval from relevant subsystems remains.
> > > >
> > >
> > > Sashiko did not find problems with this version
> > > ( https://sashiko.dev/#/patchset/271af679-34c1-4f7e-875c-4761c22595eb@I-love.SAKURA.ne.jp ) .
> > > Any questions?
> >
> > I am adding Dmitry and Aleksandr to Cc, because I think the best answer
> > to your problem is not a netdev one. More on this below.
> >
> > First, sorry for letting this series sit for three rounds. You are one
> > of the very few people actually chasing the "unregister_netdevice:
> > waiting for %s to become free" reports, that work is not fun, and
> > silence is not the answer you deserved.
> >
> > Let me also say clearly that I do not think the approach is bogus. Once
> > a reference is taken without a tracker, there is no slot to store a
> > cookie in, so counting +1/-1 per unique stack and looking at the balance
> > is essentially the only thing one can do. And 10 bugs fixed is more
> > evidence than most debug facilities come with.
> >
> > My problem is the cost/benefit for mainline. This adds a field to
> > struct net_device and code to __dev_hold()/__dev_put(), which are inline
> > and expanded in thousands of places, in order to produce information
> > that is strictly weaker than what ref_tracker already gives us (a stack
> > balance cannot tell which hold was not released when the same call site
> > does both). It is a workaround for an incomplete migration, and we would
> > be carrying it forever. Even with a perfect implementation I would be
> > lukewarm, and I would rather tell you that now than stay silent again.
> >
> > But you should not have to wait for netdev consensus to get the data you
> > need, so:
> >
> > Could syzbot run a dedicated instance on a branch carrying this patch?
> >
> > There is precedent: KMSAN lived out of tree for years with its own
> > syzbot instance, and that is exactly how it accumulated the evidence
> > that got it merged. Your real requirement, as I understand it, is not
> > "this must be in net-next", it is "the mechanism must be present in a
> > tree that syzbot builds", because the remaining bugs have no reproducer
> > and #syz test is therefore unavailable. A dedicated instance on, say,
> > linux-next plus your patch would give you continuous coverage on exactly
> > the bugs you cannot reproduce, immediately, and without anyone having to
> > agree first.
> 
> Normally, syzbot fuzzes kernel changes across different environments
> (qemu, various gce machines) and architectures (amd64, arm64, riscv),
> but adding just one dedicated instance, which would get much less
> compute than the rest of the syzbot fleet, IMO offers very little
> benefit over just casually running syzkaller locally.
> 
> How to organize this is also an interesting question. Applying the
> patch on the syzbot side would make syzbot show non-existent commit
> hashes in the reports. If there's to be a separate branch/tree that we
> would fuzz, it really must not lag too far behind linux-next/torvalds
> - the community is very annoyed by outdated reports.
> 
> Speaking of the absence of reproducers, I think we should start by
> cleaning up the existing open bug:
> https://syzkaller.appspot.com/bug?extid=e2af46126e0644cbebdd
> 
> Currently, it is an umbrella for many different crashes accumulated
> over many months. It also has some reproducers; some were even found
> recently. If we keep closing this bug after fixing the root causes
> found by the open reproducers, syzbot will keep on discovering and
> reporting new ones even without an extra debugging patch.
> 
> A small related question: should we report it per-device type, like
> `unregister_netdevice: waiting for netdevsimNUM to become free`,

+1

I think this is the major reason why we slowed down netdev_hold()/put()
conversion at some point.

After Eric converted the core code and first-class drivers, I remember
I always saw the reports were dominated by can and vcan, which we
usually don't care much, and I gave up finding an interesting one.


> or
> would that only create duplicates, and it's better to keep everything
> in one bucket?
> 
> >
> > It is not free for you: you would own the branch and the rebases. But it
> > also turns the discussion around. If the instance produces a stream of
> > diagnosed imbalances over a few months, the case for upstreaming becomes
> > an empirical one rather than a design argument, and I would find it much
> > harder to object to.
> >
> > Dmitry, Aleksandr, does that sound feasible?
> 
> Tetsuo, based on historical experience, how many issues do you expect
> to detect this way?
> 
> I can imagine setting this up as a short-term experiment, but I still
> wonder about the benefits of having it specifically on the syzbot
> infrastructure.
> 
> >
> > If you would rather still pursue mainline inclusion, here is what I
> > would need, roughly in order of importance:
> >
> > 1) The per-call list walk has to go. Today every __dev_hold() /
> >    __dev_put() walks a per-device list doing memcmp() of up to 160 bytes
> >    per node. With a few thousand distinct traces on a device, that is
> >    hundreds of KB of memory traffic per refcount operation, and it gets
> >    worse precisely on the devices you are investigating. I suspect it
> >    costs much more than the stack_trace_save() itself. stack_depot_save()
> >    gives you a handle, and a small hash of { handle -> atomic count }
> >    makes this O(1), removes the 6 MiB static array, the global raw
> >    spinlock, the sticky "exhausted" flag and the dedup pass at dump time.
> >    Ideally this lives in lib/ref_tracker.c as a "count only" mode, so
> >    other ref_tracker users benefit and net/core/dev.c gains a few lines.
> 
> FWIW there were any stack traces in the reports at all, syzbot's AI
> repro generation (which we are piloting now) would already be able to
> kick in and generate reproducers even if syzkaller fails.
> 
> >
> > 2) Do not overload CONFIG_NET_DEV_REFCNT_TRACKER. People enable it today
> >    expecting the cost of one stackdepot entry per tracked reference. A
> >    separate option (default n, depends on DEBUG_KERNEL), ideally behind a
> >    static key, lets them opt in knowingly. Some numbers on the slowdown
> >    would help too.
> 
> Upstreaming it under some separate option would be the best approach
> for syzbot - we could then just enable it on all our instances.
```
