662-remove_pfifo_fast.patch 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. From b531d492d5ef1cf9dba0f4888eb5fd8624a6d762 Mon Sep 17 00:00:00 2001
  2. From: Felix Fietkau <nbd@nbd.name>
  3. Date: Fri, 7 Jul 2017 17:23:42 +0200
  4. Subject: net: sched: switch default qdisc from pfifo_fast to fq_codel and remove pfifo_fast
  5. Signed-off-by: Felix Fietkau <nbd@nbd.name>
  6. ---
  7. net/sched/sch_generic.c | 140 ------------------------------------------------
  8. 1 file changed, 140 deletions(-)
  9. --- a/net/sched/sch_generic.c
  10. +++ b/net/sched/sch_generic.c
  11. @@ -453,146 +453,6 @@ struct Qdisc_ops noqueue_qdisc_ops __rea
  12. .owner = THIS_MODULE,
  13. };
  14. -static const u8 prio2band[TC_PRIO_MAX + 1] = {
  15. - 1, 2, 2, 2, 1, 2, 0, 0 , 1, 1, 1, 1, 1, 1, 1, 1
  16. -};
  17. -
  18. -/* 3-band FIFO queue: old style, but should be a bit faster than
  19. - generic prio+fifo combination.
  20. - */
  21. -
  22. -#define PFIFO_FAST_BANDS 3
  23. -
  24. -/*
  25. - * Private data for a pfifo_fast scheduler containing:
  26. - * - queues for the three band
  27. - * - bitmap indicating which of the bands contain skbs
  28. - */
  29. -struct pfifo_fast_priv {
  30. - u32 bitmap;
  31. - struct qdisc_skb_head q[PFIFO_FAST_BANDS];
  32. -};
  33. -
  34. -/*
  35. - * Convert a bitmap to the first band number where an skb is queued, where:
  36. - * bitmap=0 means there are no skbs on any band.
  37. - * bitmap=1 means there is an skb on band 0.
  38. - * bitmap=7 means there are skbs on all 3 bands, etc.
  39. - */
  40. -static const int bitmap2band[] = {-1, 0, 1, 0, 2, 0, 1, 0};
  41. -
  42. -static inline struct qdisc_skb_head *band2list(struct pfifo_fast_priv *priv,
  43. - int band)
  44. -{
  45. - return priv->q + band;
  46. -}
  47. -
  48. -static int pfifo_fast_enqueue(struct sk_buff *skb, struct Qdisc *qdisc,
  49. - struct sk_buff **to_free)
  50. -{
  51. - if (qdisc->q.qlen < qdisc_dev(qdisc)->tx_queue_len) {
  52. - int band = prio2band[skb->priority & TC_PRIO_MAX];
  53. - struct pfifo_fast_priv *priv = qdisc_priv(qdisc);
  54. - struct qdisc_skb_head *list = band2list(priv, band);
  55. -
  56. - priv->bitmap |= (1 << band);
  57. - qdisc->q.qlen++;
  58. - return __qdisc_enqueue_tail(skb, qdisc, list);
  59. - }
  60. -
  61. - return qdisc_drop(skb, qdisc, to_free);
  62. -}
  63. -
  64. -static struct sk_buff *pfifo_fast_dequeue(struct Qdisc *qdisc)
  65. -{
  66. - struct pfifo_fast_priv *priv = qdisc_priv(qdisc);
  67. - int band = bitmap2band[priv->bitmap];
  68. -
  69. - if (likely(band >= 0)) {
  70. - struct qdisc_skb_head *qh = band2list(priv, band);
  71. - struct sk_buff *skb = __qdisc_dequeue_head(qh);
  72. -
  73. - if (likely(skb != NULL)) {
  74. - qdisc_qstats_backlog_dec(qdisc, skb);
  75. - qdisc_bstats_update(qdisc, skb);
  76. - }
  77. -
  78. - qdisc->q.qlen--;
  79. - if (qh->qlen == 0)
  80. - priv->bitmap &= ~(1 << band);
  81. -
  82. - return skb;
  83. - }
  84. -
  85. - return NULL;
  86. -}
  87. -
  88. -static struct sk_buff *pfifo_fast_peek(struct Qdisc *qdisc)
  89. -{
  90. - struct pfifo_fast_priv *priv = qdisc_priv(qdisc);
  91. - int band = bitmap2band[priv->bitmap];
  92. -
  93. - if (band >= 0) {
  94. - struct qdisc_skb_head *qh = band2list(priv, band);
  95. -
  96. - return qh->head;
  97. - }
  98. -
  99. - return NULL;
  100. -}
  101. -
  102. -static void pfifo_fast_reset(struct Qdisc *qdisc)
  103. -{
  104. - int prio;
  105. - struct pfifo_fast_priv *priv = qdisc_priv(qdisc);
  106. -
  107. - for (prio = 0; prio < PFIFO_FAST_BANDS; prio++)
  108. - __qdisc_reset_queue(band2list(priv, prio));
  109. -
  110. - priv->bitmap = 0;
  111. - qdisc->qstats.backlog = 0;
  112. - qdisc->q.qlen = 0;
  113. -}
  114. -
  115. -static int pfifo_fast_dump(struct Qdisc *qdisc, struct sk_buff *skb)
  116. -{
  117. - struct tc_prio_qopt opt = { .bands = PFIFO_FAST_BANDS };
  118. -
  119. - memcpy(&opt.priomap, prio2band, TC_PRIO_MAX + 1);
  120. - if (nla_put(skb, TCA_OPTIONS, sizeof(opt), &opt))
  121. - goto nla_put_failure;
  122. - return skb->len;
  123. -
  124. -nla_put_failure:
  125. - return -1;
  126. -}
  127. -
  128. -static int pfifo_fast_init(struct Qdisc *qdisc, struct nlattr *opt)
  129. -{
  130. - int prio;
  131. - struct pfifo_fast_priv *priv = qdisc_priv(qdisc);
  132. -
  133. - for (prio = 0; prio < PFIFO_FAST_BANDS; prio++)
  134. - qdisc_skb_head_init(band2list(priv, prio));
  135. -
  136. - /* Can by-pass the queue discipline */
  137. - qdisc->flags |= TCQ_F_CAN_BYPASS;
  138. - return 0;
  139. -}
  140. -
  141. -struct Qdisc_ops pfifo_fast_ops __read_mostly = {
  142. - .id = "pfifo_fast",
  143. - .priv_size = sizeof(struct pfifo_fast_priv),
  144. - .enqueue = pfifo_fast_enqueue,
  145. - .dequeue = pfifo_fast_dequeue,
  146. - .peek = pfifo_fast_peek,
  147. - .init = pfifo_fast_init,
  148. - .reset = pfifo_fast_reset,
  149. - .dump = pfifo_fast_dump,
  150. - .owner = THIS_MODULE,
  151. -};
  152. -EXPORT_SYMBOL(pfifo_fast_ops);
  153. -
  154. static struct lock_class_key qdisc_tx_busylock;
  155. static struct lock_class_key qdisc_running_key;