This is a note to let you know that I've just added the patch titled

    net: Add memory barriers to prevent possible race in byte queue limits

to the 3.3-stable tree which can be found at:
    
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     net-add-memory-barriers-to-prevent-possible-race-in-byte-queue-limits.patch
and it can be found in the queue-3.3 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <[email protected]> know about it.


>From c58e988584c4664bc1eb8d5efc70ebf007f51ce3 Mon Sep 17 00:00:00 2001
From: Alexander Duyck <[email protected]>
Date: Tue, 7 Feb 2012 02:29:06 +0000
Subject: net: Add memory barriers to prevent possible race in byte queue limits


From: Alexander Duyck <[email protected]>

[ Upstream commit b37c0fbe3f6dfba1f8ad2aed47fb40578a254635 ]

This change adds a memory barrier to the byte queue limit code to address a
possible race as has been seen in the past with the
netif_stop_queue/netif_wake_queue logic.

Signed-off-by: Alexander Duyck <[email protected]>
Tested-by: Stephen Ko <[email protected]>
Signed-off-by: Jeff Kirsher <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
 include/linux/netdevice.h |   49 ++++++++++++++++++++++++++++++----------------
 1 file changed, 33 insertions(+), 16 deletions(-)

--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1898,12 +1898,22 @@ static inline void netdev_tx_sent_queue(
 {
 #ifdef CONFIG_BQL
        dql_queued(&dev_queue->dql, bytes);
-       if (unlikely(dql_avail(&dev_queue->dql) < 0)) {
-               set_bit(__QUEUE_STATE_STACK_XOFF, &dev_queue->state);
-               if (unlikely(dql_avail(&dev_queue->dql) >= 0))
-                       clear_bit(__QUEUE_STATE_STACK_XOFF,
-                           &dev_queue->state);
-       }
+
+       if (likely(dql_avail(&dev_queue->dql) >= 0))
+               return;
+
+       set_bit(__QUEUE_STATE_STACK_XOFF, &dev_queue->state);
+
+       /*
+        * The XOFF flag must be set before checking the dql_avail below,
+        * because in netdev_tx_completed_queue we update the dql_completed
+        * before checking the XOFF flag.
+        */
+       smp_mb();
+
+       /* check again in case another CPU has just made room avail */
+       if (unlikely(dql_avail(&dev_queue->dql) >= 0))
+               clear_bit(__QUEUE_STATE_STACK_XOFF, &dev_queue->state);
 #endif
 }
 
@@ -1916,16 +1926,23 @@ static inline void netdev_tx_completed_q
                                             unsigned pkts, unsigned bytes)
 {
 #ifdef CONFIG_BQL
-       if (likely(bytes)) {
-               dql_completed(&dev_queue->dql, bytes);
-               if (unlikely(test_bit(__QUEUE_STATE_STACK_XOFF,
-                   &dev_queue->state) &&
-                   dql_avail(&dev_queue->dql) >= 0)) {
-                       if (test_and_clear_bit(__QUEUE_STATE_STACK_XOFF,
-                            &dev_queue->state))
-                               netif_schedule_queue(dev_queue);
-               }
-       }
+       if (unlikely(!bytes))
+               return;
+
+       dql_completed(&dev_queue->dql, bytes);
+
+       /*
+        * Without the memory barrier there is a small possiblity that
+        * netdev_tx_sent_queue will miss the update and cause the queue to
+        * be stopped forever
+        */
+       smp_mb();
+
+       if (dql_avail(&dev_queue->dql) < 0)
+               return;
+
+       if (test_and_clear_bit(__QUEUE_STATE_STACK_XOFF, &dev_queue->state))
+               netif_schedule_queue(dev_queue);
 #endif
 }
 


Patches currently in stable-queue which might be from 
[email protected] are

queue-3.3/net-add-memory-barriers-to-prevent-possible-race-in-byte-queue-limits.patch
queue-3.3/net-fix-issue-with-netdev_tx_reset_queue-not-resetting-queue-from-xoff-state.patch
--
To unsubscribe from this list: send the line "unsubscribe stable" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to