diff mbox

[net] net: fq_codel: Fix off-by-one error

Message ID 1364514720-20780-1-git-send-email-subramanian.vijay@gmail.com
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Vijay Subramanian March 28, 2013, 11:52 p.m. UTC
Currently, we hold a max of sch->limit -1 number of packets instead of
sch->limit packets. Fix this off-by-one error.

Signed-off-by: Vijay Subramanian <subramanian.vijay@gmail.com>
---
 net/sched/sch_fq_codel.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Eric Dumazet March 29, 2013, 3:01 p.m. UTC | #1
On Thu, 2013-03-28 at 16:52 -0700, Vijay Subramanian wrote:
> Currently, we hold a max of sch->limit -1 number of packets instead of
> sch->limit packets. Fix this off-by-one error.
> 
> Signed-off-by: Vijay Subramanian <subramanian.vijay@gmail.com>
> ---
>  net/sched/sch_fq_codel.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/sched/sch_fq_codel.c b/net/sched/sch_fq_codel.c
> index 4e606fc..5578628 100644
> --- a/net/sched/sch_fq_codel.c
> +++ b/net/sched/sch_fq_codel.c
> @@ -195,7 +195,7 @@ static int fq_codel_enqueue(struct sk_buff *skb, struct Qdisc *sch)
>  		flow->deficit = q->quantum;
>  		flow->dropped = 0;
>  	}
> -	if (++sch->q.qlen < sch->limit)
> +	if (++sch->q.qlen <= sch->limit)
>  		return NET_XMIT_SUCCESS;
>  
>  	q->drop_overlimit++;

Just curious, did you play changing the default limit (10240 packets) ?

Acked-by: Eric Dumazet <edumazet@google.com>

Thanks !


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller March 29, 2013, 7:33 p.m. UTC | #2
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Fri, 29 Mar 2013 08:01:20 -0700

> On Thu, 2013-03-28 at 16:52 -0700, Vijay Subramanian wrote:
>> Currently, we hold a max of sch->limit -1 number of packets instead of
>> sch->limit packets. Fix this off-by-one error.
>> 
>> Signed-off-by: Vijay Subramanian <subramanian.vijay@gmail.com>
 ...
> Acked-by: Eric Dumazet <edumazet@google.com>

Applied and queued up for -stable.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Vijay Subramanian March 29, 2013, 9:49 p.m. UTC | #3
> Just curious, did you play changing the default limit (10240 packets) ?
>
>

Eric,
So far we have not changed the default but we are planning to run some
more tests next week with fq_codel.
We can try different values for limit. If you have any other
suggestions for testing, please let me know.

Thanks!
Vijay
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Markus Trippelsdorf March 30, 2013, 6:53 a.m. UTC | #4
On 2013.03.29 at 08:01 -0700, Eric Dumazet wrote:
> 
> Just curious, did you play changing the default limit (10240 packets) ?

I did some tests on my home router (running OpenWrt trunk) that is rate-
limited with hfsc to the speed of the cable modem.

My tests seem to indicate that lowering the default limit to 1024
packets results in much better latency behavior when using bittorrent.

With the default limit (10240 packets) I would get huge ping latencies
from 600-1200ms when downloading e.g.:
http://download.opensuse.org/distribution/12.3/iso/openSUSE-12.3-DVD-x86_64.iso.torrent
with hundreds of peers.

Setting the limit to 1024 did get the latencies back in check (20-30ms
with occasional spikes of ~100ms).

fq_codel limit 1024:
 Host                                    Loss%   Snt   Last   Avg  Best  Wrst StDev
 1. OpenWrt.lan                           0.0%   179    0.2   0.3   0.2   1.0   0.1
 2. ???
 3. 83-169-179-150-isp.superkabel.de      0.6%   179   13.4  29.3   7.1 214.1  26.1
 4. 88-134-192-0-dynip.superkabel.de      0.6%   179   13.5  28.2   7.8 213.9  26.3
 5. 88-134-196-230-dynip.superkabel.de    1.1%   179   10.7  27.7   7.5 225.6  26.7
 6. 88-134-203-141-dynip.superkabel.de    0.6%   179   18.8  30.4   7.6 216.7  25.2
    88-134-203-10-dynip.superkabel.de
    88-134-203-6-dynip.superkabel.de
    88-134-203-14-dynip.superkabel.de
 7. 88-134-201-5-dynip.superkabel.de      0.6%   179    8.4  37.1   7.5 453.5  50.6
 8. ???
 9. 209.85.249.182                        0.6%   179   11.8  28.5   8.2 185.6  25.4
