Commit aa3e2199 authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

net_sched: sch_sfq: fix allot handling

When deploying SFQ/IFB here at work, I found the allot management was
pretty wrong in sfq, even changing allot from short to int...

We should init allot for each new flow, not using a previous value found
in slot.

Before patch, I saw bursts of several packets per flow, apparently
denying the default "quantum 1514" limit I had on my SFQ class.

class sfq 11:1 parent 11: 
 (dropped 0, overlimits 0 requeues 0) 
 backlog 0b 7p requeues 0 
 allot 11546 

class sfq 11:46 parent 11: 
 (dropped 0, overlimits 0 requeues 0) 
 backlog 0b 1p requeues 0 
 allot -23873 

class sfq 11:78 parent 11: 
 (dropped 0, overlimits 0 requeues 0) 
 backlog 0b 5p requeues 0 
 allot 11393 

After patch, better fairness among each flow, allot limit being
respected, allot is positive :

class sfq 11:e parent 11: 
 (dropped 0, overlimits 0 requeues 86) 
 backlog 0b 3p requeues 86 
 allot 596 

class sfq 11:94 parent 11: 
 (dropped 0, overlimits 0 requeues 0) 
 backlog 0b 3p requeues 0 
 allot 1468 

class sfq 11:a4 parent 11: 
 (dropped 0, overlimits 0 requeues 0) 
 backlog 0b 4p requeues 0 
 allot 650 

class sfq 11:bb parent 11: 
 (dropped 0, overlimits 0 requeues 0) 
 backlog 0b 3p requeues 0 
 allot 596 
Signed-off-by: default avatarEric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 914e5cea
...@@ -270,7 +270,6 @@ static unsigned int sfq_drop(struct Qdisc *sch) ...@@ -270,7 +270,6 @@ static unsigned int sfq_drop(struct Qdisc *sch)
/* It is difficult to believe, but ALL THE SLOTS HAVE LENGTH 1. */ /* It is difficult to believe, but ALL THE SLOTS HAVE LENGTH 1. */
d = q->next[q->tail]; d = q->next[q->tail];
q->next[q->tail] = q->next[d]; q->next[q->tail] = q->next[d];
q->allot[q->next[d]] += q->quantum;
skb = q->qs[d].prev; skb = q->qs[d].prev;
len = qdisc_pkt_len(skb); len = qdisc_pkt_len(skb);
__skb_unlink(skb, &q->qs[d]); __skb_unlink(skb, &q->qs[d]);
...@@ -321,14 +320,13 @@ sfq_enqueue(struct sk_buff *skb, struct Qdisc *sch) ...@@ -321,14 +320,13 @@ sfq_enqueue(struct sk_buff *skb, struct Qdisc *sch)
sfq_inc(q, x); sfq_inc(q, x);
if (q->qs[x].qlen == 1) { /* The flow is new */ if (q->qs[x].qlen == 1) { /* The flow is new */
if (q->tail == SFQ_DEPTH) { /* It is the first flow */ if (q->tail == SFQ_DEPTH) { /* It is the first flow */
q->tail = x;
q->next[x] = x; q->next[x] = x;
q->allot[x] = q->quantum;
} else { } else {
q->next[x] = q->next[q->tail]; q->next[x] = q->next[q->tail];
q->next[q->tail] = x; q->next[q->tail] = x;
q->tail = x;
} }
q->tail = x;
q->allot[x] = q->quantum;
} }
if (++sch->q.qlen <= q->limit) { if (++sch->q.qlen <= q->limit) {
sch->bstats.bytes += qdisc_pkt_len(skb); sch->bstats.bytes += qdisc_pkt_len(skb);
...@@ -359,13 +357,13 @@ sfq_dequeue(struct Qdisc *sch) ...@@ -359,13 +357,13 @@ sfq_dequeue(struct Qdisc *sch)
{ {
struct sfq_sched_data *q = qdisc_priv(sch); struct sfq_sched_data *q = qdisc_priv(sch);
struct sk_buff *skb; struct sk_buff *skb;
sfq_index a, old_a; sfq_index a, next_a;
/* No active slots */ /* No active slots */
if (q->tail == SFQ_DEPTH) if (q->tail == SFQ_DEPTH)
return NULL; return NULL;
a = old_a = q->next[q->tail]; a = q->next[q->tail];
/* Grab packet */ /* Grab packet */
skb = __skb_dequeue(&q->qs[a]); skb = __skb_dequeue(&q->qs[a]);
...@@ -376,17 +374,15 @@ sfq_dequeue(struct Qdisc *sch) ...@@ -376,17 +374,15 @@ sfq_dequeue(struct Qdisc *sch)
/* Is the slot empty? */ /* Is the slot empty? */
if (q->qs[a].qlen == 0) { if (q->qs[a].qlen == 0) {
q->ht[q->hash[a]] = SFQ_DEPTH; q->ht[q->hash[a]] = SFQ_DEPTH;
a = q->next[a]; next_a = q->next[a];
if (a == old_a) { if (a == next_a) {
q->tail = SFQ_DEPTH; q->tail = SFQ_DEPTH;
return skb; return skb;
} }
q->next[q->tail] = a; q->next[q->tail] = next_a;
q->allot[a] += q->quantum;
} else if ((q->allot[a] -= qdisc_pkt_len(skb)) <= 0) { } else if ((q->allot[a] -= qdisc_pkt_len(skb)) <= 0) {
q->tail = a;
a = q->next[a];
q->allot[a] += q->quantum; q->allot[a] += q->quantum;
q->tail = a;
} }
return skb; return skb;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment