662-remove_pfifo_fast.patch 5.6 KB

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