025-tcp-allow-drivers-to-tweak-TSQ-logic.patch 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. From: Eric Dumazet <edumazet@google.com>
  2. Date: Sat, 11 Nov 2017 15:54:12 -0800
  3. Subject: [PATCH] tcp: allow drivers to tweak TSQ logic
  4. MIME-Version: 1.0
  5. Content-Type: text/plain; charset=UTF-8
  6. Content-Transfer-Encoding: 8bit
  7. I had many reports that TSQ logic breaks wifi aggregation.
  8. Current logic is to allow up to 1 ms of bytes to be queued into qdisc
  9. and drivers queues.
  10. But Wifi aggregation needs a bigger budget to allow bigger rates to
  11. be discovered by various TCP Congestion Controls algorithms.
  12. This patch adds an extra socket field, allowing wifi drivers to select
  13. another log scale to derive TCP Small Queue credit from current pacing
  14. rate.
  15. Initial value is 10, meaning that this patch does not change current
  16. behavior.
  17. We expect wifi drivers to set this field to smaller values (tests have
  18. been done with values from 6 to 9)
  19. They would have to use following template :
  20. if (skb->sk && skb->sk->sk_pacing_shift != MY_PACING_SHIFT)
  21. skb->sk->sk_pacing_shift = MY_PACING_SHIFT;
  22. Ref: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1670041
  23. Signed-off-by: Eric Dumazet <edumazet@google.com>
  24. Cc: Johannes Berg <johannes.berg@intel.com>
  25. Cc: Toke Høiland-Jørgensen <toke@toke.dk>
  26. Cc: Kir Kolyshkin <kir@openvz.org>
  27. ---
  28. --- a/include/net/sock.h
  29. +++ b/include/net/sock.h
  30. @@ -267,6 +267,7 @@ struct sock_common {
  31. * @sk_gso_type: GSO type (e.g. %SKB_GSO_TCPV4)
  32. * @sk_gso_max_size: Maximum GSO segment size to build
  33. * @sk_gso_max_segs: Maximum number of GSO segments
  34. + * @sk_pacing_shift: scaling factor for TCP Small Queues
  35. * @sk_lingertime: %SO_LINGER l_linger setting
  36. * @sk_backlog: always used with the per-socket spinlock held
  37. * @sk_callback_lock: used with the callbacks in the end of this struct
  38. @@ -446,6 +447,8 @@ struct sock {
  39. sk_type : 16;
  40. #define SK_PROTOCOL_MAX U8_MAX
  41. u16 sk_gso_max_segs;
  42. +#define sk_pacing_shift sk_pacing_shift /* for backport checks */
  43. + u8 sk_pacing_shift;
  44. unsigned long sk_lingertime;
  45. struct proto *sk_prot_creator;
  46. rwlock_t sk_callback_lock;
  47. --- a/net/core/sock.c
  48. +++ b/net/core/sock.c
  49. @@ -2771,6 +2771,7 @@ void sock_init_data(struct socket *sock,
  50. sk->sk_max_pacing_rate = ~0U;
  51. sk->sk_pacing_rate = ~0U;
  52. + sk->sk_pacing_shift = 10;
  53. sk->sk_incoming_cpu = -1;
  54. /*
  55. * Before updating sk_refcnt, we must commit prior changes to memory
  56. --- a/net/ipv4/tcp_output.c
  57. +++ b/net/ipv4/tcp_output.c
  58. @@ -1700,7 +1700,7 @@ u32 tcp_tso_autosize(const struct sock *
  59. {
  60. u32 bytes, segs;
  61. - bytes = min(sk->sk_pacing_rate >> 10,
  62. + bytes = min(sk->sk_pacing_rate >> sk->sk_pacing_shift,
  63. sk->sk_gso_max_size - 1 - MAX_TCP_HEADER);
  64. /* Goal is to send at least one packet per ms,
  65. @@ -2218,7 +2218,7 @@ static bool tcp_small_queue_check(struct
  66. {
  67. unsigned int limit;
  68. - limit = max(2 * skb->truesize, sk->sk_pacing_rate >> 10);
  69. + limit = max(2 * skb->truesize, sk->sk_pacing_rate >> sk->sk_pacing_shift);
  70. limit = min_t(u32, limit, sysctl_tcp_limit_output_bytes);
  71. limit <<= factor;