kernel: update linux 3.3 to 3.3.2
[openwrt.git] / target / linux / generic / patches-3.3 / 120-ppp_txqueue_restart.patch
1 commit 9a5d2bd99e0dfe9a31b3c160073ac445ba3d773f
2 Author: David Woodhouse <dwmw2@infradead.org>
3 Date:   Sun Apr 8 10:01:44 2012 +0000
4
5     ppp: Fix race condition with queue start/stop
6     
7     Commit e675f0cc9a872fd152edc0c77acfed19bf28b81e ("ppp: Don't stop and
8     restart queue on every TX packet") introduced a race condition which
9     could leave the net queue stopped even when the channel is no longer
10     busy. By calling netif_stop_queue() from ppp_start_xmit(), based on the
11     return value from ppp_xmit_process() but *after* all the locks have been
12     dropped, we could potentially do so *after* the channel has actually
13     finished transmitting and attempted to re-wake the queue.
14     
15     Fix this by moving the netif_stop_queue() into ppp_xmit_process() under
16     the xmit lock. I hadn't done this previously, because it gets called
17     from other places than ppp_start_xmit(). But I now think it's the better
18     option. The net queue *should* be stopped if the channel becomes
19     congested due to writes from pppd, anyway.
20     
21     Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
22     Signed-off-by: David S. Miller <davem@davemloft.net>
23
24 commit e675f0cc9a872fd152edc0c77acfed19bf28b81e
25 Author: David Woodhouse <dwmw2@infradead.org>
26 Date:   Mon Mar 26 00:03:42 2012 +0000
27
28     ppp: Don't stop and restart queue on every TX packet
29     
30     For every transmitted packet, ppp_start_xmit() will stop the netdev
31     queue and then, if appropriate, restart it. This causes the TX softirq
32     to run, entirely gratuitously.
33     
34     This is "only" a waste of CPU time in the normal case, but it's actively
35     harmful when the PPP device is a TEQL slave — the wakeup will cause the
36     offending device to receive the next TX packet from the TEQL queue, when
37     it *should* have gone to the next slave in the list. We end up seeing
38     large bursts of packets on just *one* slave device, rather than using
39     the full available bandwidth over all slaves.
40     
41     This patch fixes the problem by *not* unconditionally stopping the queue
42     in ppp_start_xmit(). It adds a return value from ppp_xmit_process()
43     which indicates whether the queue should be stopped or not.
44     
45     It *doesn't* remove the call to netif_wake_queue() from
46     ppp_xmit_process(), because other code paths (especially from
47     ppp_output_wakeup()) need it there and it's messy to push it out to the
48     other callers to do it based on the return value. So we leave it in
49     place — it's a no-op in the case where the queue wasn't stopped, so it's
50     harmless in the TX path.
51     
52     Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
53     Signed-off-by: David S. Miller <davem@davemloft.net>
54
55
56
57 --- a/drivers/net/ppp/ppp_generic.c
58 +++ b/drivers/net/ppp/ppp_generic.c
59 @@ -968,7 +968,6 @@ ppp_start_xmit(struct sk_buff *skb, stru
60         proto = npindex_to_proto[npi];
61         put_unaligned_be16(proto, pp);
62  
63 -       netif_stop_queue(dev);
64         skb_queue_tail(&ppp->file.xq, skb);
65         ppp_xmit_process(ppp);
66         return NETDEV_TX_OK;
67 @@ -1063,6 +1062,8 @@ ppp_xmit_process(struct ppp *ppp)
68                    code that we can accept some more. */
69                 if (!ppp->xmit_pending && !skb_peek(&ppp->file.xq))
70                         netif_wake_queue(ppp->dev);
71 +               else
72 +                       netif_stop_queue(ppp->dev);
73         }
74         ppp_xmit_unlock(ppp);
75  }