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

sch_htb: fix "too many events" situation

HTB is event driven algorithm and part of its work is to apply
scheduled events at proper times. It tried to defend itself from
livelock by processing only limited number of events per dequeue.
Because of faster computers some users already hit this hardcoded
limit.

This patch limits processing up to 2 jiffies (why not 1 jiffie ?
because it might stop prematurely when only fraction of jiffie
remains).

Signed-off-by: Martin Devera <devik@cdi.cz>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Martin Devera and committed by
David S. Miller
8f3ea33a 4b1b3667

+7 -6
+7 -6
net/sched/sch_htb.c
··· 711 711 */ 712 712 static psched_time_t htb_do_events(struct htb_sched *q, int level) 713 713 { 714 - int i; 715 - 716 - for (i = 0; i < 500; i++) { 714 + /* don't run for longer than 2 jiffies; 2 is used instead of 715 + 1 to simplify things when jiffy is going to be incremented 716 + too soon */ 717 + unsigned long stop_at = jiffies + 2; 718 + while (time_before(jiffies, stop_at)) { 717 719 struct htb_class *cl; 718 720 long diff; 719 721 struct rb_node *p = rb_first(&q->wait_pq[level]); ··· 733 731 if (cl->cmode != HTB_CAN_SEND) 734 732 htb_add_to_wait_tree(q, cl, diff); 735 733 } 736 - if (net_ratelimit()) 737 - printk(KERN_WARNING "htb: too many events !\n"); 738 - return q->now + PSCHED_TICKS_PER_SEC / 10; 734 + /* too much load - let's continue on next jiffie */ 735 + return q->now + PSCHED_TICKS_PER_SEC / HZ; 739 736 } 740 737 741 738 /* Returns class->node+prio from id-tree where classe's id is >= id. NULL