10. 66.249.95.175                         0.6%   179    9.2  34.5   8.3 263.9  31.3
    66.249.95.67
11. 64.233.174.29                         0.6%   179   13.4  30.6   7.8 297.8  31.7
    216.239.48.53
    64.233.174.55
12. ???
13. google-public-dns-a.google.com        0.0%   178   13.7  29.7   7.6 312.7  33.8

fq_codel limit 10240:
 Host                                    Loss%   Snt   Last   Avg  Best  Wrst StDev
 1. OpenWrt.lan                           0.0%   179    0.5   0.3   0.2   0.8   0.1
 2. ???
 3. 83-169-179-150-isp.superkabel.de      1.1%   179   13.4  98.9   7.6 888.4 170.0
 4. 88-134-192-0-dynip.superkabel.de      1.1%   179   16.8  95.5   8.0 892.5 171.9
 5. 88-134-196-230-dynip.superkabel.d     1.1%   179   12.8  96.2   7.7 913.8 173.8
 6. 88-134-203-6-dynip.superkabel.de      2.2%   179   38.2 105.9   9.5 926.1 175.9
    88-134-203-10-dynip.superkabel.de
    88-134-203-14-dynip.superkabel.de
    88-134-203-141-dynip.superkabel.de
 7. 88-134-201-5-dynip.superkabel.de      1.7%   179   44.0 103.3   8.0 960.6 178.9
 8. ???
 9. 209.85.249.182                        1.7%   179   20.8  98.7   7.7 900.0 176.1
10. 66.249.95.175                         1.7%   179   17.0 100.2   8.1 861.9 174.9
    66.249.95.67
11. 64.233.174.55                         1.7%   179   50.3 102.6   7.7 826.6 171.7
    216.239.48.53
    64.233.174.29
12. ???
13. google-public-dns-a.google.com        1.1%   179   12.5  98.2   8.1 849.8 168.9
Eric Dumazet March 30, 2013, 2:42 p.m. UTC | #5
On Sat, 2013-03-30 at 07:53 +0100, Markus Trippelsdorf wrote:
> On 2013.03.29 at 08:01 -0700, Eric Dumazet wrote:
> > 
> > Just curious, did you play changing the default limit (10240 packets) ?
> 
> I did some tests on my home router (running OpenWrt trunk) that is rate-
> limited with hfsc to the speed of the cable modem.
> 
> My tests seem to indicate that lowering the default limit to 1024
> packets results in much better latency behavior when using bittorrent.
> 
> With the default limit (10240 packets) I would get huge ping latencies
> from 600-1200ms when downloading e.g.:
> http://download.opensuse.org/distribution/12.3/iso/openSUSE-12.3-DVD-x86_64.iso.torrent
> with hundreds of peers.
> 
> Setting the limit to 1024 did get the latencies back in check (20-30ms
> with occasional spikes of ~100ms).

Hi Markus

I am very bored having to explain {fq_}codel principles each time
someone does this kind of experiments.

Codel principle is _allowing_ bursts, as long as the queue is
controlled. Read Codel paper for details. TCP can be slow to lower the
queues, it takes several RTT. So observing large queues is quite normal
in your case.

Bittorent uses its own rate limiting technique, defeating
current cwnd control done in the TCP stack, because of a very known
problem

