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. @@ -260,6 +260,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. @@ -421,6 +422,8 @@ struct sock {
  39. kmemcheck_bitfield_end(flags);
  40. u16 sk_gso_max_segs;
  41. +#define sk_pacing_shift sk_pacing_shift /* for backport checks */
  42. + u8 sk_pacing_shift;
  43. unsigned long sk_lingertime;
  44. struct proto *sk_prot_creator;
  45. rwlock_t sk_callback_lock;
  46. --- a/net/core/sock.c
  47. +++ b/net/core/sock.c
  48. @@ -2475,6 +2475,7 @@ void sock_init_data(struct socket *sock,
  49. sk->sk_max_pacing_rate = ~0U;
  50. sk->sk_pacing_rate = ~0U;
  51. + sk->sk_pacing_shift = 10;
  52. sk->sk_incoming_cpu = -1;
  53. /*
  54. * Before updating sk_refcnt, we must commit prior changes to memory
  55. --- a/net/ipv4/tcp_output.c
  56. +++ b/net/ipv4/tcp_output.c
  57. @@ -1593,7 +1593,7 @@ u32 tcp_tso_autosize(const struct sock *
  58. {
  59. u32 bytes, segs;
  60. - bytes = min(sk->sk_pacing_rate >> 10,
  61. + bytes = min(sk->sk_pacing_rate >> sk->sk_pacing_shift,
  62. sk->sk_gso_max_size - 1 - MAX_TCP_HEADER);
  63. /* Goal is to send at least one packet per ms,
  64. @@ -2123,7 +2123,7 @@ static bool tcp_small_queue_check(struct
  65. {
  66. unsigned int limit;
  67. - limit = max(2 * skb->truesize, sk->sk_pacing_rate >> 10);
  68. + limit = max(2 * skb->truesize, sk->sk_pacing_rate >> sk->sk_pacing_shift);
  69. limit = min_t(u32, limit, sysctl_tcp_limit_output_bytes);
  70. limit <<= factor;