hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/net/sched/sch_fq_pie.c
....@@ -61,6 +61,7 @@
6161 struct pie_params p_params;
6262 u32 ecn_prob;
6363 u32 flows_cnt;
64
+ u32 flows_cursor;
6465 u32 quantum;
6566 u32 memory_limit;
6667 u32 new_flow_count;
....@@ -201,6 +202,11 @@
201202 return NET_XMIT_CN;
202203 }
203204
205
+static struct netlink_range_validation fq_pie_q_range = {
206
+ .min = 1,
207
+ .max = 1 << 20,
208
+};
209
+
204210 static const struct nla_policy fq_pie_policy[TCA_FQ_PIE_MAX + 1] = {
205211 [TCA_FQ_PIE_LIMIT] = {.type = NLA_U32},
206212 [TCA_FQ_PIE_FLOWS] = {.type = NLA_U32},
....@@ -208,7 +214,8 @@
208214 [TCA_FQ_PIE_TUPDATE] = {.type = NLA_U32},
209215 [TCA_FQ_PIE_ALPHA] = {.type = NLA_U32},
210216 [TCA_FQ_PIE_BETA] = {.type = NLA_U32},
211
- [TCA_FQ_PIE_QUANTUM] = {.type = NLA_U32},
217
+ [TCA_FQ_PIE_QUANTUM] =
218
+ NLA_POLICY_FULL_RANGE(NLA_U32, &fq_pie_q_range),
212219 [TCA_FQ_PIE_MEMORY_LIMIT] = {.type = NLA_U32},
213220 [TCA_FQ_PIE_ECN_PROB] = {.type = NLA_U32},
214221 [TCA_FQ_PIE_ECN] = {.type = NLA_U32},
....@@ -372,21 +379,31 @@
372379 static void fq_pie_timer(struct timer_list *t)
373380 {
374381 struct fq_pie_sched_data *q = from_timer(q, t, adapt_timer);
382
+ unsigned long next, tupdate;
375383 struct Qdisc *sch = q->sch;
376384 spinlock_t *root_lock; /* to lock qdisc for probability calculations */
377
- u32 idx;
385
+ int max_cnt, i;
378386
379387 root_lock = qdisc_lock(qdisc_root_sleeping(sch));
380388 spin_lock(root_lock);
381389
382
- for (idx = 0; idx < q->flows_cnt; idx++)
383
- pie_calculate_probability(&q->p_params, &q->flows[idx].vars,
384
- q->flows[idx].backlog);
390
+ /* Limit this expensive loop to 2048 flows per round. */
391
+ max_cnt = min_t(int, q->flows_cnt - q->flows_cursor, 2048);
392
+ for (i = 0; i < max_cnt; i++) {
393
+ pie_calculate_probability(&q->p_params,
394
+ &q->flows[q->flows_cursor].vars,
395
+ q->flows[q->flows_cursor].backlog);
396
+ q->flows_cursor++;
397
+ }
385398
386
- /* reset the timer to fire after 'tupdate' jiffies. */
387
- if (q->p_params.tupdate)
388
- mod_timer(&q->adapt_timer, jiffies + q->p_params.tupdate);
389
-
399
+ tupdate = q->p_params.tupdate;
400
+ next = 0;
401
+ if (q->flows_cursor >= q->flows_cnt) {
402
+ q->flows_cursor = 0;
403
+ next = tupdate;
404
+ }
405
+ if (tupdate)
406
+ mod_timer(&q->adapt_timer, jiffies + next);
390407 spin_unlock(root_lock);
391408 }
392409