Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Jarek Poplawski and committed by
David S. Miller
a73be040 c0851347

+6 -3
+6 -3
net/sched/sch_htb.c
··· 661 661 * next pending event (0 for no event in pq). 662 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 667 /* don't run for longer than 2 jiffies; 2 is used instead of 667 668 1 to simplify things when jiffy is going to be incremented 668 669 too soon */ 669 - unsigned long stop_at = jiffies + 2; 670 + unsigned long stop_at = start + 2; 670 671 while (time_before(jiffies, stop_at)) { 671 672 struct htb_class *cl; 672 673 long diff; ··· 846 845 struct htb_sched *q = qdisc_priv(sch); 847 846 int level; 848 847 psched_time_t next_event; 848 + unsigned long start_at; 849 849 850 850 /* try to dequeue direct packets as high prio (!) to minimize cpu work */ 851 851 skb = __skb_dequeue(&q->direct_queue); ··· 859 857 if (!sch->q.qlen) 860 858 goto fin; 861 859 q->now = psched_get_time(); 860 + start_at = jiffies; 862 861 863 862 next_event = q->now + 5 * PSCHED_TICKS_PER_SEC; 864 863 ··· 869 866 psched_time_t event; 870 867 871 868 if (q->now >= q->near_ev_cache[level]) { 872 - event = htb_do_events(q, level); 869 + event = htb_do_events(q, level, start_at); 873 870 if (!event) 874 871 event = q->now + PSCHED_TICKS_PER_SEC; 875 872 q->near_ev_cache[level] = event;