]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
net/sched/sch_hfsc.c: handle corner cases where head may change invalidating calculat...
authorMichal Soltys <soltys@ziu.info>
Thu, 30 Jun 2016 00:26:44 +0000 (02:26 +0200)
committerDavid S. Miller <davem@davemloft.net>
Fri, 1 Jul 2016 09:03:43 +0000 (05:03 -0400)
Realtime scheduling implemented in HFSC uses head of the queue to make
the decision about which packet to schedule next. But in case of any
head drop, the deadline calculated for the previous head is not
necessarily correct for the next head (unless both packets have the same
length).

Thanks to peek() function used during dequeue - which internally is a
dequeue operation - hfsc is almost safe from this issue, as peek()
dequeues and isolates the head storing it temporarily until the real
dequeue happens.

But there is one exception: if after the class activation a drop happens
before the first dequeue operation, there's never a chance to do the
peek().

Adding peek() call in enqueue - if this is the first packet in a new
backlog period AND the scheduler has realtime curve defined - fixes that
one corner case. The 1st hfsc_dequeue() will use that peeked packet,
similarly as every subsequent hfsc_dequeue() call uses packet peeked by
the previous call.

Signed-off-by: Michal Soltys <soltys@ziu.info>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/sched/sch_hfsc.c

index 8cb5eff7b79c82a0bd6696cfbe53661f9818cc55..6d6df6b2d38fd5b509f4c49b04126a374cfe1ee2 100644 (file)
@@ -1594,8 +1594,17 @@ hfsc_enqueue(struct sk_buff *skb, struct Qdisc *sch, struct sk_buff **to_free)
                return err;
        }
 
-       if (cl->qdisc->q.qlen == 1)
+       if (cl->qdisc->q.qlen == 1) {
                set_active(cl, qdisc_pkt_len(skb));
+               /*
+                * If this is the first packet, isolate the head so an eventual
+                * head drop before the first dequeue operation has no chance
+                * to invalidate the deadline.
+                */
+               if (cl->cl_flags & HFSC_RSC)
+                       cl->qdisc->ops->peek(cl->qdisc);
+
+       }
 
        qdisc_qstats_backlog_inc(sch, skb);
        sch->q.qlen++;