( http://www.ietf.org/id/draft-ietf-tcpm-newcwv-00.txt )

So if your goal is reducing latencies for a _given_ class of flows, just
use prio + 3 fq_codel,  and classify your packets to make sure your
lovely ping packets are not dropped or behind long packets.

fq_codel by itself is not universal.

My question about fq_codel limit was related to something completely
different.

The default is 10240 packets. The logic behind is to control the queue
at dequeue, not enqueue. But we needed an safety limit to avoid OOM in
case rate of enqueue() is insane.

It could theoretically hurt a low end machine, in case a burst fills the
queue with big GSO packets. But then these low end machines should not
use GRO/TSO anyway (as this is against anti bufferbloat techniques)

Probably a better choice would have been to limit sum(skb->truesize), or
sum(skb->len) (aka current sch->qstats.backlog)



--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Markus Trippelsdorf March 30, 2013, 3:08 p.m. UTC | #6
On 2013.03.30 at 07:42 -0700, Eric Dumazet wrote:
> On Sat, 2013-03-30 at 07:53 +0100, Markus Trippelsdorf wrote:
> > On 2013.03.29 at 08:01 -0700, Eric Dumazet wrote:
> > > 
> > > Just curious, did you play changing the default limit (10240 packets) ?
> > 
> > I did some tests on my home router (running OpenWrt trunk) that is rate-
> > limited with hfsc to the speed of the cable modem.
> > 
> > My tests seem to indicate that lowering the default limit to 1024
> > packets results in much better latency behavior when using bittorrent.
> > 
> > With the default limit (10240 packets) I would get huge ping latencies
> > from 600-1200ms when downloading e.g.:
> > http://download.opensuse.org/distribution/12.3/iso/openSUSE-12.3-DVD-x86_64.iso.torrent
> > with hundreds of peers.
> > 
> > Setting the limit to 1024 did get the latencies back in check (20-30ms
> > with occasional spikes of ~100ms).
> 
> Bittorent uses its own rate limiting technique, defeating
> current cwnd control done in the TCP stack, because of a very known
> problem
> 
> ( http://www.ietf.org/id/draft-ietf-tcpm-newcwv-00.txt )
> 
> So if your goal is reducing latencies for a _given_ class of flows, just
> use prio + 3 fq_codel,  and classify your packets to make sure your
> lovely ping packets are not dropped or behind long packets.

This is exactly the setup that I'm using right now (prio + 4 fq_codel
with bittorent set to low).
And setting the fq_codel limit to 1024 improves latency in this
situation. 
That's all I wanted to communicate. If the result doesn't interest you,
just ignore my mail.
Eric Dumazet March 30, 2013, 3:28 p.m. UTC | #7
On Sat, 2013-03-30 at 16:08 +0100, Markus Trippelsdorf wrote:

> This is exactly the setup that I'm using right now (prio + 4 fq_codel
> with bittorent set to low).
> And setting the fq_codel limit to 1024 improves latency in this
> situation. 
> That's all I wanted to communicate. If the result doesn't interest you,
> just ignore my mail.
> 

I didn't ignore your mail, I spent time from my Saturday to answer you.

If your prio setting was right, a limit of 10 should be enough for the
high prio queue, and a mere pfifo would be ok.

By definition, high prio packets should have a minimum latency (assuming
of course that BQL is enabled on your device)

Then, if all your packets land into he same prio queue, classification
is not correct.

If your link is oversubscribed (and Bittorent tends to push links to
over subscribed situation), then you want to increase drops by reducing
queue lengths.

fq_codel default limit is only a hint, like all defaults.

Some users want to increase it, others want to decrease it.

In your case, I suspect the number of flows is too large (and you get
hash collisions in fq), _and_ your ping packets land the crowded
fq_codel qdisc, instead of a small queue reserved for high prio packets.





--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/sched/sch_fq_codel.c b/net/sched/sch_fq_codel.c
index 4e606fc..5578628 100644
--- a/net/sched/sch_fq_codel.c
+++ b/net/sched/sch_fq_codel.c
@@ -195,7 +195,7 @@  static int fq_codel_enqueue(struct sk_buff *skb, struct Qdisc *sch)
 		flow->deficit = q->quantum;
 		flow->dropped = 0;
 	}
-	if (++sch->q.qlen < sch->limit)
+	if (++sch->q.qlen <= sch->limit)
 		return NET_XMIT_SUCCESS;
 
 	q->drop_overlimit++;