Merge branch 'for-linus' of git://git390.marist.edu/pub/scm/linux-2.6
[firefly-linux-kernel-4.4.55.git] / net / core / dst.c
index 09c1530f46814d287929a37ce948885d44f8bb03..cb1b3488b739837fcff71c10d36694f2ea3ab393 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/string.h>
 #include <linux/types.h>
 #include <net/net_namespace.h>
+#include <linux/sched.h>
 
 #include <net/dst.h>
 
@@ -79,6 +80,7 @@ loop:
        while ((dst = next) != NULL) {
                next = dst->next;
                prefetch(&next->next);
+               cond_resched();
                if (likely(atomic_read(&dst->__refcnt))) {
                        last->next = dst;
                        last = dst;
@@ -263,9 +265,11 @@ again:
 void dst_release(struct dst_entry *dst)
 {
        if (dst) {
-               WARN_ON(atomic_read(&dst->__refcnt) < 1);
+               int newrefcnt;
+
                smp_mb__before_atomic_dec();
-               atomic_dec(&dst->__refcnt);
+               newrefcnt = atomic_dec_return(&dst->__refcnt);
+               WARN_ON(newrefcnt < 0);
        }
 }
 EXPORT_SYMBOL(dst_release);