@@ -61,6 +61,7 @@ struct fq_pie_sched_data {
61
61
struct pie_params p_params ;
62
62
u32 ecn_prob ;
63
63
u32 flows_cnt ;
64
+ u32 flows_cursor ;
64
65
u32 quantum ;
65
66
u32 memory_limit ;
66
67
u32 new_flow_count ;
@@ -375,22 +376,32 @@ static int fq_pie_change(struct Qdisc *sch, struct nlattr *opt,
375
376
static void fq_pie_timer (struct timer_list * t )
376
377
{
377
378
struct fq_pie_sched_data * q = from_timer (q , t , adapt_timer );
379
+ unsigned long next , tupdate ;
378
380
struct Qdisc * sch = q -> sch ;
379
381
spinlock_t * root_lock ; /* to lock qdisc for probability calculations */
380
- u32 idx ;
382
+ int max_cnt , i ;
381
383
382
384
rcu_read_lock ();
383
385
root_lock = qdisc_lock (qdisc_root_sleeping (sch ));
384
386
spin_lock (root_lock );
385
387
386
- for (idx = 0 ; idx < q -> flows_cnt ; idx ++ )
387
- pie_calculate_probability (& q -> p_params , & q -> flows [idx ].vars ,
388
- q -> flows [idx ].backlog );
389
-
390
- /* reset the timer to fire after 'tupdate' jiffies. */
391
- if (q -> p_params .tupdate )
392
- mod_timer (& q -> adapt_timer , jiffies + q -> p_params .tupdate );
388
+ /* Limit this expensive loop to 2048 flows per round. */
389
+ max_cnt = min_t (int , q -> flows_cnt - q -> flows_cursor , 2048 );
390
+ for (i = 0 ; i < max_cnt ; i ++ ) {
391
+ pie_calculate_probability (& q -> p_params ,
392
+ & q -> flows [q -> flows_cursor ].vars ,
393
+ q -> flows [q -> flows_cursor ].backlog );
394
+ q -> flows_cursor ++ ;
395
+ }
393
396
397
+ tupdate = q -> p_params .tupdate ;
398
+ next = 0 ;
399
+ if (q -> flows_cursor >= q -> flows_cnt ) {
400
+ q -> flows_cursor = 0 ;
401
+ next = tupdate ;
402
+ }
403
+ if (tupdate )
404
+ mod_timer (& q -> adapt_timer , jiffies + next );
394
405
spin_unlock (root_lock );
395
406
rcu_read_unlock ();
396
407
}
0 commit comments