aboutsummaryrefslogtreecommitdiffstats
path: root/net/sched/sch_htb.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/sched/sch_htb.c')
-rw-r--r--net/sched/sch_htb.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c
index 5070643ce534..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 */
664static psched_time_t htb_do_events(struct htb_sched *q, int level) 664static 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;
@@ -685,8 +686,8 @@ static psched_time_t htb_do_events(struct htb_sched *q, int level)
685 if (cl->cmode != HTB_CAN_SEND) 686 if (cl->cmode != HTB_CAN_SEND)
686 htb_add_to_wait_tree(q, cl, diff); 687 htb_add_to_wait_tree(q, cl, diff);
687 } 688 }
688 /* too much load - let's continue on next jiffie */ 689 /* too much load - let's continue on next jiffie (including above) */
689 return q->now + PSCHED_TICKS_PER_SEC / HZ; 690 return q->now + 2 * PSCHED_TICKS_PER_SEC / HZ;
690} 691}
691 692
692/* Returns class->node+prio from id-tree where classe's id is >= id. NULL 693/* Returns class->node+prio from id-tree where classe's id is >= id. NULL
@@ -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,14 +869,14 @@ 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;
873 } else 876 } else
874 event = q->near_ev_cache[level]; 877 event = q->near_ev_cache[level];
875 878
876 if (event && next_event > event) 879 if (next_event > event)
877 next_event = event; 880 next_event = event;
878 881
879 m = ~q->row_mask[level]; 882 m = ~q->row_mask[level];