662-remove_pfifo_fast.patch 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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,208 +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. - return qdisc_drop_cpu(skb, qdisc, to_free);
  51. -
  52. - qdisc_qstats_cpu_qlen_inc(qdisc);
  53. - /* Note: skb can not be used after skb_array_produce(),
  54. - * so we better not use qdisc_qstats_cpu_backlog_inc()
  55. - */
  56. - this_cpu_add(qdisc->cpu_qstats->backlog, 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_qstats_cpu_backlog_dec(qdisc, skb);
  76. - qdisc_bstats_cpu_update(qdisc, skb);
  77. - qdisc_qstats_cpu_qlen_dec(qdisc);
  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. - for_each_possible_cpu(i) {
  118. - struct gnet_stats_queue *q = per_cpu_ptr(qdisc->cpu_qstats, i);
  119. -
  120. - q->backlog = 0;
  121. - q->qlen = 0;
  122. - }
  123. -}
  124. -
  125. -static int pfifo_fast_dump(struct Qdisc *qdisc, struct sk_buff *skb)
  126. -{
  127. - struct tc_prio_qopt opt = { .bands = PFIFO_FAST_BANDS };
  128. -
  129. - memcpy(&opt.priomap, prio2band, TC_PRIO_MAX + 1);
  130. - if (nla_put(skb, TCA_OPTIONS, sizeof(opt), &opt))
  131. - goto nla_put_failure;
  132. - return skb->len;
  133. -
  134. -nla_put_failure:
  135. - return -1;
  136. -}
  137. -
  138. -static int pfifo_fast_init(struct Qdisc *qdisc, struct nlattr *opt,
  139. - struct netlink_ext_ack *extack)
  140. -{
  141. - unsigned int qlen = qdisc_dev(qdisc)->tx_queue_len;
  142. - struct pfifo_fast_priv *priv = qdisc_priv(qdisc);
  143. - int prio;
  144. -
  145. - /* guard against zero length rings */
  146. - if (!qlen)
  147. - return -EINVAL;
  148. -
  149. - for (prio = 0; prio < PFIFO_FAST_BANDS; prio++) {
  150. - struct skb_array *q = band2list(priv, prio);
  151. - int err;
  152. -
  153. - err = skb_array_init(q, qlen, GFP_KERNEL);
  154. - if (err)
  155. - return -ENOMEM;
  156. - }
  157. -
  158. - /* Can by-pass the queue discipline */
  159. - qdisc->flags |= TCQ_F_CAN_BYPASS;
  160. - return 0;
  161. -}
  162. -
  163. -static void pfifo_fast_destroy(struct Qdisc *sch)
  164. -{
  165. - struct pfifo_fast_priv *priv = qdisc_priv(sch);
  166. - int prio;
  167. -
  168. - for (prio = 0; prio < PFIFO_FAST_BANDS; prio++) {
  169. - struct skb_array *q = band2list(priv, prio);
  170. -
  171. - /* NULL ring is possible if destroy path is due to a failed
  172. - * skb_array_init() in pfifo_fast_init() case.
  173. - */
  174. - if (!q->ring.queue)
  175. - continue;
  176. - /* Destroy ring but no need to kfree_skb because a call to
  177. - * pfifo_fast_reset() has already done that work.
  178. - */
  179. - ptr_ring_cleanup(&q->ring, NULL);
  180. - }
  181. -}
  182. -
  183. -static int pfifo_fast_change_tx_queue_len(struct Qdisc *sch,
  184. - unsigned int new_len)
  185. -{
  186. - struct pfifo_fast_priv *priv = qdisc_priv(sch);
  187. - struct skb_array *bands[PFIFO_FAST_BANDS];
  188. - int prio;
  189. -
  190. - for (prio = 0; prio < PFIFO_FAST_BANDS; prio++) {
  191. - struct skb_array *q = band2list(priv, prio);
  192. -
  193. - bands[prio] = q;
  194. - }
  195. -
  196. - return skb_array_resize_multiple(bands, PFIFO_FAST_BANDS, new_len,
  197. - GFP_KERNEL);
  198. -}
  199. -
  200. -struct Qdisc_ops pfifo_fast_ops __read_mostly = {
  201. - .id = "pfifo_fast",
  202. - .priv_size = sizeof(struct pfifo_fast_priv),
  203. - .enqueue = pfifo_fast_enqueue,
  204. - .dequeue = pfifo_fast_dequeue,
  205. - .peek = pfifo_fast_peek,
  206. - .init = pfifo_fast_init,
  207. - .destroy = pfifo_fast_destroy,
  208. - .reset = pfifo_fast_reset,
  209. - .dump = pfifo_fast_dump,
  210. - .change_tx_queue_len = pfifo_fast_change_tx_queue_len,
  211. - .owner = THIS_MODULE,
  212. - .static_flags = TCQ_F_NOLOCK | TCQ_F_CPUSTATS,
  213. -};
  214. -EXPORT_SYMBOL(pfifo_fast_ops);
  215. -
  216. static struct lock_class_key qdisc_tx_busylock;
  217. static struct lock_class_key qdisc_running_key;