620-net_sched-codel-do-not-defer-queue-length-update.patch 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. From: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
  2. Date: Mon, 21 Aug 2017 11:14:14 +0300
  3. Subject: [PATCH] net_sched/codel: do not defer queue length update
  4. When codel wants to drop last packet in ->dequeue() it cannot call
  5. qdisc_tree_reduce_backlog() right away - it will notify parent qdisc
  6. about zero qlen and HTB/HFSC will deactivate class. The same class will
  7. be deactivated second time by caller of ->dequeue(). Currently codel and
  8. fq_codel defer update. This triggers warning in HFSC when it's qlen != 0
  9. but there is no active classes.
  10. This patch update parent queue length immediately: just temporary increase
  11. qlen around qdisc_tree_reduce_backlog() to prevent first class deactivation
  12. if we have skb to return.
  13. This might open another problem in HFSC - now operation peek could fail and
  14. deactivate parent class.
  15. Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
  16. Link: https://bugzilla.kernel.org/show_bug.cgi?id=109581
  17. ---
  18. --- a/net/sched/sch_codel.c
  19. +++ b/net/sched/sch_codel.c
  20. @@ -95,11 +95,17 @@ static struct sk_buff *codel_qdisc_deque
  21. &q->stats, qdisc_pkt_len, codel_get_enqueue_time,
  22. drop_func, dequeue_func);
  23. - /* We cant call qdisc_tree_reduce_backlog() if our qlen is 0,
  24. - * or HTB crashes. Defer it for next round.
  25. + /* If our qlen is 0 qdisc_tree_reduce_backlog() will deactivate
  26. + * parent class, dequeue in parent qdisc will do the same if we
  27. + * return skb. Temporary increment qlen if we have skb.
  28. */
  29. - if (q->stats.drop_count && sch->q.qlen) {
  30. - qdisc_tree_reduce_backlog(sch, q->stats.drop_count, q->stats.drop_len);
  31. + if (q->stats.drop_count) {
  32. + if (skb)
  33. + sch->q.qlen++;
  34. + qdisc_tree_reduce_backlog(sch, q->stats.drop_count,
  35. + q->stats.drop_len);
  36. + if (skb)
  37. + sch->q.qlen--;
  38. q->stats.drop_count = 0;
  39. q->stats.drop_len = 0;
  40. }
  41. --- a/net/sched/sch_fq_codel.c
  42. +++ b/net/sched/sch_fq_codel.c
  43. @@ -316,6 +316,21 @@ begin:
  44. flow->dropped += q->cstats.drop_count - prev_drop_count;
  45. flow->dropped += q->cstats.ecn_mark - prev_ecn_mark;
  46. + /* If our qlen is 0 qdisc_tree_reduce_backlog() will deactivate
  47. + * parent class, dequeue in parent qdisc will do the same if we
  48. + * return skb. Temporary increment qlen if we have skb.
  49. + */
  50. + if (q->cstats.drop_count) {
  51. + if (skb)
  52. + sch->q.qlen++;
  53. + qdisc_tree_reduce_backlog(sch, q->cstats.drop_count,
  54. + q->cstats.drop_len);
  55. + if (skb)
  56. + sch->q.qlen--;
  57. + q->cstats.drop_count = 0;
  58. + q->cstats.drop_len = 0;
  59. + }
  60. +
  61. if (!skb) {
  62. /* force a pass through old_flows to prevent starvation */
  63. if ((head == &q->new_flows) && !list_empty(&q->old_flows))
  64. @@ -326,15 +341,6 @@ begin:
  65. }
  66. qdisc_bstats_update(sch, skb);
  67. flow->deficit -= qdisc_pkt_len(skb);
  68. - /* We cant call qdisc_tree_reduce_backlog() if our qlen is 0,
  69. - * or HTB crashes. Defer it for next round.
  70. - */
  71. - if (q->cstats.drop_count && sch->q.qlen) {
  72. - qdisc_tree_reduce_backlog(sch, q->cstats.drop_count,
  73. - q->cstats.drop_len);
  74. - q->cstats.drop_count = 0;
  75. - q->cstats.drop_len = 0;
  76. - }
  77. return skb;
  78. }