diff options
author | Eric Dumazet <edumazet@google.com> | 2022-02-04 14:42:36 -0800 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2022-02-05 15:22:44 +0000 |
commit | 8fd5522f44dcd7f05454ddc4f16d0f821b676cd9 (patch) | |
tree | b9899897b9d8687f629833d4ac7d58a3f9239f22 /lib/ref_tracker.c | |
parent | e3ececfe668facd87d920b608349a32607060e66 (diff) | |
download | linux-stable-8fd5522f44dcd7f05454ddc4f16d0f821b676cd9.tar.gz linux-stable-8fd5522f44dcd7f05454ddc4f16d0f821b676cd9.tar.bz2 linux-stable-8fd5522f44dcd7f05454ddc4f16d0f821b676cd9.zip |
ref_tracker: add a count of untracked references
We are still chasing a netdev refcount imbalance, and we suspect
we have one rogue dev_put() that is consuming a reference taken
from a dev_hold_track()
To detect this case, allow ref_tracker_alloc() and ref_tracker_free()
to be called with a NULL @trackerp parameter, and use a dedicated
refcount_t just for them.
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'lib/ref_tracker.c')
-rw-r--r-- | lib/ref_tracker.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/ref_tracker.c b/lib/ref_tracker.c index 32ff6bd497f8..9c0c2e09df66 100644 --- a/lib/ref_tracker.c +++ b/lib/ref_tracker.c @@ -38,6 +38,7 @@ void ref_tracker_dir_exit(struct ref_tracker_dir *dir) spin_unlock_irqrestore(&dir->lock, flags); WARN_ON_ONCE(leak); WARN_ON_ONCE(refcount_read(&dir->untracked) != 1); + WARN_ON_ONCE(refcount_read(&dir->no_tracker) != 1); } EXPORT_SYMBOL(ref_tracker_dir_exit); @@ -75,6 +76,10 @@ int ref_tracker_alloc(struct ref_tracker_dir *dir, WARN_ON_ONCE(dir->dead); + if (!trackerp) { + refcount_inc(&dir->no_tracker); + return 0; + } if (gfp & __GFP_DIRECT_RECLAIM) gfp_mask |= __GFP_NOFAIL; *trackerp = tracker = kzalloc(sizeof(*tracker), gfp_mask); @@ -98,13 +103,18 @@ int ref_tracker_free(struct ref_tracker_dir *dir, struct ref_tracker **trackerp) { unsigned long entries[REF_TRACKER_STACK_ENTRIES]; - struct ref_tracker *tracker = *trackerp; depot_stack_handle_t stack_handle; + struct ref_tracker *tracker; unsigned int nr_entries; unsigned long flags; WARN_ON_ONCE(dir->dead); + if (!trackerp) { + refcount_dec(&dir->no_tracker); + return 0; + } + tracker = *trackerp; if (!tracker) { refcount_dec(&dir->untracked); return -EEXIST; |