Skip to contentSkip to conversation

net: stop endless flood about dst entry refcount underflow or overflow

PATCH Superseded Konstantin Khlebnikov 3 participants 5 messages Jul 14, 2015

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: stop endless flood about dst entry refcount underflow or overflow

Kernel generates a lot of warnings when dst entry reference counter overflows and becomes negative. This patch prints address of dst entry, its refcount and then resets reference counter to INT_MAX/2.

That bug was seen several times at machines with outdated 3.10.y kernels. Most like it's already fixed in upstream. Anyway flood of that warnings completely kills machine and makes further debugging impossible.

---
 net/core/dst.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/core/dst.c +2 -1
index e956ce6d1378..2ed91082b3cf 100644
@@ -284,7 +284,8 @@ void dst_release(struct dst_entry *dst)
 		int newrefcnt;
 
 		newrefcnt = atomic_dec_return(&dst->__refcnt);
-		WARN_ON(newrefcnt < 0);
+		if (WARN(newrefcnt < 0, "dst: %p refcnt: %d\n", dst, newrefcnt))
+			atomic_set(&dst->__refcnt, INT_MAX / 2);
 		if (unlikely(dst->flags & DST_NOCACHE) && !newrefcnt)
 			call_rcu(&dst->rcu_head, dst_destroy_rcu);
 	}
#1 lore raw
Quoted 18 lines · Konstantin Khlebnikov

Kernel generates a lot of warnings when dst entry reference counter overflows and becomes negative. This patch prints address of dst entry, its refcount and then resets reference counter to INT_MAX/2.

That bug was seen several times at machines with outdated 3.10.y kernels. Most like it's already fixed in upstream. Anyway flood of that warnings completely kills machine and makes further debugging impossible.

---
 net/core/dst.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/core/dst.c +0 -0
index e956ce6d1378..2ed91082b3cf 100644

net/core/dst.c void dst_release(struct dst_entry *dst) · line 291

Quoted 9 lines
net/core/dst.c +2 -1
@@ -284,7 +284,8 @@ void dst_release(struct dst_entry *dst)
 		int newrefcnt;
 
 		newrefcnt = atomic_dec_return(&dst->__refcnt);
-		WARN_ON(newrefcnt < 0);
+		if (WARN(newrefcnt < 0, "dst: %p refcnt: %d\n", dst, newrefcnt))
+			atomic_set(&dst->__refcnt, INT_MAX / 2);
 		if (unlikely(dst->flags & DST_NOCACHE) && !newrefcnt)
 			call_rcu(&dst->rcu_head, dst_destroy_rcu);
 	}

WARN_ON_ONCE() if you want, but setting __refcnt like this is absolutely a dirty hack.

#2 lore raw
Quoted 21 lines · Eric Dumazet
Quoted 20 lines · Konstantin Khlebnikov

Kernel generates a lot of warnings when dst entry reference counter overflows and becomes negative. This patch prints address of dst entry, its refcount and then resets reference counter to INT_MAX/2.

That bug was seen several times at machines with outdated 3.10.y kernels. Most like it's already fixed in upstream. Anyway flood of that warnings completely kills machine and makes further debugging impossible.

---
  net/core/dst.c |    3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
net/core/dst.c +0 -0
index e956ce6d1378..2ed91082b3cf 100644
@@ -284,7 +284,8 @@ void dst_release(struct dst_entry *dst)
  		int newrefcnt;
 
Quoted 11 lines

net/core/dst.c void dst_release(struct dst_entry *dst) · line 291

Quoted 7 lines
net/core/dst.c +2 -1
  		newrefcnt = atomic_dec_return(&dst->__refcnt);
-		WARN_ON(newrefcnt < 0);
+		if (WARN(newrefcnt < 0, "dst: %p refcnt: %d\n", dst, newrefcnt))
+			atomic_set(&dst->__refcnt, INT_MAX / 2);
  		if (unlikely(dst->flags & DST_NOCACHE) && !newrefcnt)
  			call_rcu(&dst->rcu_head, dst_destroy_rcu);
  	}

WARN_ON_ONCE() if you want, but setting __refcnt like this is absolutely a dirty hack.

Simple warn-once will hide a lot of information which could be useful. Also dst entry leak is better than freeing actually active entry.

Quoted 3 lines
Signature · 1 line
Konstantin
#3 lore raw
Quoted 2 lines · Konstantin Khlebnikov

Simple warn-once will hide a lot of information which could be useful. Also dst entry leak is better than freeing actually active entry.

Then BUG_ON() .

Really, we need to fix leaks, not brown paper them.

maintainer
#4 lore raw

From: Eric Dumazet <[email protected]>
Date: Tue, 14 Jul 2015 14:26:07 +0200

Quoted 8 lines · Konstantin Khlebnikov
Quoted 3 lines

Simple warn-once will hide a lot of information which could be useful. Also dst entry leak is better than freeing actually active entry.

Then BUG_ON() .

Really, we need to fix leaks, not brown paper them.

No, killing the machine is not the answer.

If you want to rate limit this message, do it on a per-device basis, but without corrupting the netdev state in the process.