[Devel] [PATCH VZ7] net/dst: print stack when we face dst_entry refcount leak

Pavel Tikhomirov ptikhomirov at virtuozzo.com
Mon Jul 21 13:56:28 MSK 2025


This should help finding unbalanced refcount put leading to negative
refcounts, unfreeable dst_entry-es and hanging network namespace
cleanup.

Previously we had messages like this in dmesg:

  dst_release: dst:ffff9d9686fef000 refcnt:-1

But without stack it's hard to guess the root cause.

https://virtuozzo.atlassian.net/browse/PSBM-125709
Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
 net/core/dst.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/core/dst.c b/net/core/dst.c
index e3ddd2d50235..94891b43bddc 100644
--- a/net/core/dst.c
+++ b/net/core/dst.c
@@ -305,9 +305,9 @@ void dst_release(struct dst_entry *dst)
 		unsigned short nocache = dst->flags & DST_NOCACHE;
 
 		newrefcnt = atomic_dec_return(&dst->__refcnt);
-		if (unlikely(newrefcnt < 0))
-			net_warn_ratelimited("%s: dst:%p refcnt:%d\n",
-					     __func__, dst, newrefcnt);
+		WARN_RATELIMIT(unlikely(newrefcnt < 0),
+			       "%s: Refcount leak dst:%p refcnt:%d (please report to PSBM-125709)\n",
+			       __func__, dst, newrefcnt);
 		if (!newrefcnt && unlikely(nocache))
 			call_rcu(&dst->rcu_head, dst_destroy_rcu);
 	}
-- 
2.50.0



More information about the Devel mailing list