diff options
author | Jarek Poplawski <jarkao2@gmail.com> | 2009-01-13 00:54:40 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-01-13 00:54:40 -0500 |
commit | a73be040650463eacb95f83d2e6673ac57b4fc59 (patch) | |
tree | ae3958ba9830448e18a0dedc82c8d7c031af2476 /net/sched | |
parent | c08513471911cf33cb50249a7ff12848374f7263 (diff) |
pkt_sched: sch_htb: Break all htb_do_events() after 2 jiffies
Currently htb_do_events() breaks events recounting for a level after 2
jiffies, but there is no reason to repeat this for next levels and
increase delays even more (with softirqs disabled). htb_dequeue_tree()
can add to this too, btw. In such a case q->now time is invalid anyway.
Thanks to Patrick McHardy for spotting an error around earlier version
of this patch.
Signed-off-by: Jarek Poplawski <jarkao2@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sched')
-rw-r--r-- | net/sched/sch_htb.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c index 9ca8a26ba507..2f0f0b04d3fb 100644 --- a/net/sched/sch_htb.c +++ b/net/sched/sch_htb.c | |||
@@ -661,12 +661,13 @@ static void htb_charge_class(struct htb_sched *q, struct htb_class *cl, | |||
661 | * next pending event (0 for no event in pq). | 661 | * next pending event (0 for no event in pq). |
662 | * Note: Applied are events whose have cl->pq_key <= q->now. | 662 | * Note: Applied are events whose have cl->pq_key <= q->now. |
663 | */ | 663 | */ |
664 | static psched_time_t htb_do_events(struct htb_sched *q, int level) | 664 | static psched_time_t htb_do_events(struct htb_sched *q, int level, |
665 | unsigned long start) | ||
665 | { | 666 | { |
666 | /* don't run for longer than 2 jiffies; 2 is used instead of | 667 | /* don't run for longer than 2 jiffies; 2 is used instead of |
667 | 1 to simplify things when jiffy is going to be incremented | 668 | 1 to simplify things when jiffy is going to be incremented |
668 | too soon */ | 669 | too soon */ |
669 | unsigned long stop_at = jiffies + 2; | 670 | unsigned long stop_at = start + 2; |
670 | while (time_before(jiffies, stop_at)) { | 671 | while (time_before(jiffies, stop_at)) { |
671 | struct htb_class *cl; | 672 | struct htb_class *cl; |
672 | long diff; | 673 | long diff; |
@@ -845,6 +846,7 @@ static struct sk_buff *htb_dequeue(struct Qdisc *sch) | |||
845 | struct htb_sched *q = qdisc_priv(sch); | 846 | struct htb_sched *q = qdisc_priv(sch); |
846 | int level; | 847 | int level; |
847 | psched_time_t next_event; | 848 | psched_time_t next_event; |
849 | unsigned long start_at; | ||
848 | 850 | ||
849 | /* try to dequeue direct packets as high prio (!) to minimize cpu work */ | 851 | /* try to dequeue direct packets as high prio (!) to minimize cpu work */ |
850 | skb = __skb_dequeue(&q->direct_queue); | 852 | skb = __skb_dequeue(&q->direct_queue); |
@@ -857,6 +859,7 @@ static struct sk_buff *htb_dequeue(struct Qdisc *sch) | |||
857 | if (!sch->q.qlen) | 859 | if (!sch->q.qlen) |
858 | goto fin; | 860 | goto fin; |
859 | q->now = psched_get_time(); | 861 | q->now = psched_get_time(); |
862 | start_at = jiffies; | ||
860 | 863 | ||
861 | next_event = q->now + 5 * PSCHED_TICKS_PER_SEC; | 864 | next_event = q->now + 5 * PSCHED_TICKS_PER_SEC; |
862 | 865 | ||
@@ -866,7 +869,7 @@ static struct sk_buff *htb_dequeue(struct Qdisc *sch) | |||
866 | psched_time_t event; | 869 | psched_time_t event; |
867 | 870 | ||
868 | if (q->now >= q->near_ev_cache[level]) { | 871 | if (q->now >= q->near_ev_cache[level]) { |
869 | event = htb_do_events(q, level); | 872 | event = htb_do_events(q, level, start_at); |
870 | if (!event) | 873 | if (!event) |
871 | event = q->now + PSCHED_TICKS_PER_SEC; | 874 | event = q->now + PSCHED_TICKS_PER_SEC; |
872 | q->near_ev_cache[level] = event; | 875 | q->near_ev_cache[level] = event; |