662-remove_pfifo_fast.patch 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. From b531d492d5ef1cf9dba0f4888eb5fd8624a6d762 Mon Sep 17 00:00:00 2001
  2. From: Felix Fietkau <[email protected]>
  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 <[email protected]>
  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. @@ -595,211 +595,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. - * - rings for priority bands
  27. - */
  28. -struct pfifo_fast_priv {
  29. - struct skb_array q[PFIFO_FAST_BANDS];
  30. -};
  31. -
  32. -static inline struct skb_array *band2list(struct pfifo_fast_priv *priv,
  33. - int band)
  34. -{
  35. - return &priv->q[band];
  36. -}
  37. -
  38. -static int pfifo_fast_enqueue(struct sk_buff *skb, struct Qdisc *qdisc,
  39. - struct sk_buff **to_free)
  40. -{
  41. - int band = prio2band[skb->priority & TC_PRIO_MAX];
  42. - struct pfifo_fast_priv *priv = qdisc_priv(qdisc);
  43. - struct skb_array *q = band2list(priv, band);
  44. - unsigned int pkt_len = qdisc_pkt_len(skb);
  45. - int err;
  46. -
  47. - err = skb_array_produce(q, skb);
  48. -
  49. - if (unlikely(err)) {
  50. - if (qdisc_is_percpu_stats(qdisc))
  51. - return qdisc_drop_cpu(skb, qdisc, to_free);
  52. - else
  53. - return qdisc_drop(skb, qdisc, to_free);
  54. - }
  55. -
  56. - qdisc_update_stats_at_enqueue(qdisc, pkt_len);
  57. - return NET_XMIT_SUCCESS;
  58. -}
  59. -
  60. -static struct sk_buff *pfifo_fast_dequeue(struct Qdisc *qdisc)
  61. -{
  62. - struct pfifo_fast_priv *priv = qdisc_priv(qdisc);
  63. - struct sk_buff *skb = NULL;
  64. - int band;
  65. -
  66. - for (band = 0; band < PFIFO_FAST_BANDS && !skb; band++) {
  67. - struct skb_array *q = band2list(priv, band);
  68. -
  69. - if (__skb_array_empty(q))
  70. - continue;
  71. -
  72. - skb = __skb_array_consume(q);
  73. - }
  74. - if (likely(skb)) {
  75. - qdisc_update_stats_at_dequeue(qdisc, skb);
  76. - } else {
  77. - WRITE_ONCE(qdisc->empty, true);
  78. - }
  79. -
  80. - return skb;
  81. -}
  82. -
  83. -static struct sk_buff *pfifo_fast_peek(struct Qdisc *qdisc)
  84. -{
  85. - struct pfifo_fast_priv *priv = qdisc_priv(qdisc);
  86. - struct sk_buff *skb = NULL;
  87. - int band;
  88. -
  89. - for (band = 0; band < PFIFO_FAST_BANDS && !skb; band++) {
  90. - struct skb_array *q = band2list(priv, band);
  91. -
  92. - skb = __skb_array_peek(q);
  93. - }
  94. -
  95. - return skb;
  96. -}
  97. -
  98. -static void pfifo_fast_reset(struct Qdisc *qdisc)
  99. -{
  100. - int i, band;
  101. - struct pfifo_fast_priv *priv = qdisc_priv(qdisc);
  102. -
  103. - for (band = 0; band < PFIFO_FAST_BANDS; band++) {
  104. - struct skb_array *q = band2list(priv, band);
  105. - struct sk_buff *skb;
  106. -
  107. - /* NULL ring is possible if destroy path is due to a failed
  108. - * skb_array_init() in pfifo_fast_init() case.
  109. - */
  110. - if (!q->ring.queue)
  111. - continue;
  112. -
  113. - while ((skb = __skb_array_consume(q)) != NULL)
  114. - kfree_skb(skb);
  115. - }
  116. -
  117. - if (qdisc_is_percpu_stats(qdisc)) {
  118. - for_each_possible_cpu(i) {
  119. - struct gnet_stats_queue *q;
  120. -
  121. - q = per_cpu_ptr(qdisc->cpu_qstats, i);
  122. - q->backlog = 0;
  123. - q->qlen = 0;
  124. - }
  125. - }
  126. -}
  127. -
  128. -static int pfifo_fast_dump(struct Qdisc *qdisc, struct sk_buff *skb)
  129. -{
  130. - struct tc_prio_qopt opt = { .bands = PFIFO_FAST_BANDS };
  131. -
  132. - memcpy(&opt.priomap, prio2band, TC_PRIO_MAX + 1);
  133. - if (nla_put(skb, TCA_OPTIONS, sizeof(opt), &opt))
  134. - goto nla_put_failure;
  135. - return skb->len;
  136. -
  137. -nla_put_failure:
  138. - return -1;
  139. -}
  140. -
  141. -static int pfifo_fast_init(struct Qdisc *qdisc, struct nlattr *opt,
  142. - struct netlink_ext_ack *extack)
  143. -{
  144. - unsigned int qlen = qdisc_dev(qdisc)->tx_queue_len;
  145. - struct pfifo_fast_priv *priv = qdisc_priv(qdisc);
  146. - int prio;
  147. -
  148. - /* guard against zero length rings */
  149. - if (!qlen)
  150. - return -EINVAL;
  151. -
  152. - for (prio = 0; prio < PFIFO_FAST_BANDS; prio++) {
  153. - struct skb_array *q = band2list(priv, prio);
  154. - int err;
  155. -
  156. - err = skb_array_init(q, qlen, GFP_KERNEL);
  157. - if (err)
  158. - return -ENOMEM;
  159. - }
  160. -
  161. - /* Can by-pass the queue discipline */
  162. - qdisc->flags |= TCQ_F_CAN_BYPASS;
  163. - return 0;
  164. -}
  165. -
  166. -static void pfifo_fast_destroy(struct Qdisc *sch)
  167. -{
  168. - struct pfifo_fast_priv *priv = qdisc_priv(sch);
  169. - int prio;
  170. -
  171. - for (prio = 0; prio < PFIFO_FAST_BANDS; prio++) {
  172. - struct skb_array *q = band2list(priv, prio);
  173. -
  174. - /* NULL ring is possible if destroy path is due to a failed
  175. - * skb_array_init() in pfifo_fast_init() case.
  176. - */
  177. - if (!q->ring.queue)
  178. - continue;
  179. - /* Destroy ring but no need to kfree_skb because a call to
  180. - * pfifo_fast_reset() has already done that work.
  181. - */
  182. - ptr_ring_cleanup(&q->ring, NULL);
  183. - }
  184. -}
  185. -
  186. -static int pfifo_fast_change_tx_queue_len(struct Qdisc *sch,
  187. - unsigned int new_len)
  188. -{
  189. - struct pfifo_fast_priv *priv = qdisc_priv(sch);
  190. - struct skb_array *bands[PFIFO_FAST_BANDS];
  191. - int prio;
  192. -
  193. - for (prio = 0; prio < PFIFO_FAST_BANDS; prio++) {
  194. - struct skb_array *q = band2list(priv, prio);
  195. -
  196. - bands[prio] = q;
  197. - }
  198. -
  199. - return skb_array_resize_multiple(bands, PFIFO_FAST_BANDS, new_len,
  200. - GFP_KERNEL);
  201. -}
  202. -
  203. -struct Qdisc_ops pfifo_fast_ops __read_mostly = {
  204. - .id = "pfifo_fast",
  205. - .priv_size = sizeof(struct pfifo_fast_priv),
  206. - .enqueue = pfifo_fast_enqueue,
  207. - .dequeue = pfifo_fast_dequeue,
  208. - .peek = pfifo_fast_peek,
  209. - .init = pfifo_fast_init,
  210. - .destroy = pfifo_fast_destroy,
  211. - .reset = pfifo_fast_reset,
  212. - .dump = pfifo_fast_dump,
  213. - .change_tx_queue_len = pfifo_fast_change_tx_queue_len,
  214. - .owner = THIS_MODULE,
  215. - .static_flags = TCQ_F_NOLOCK | TCQ_F_CPUSTATS,
  216. -};
  217. -EXPORT_SYMBOL(pfifo_fast_ops);
  218. -
  219. struct Qdisc *qdisc_alloc(struct netdev_queue *dev_queue,
  220. const struct Qdisc_ops *ops,
  221. struct netlink_ext_ack *extack)