024-1-tcp-tsq-add-tsq_flags-tsq_enum.patch 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. From 40fc3423b983b864bf70b03199191260ae9b2ea6 Mon Sep 17 00:00:00 2001
  2. From: Eric Dumazet <edumazet@google.com>
  3. Date: Sat, 3 Dec 2016 11:14:50 -0800
  4. Subject: [PATCH 01/10] tcp: tsq: add tsq_flags / tsq_enum
  5. This is a cleanup, to ease code review of following patches.
  6. Old 'enum tsq_flags' is renamed, and a new enumeration is added
  7. with the flags used in cmpxchg() operations as opposed to
  8. single bit operations.
  9. Signed-off-by: Eric Dumazet <edumazet@google.com>
  10. Signed-off-by: David S. Miller <davem@davemloft.net>
  11. ---
  12. include/linux/tcp.h | 11 ++++++++++-
  13. net/ipv4/tcp_output.c | 16 ++++++++--------
  14. 2 files changed, 18 insertions(+), 9 deletions(-)
  15. --- a/include/linux/tcp.h
  16. +++ b/include/linux/tcp.h
  17. @@ -368,7 +368,7 @@ struct tcp_sock {
  18. u32 *saved_syn;
  19. };
  20. -enum tsq_flags {
  21. +enum tsq_enum {
  22. TSQ_THROTTLED,
  23. TSQ_QUEUED,
  24. TCP_TSQ_DEFERRED, /* tcp_tasklet_func() found socket was owned */
  25. @@ -379,6 +379,15 @@ enum tsq_flags {
  26. */
  27. };
  28. +enum tsq_flags {
  29. + TSQF_THROTTLED = (1UL << TSQ_THROTTLED),
  30. + TSQF_QUEUED = (1UL << TSQ_QUEUED),
  31. + TCPF_TSQ_DEFERRED = (1UL << TCP_TSQ_DEFERRED),
  32. + TCPF_WRITE_TIMER_DEFERRED = (1UL << TCP_WRITE_TIMER_DEFERRED),
  33. + TCPF_DELACK_TIMER_DEFERRED = (1UL << TCP_DELACK_TIMER_DEFERRED),
  34. + TCPF_MTU_REDUCED_DEFERRED = (1UL << TCP_MTU_REDUCED_DEFERRED),
  35. +};
  36. +
  37. static inline struct tcp_sock *tcp_sk(const struct sock *sk)
  38. {
  39. return (struct tcp_sock *)sk;
  40. --- a/net/ipv4/tcp_output.c
  41. +++ b/net/ipv4/tcp_output.c
  42. @@ -789,10 +789,10 @@ static void tcp_tasklet_func(unsigned lo
  43. }
  44. }
  45. -#define TCP_DEFERRED_ALL ((1UL << TCP_TSQ_DEFERRED) | \
  46. - (1UL << TCP_WRITE_TIMER_DEFERRED) | \
  47. - (1UL << TCP_DELACK_TIMER_DEFERRED) | \
  48. - (1UL << TCP_MTU_REDUCED_DEFERRED))
  49. +#define TCP_DEFERRED_ALL (TCPF_TSQ_DEFERRED | \
  50. + TCPF_WRITE_TIMER_DEFERRED | \
  51. + TCPF_DELACK_TIMER_DEFERRED | \
  52. + TCPF_MTU_REDUCED_DEFERRED)
  53. /**
  54. * tcp_release_cb - tcp release_sock() callback
  55. * @sk: socket
  56. @@ -813,7 +813,7 @@ void tcp_release_cb(struct sock *sk)
  57. nflags = flags & ~TCP_DEFERRED_ALL;
  58. } while (cmpxchg(&tp->tsq_flags, flags, nflags) != flags);
  59. - if (flags & (1UL << TCP_TSQ_DEFERRED))
  60. + if (flags & TCPF_TSQ_DEFERRED)
  61. tcp_tsq_handler(sk);
  62. /* Here begins the tricky part :
  63. @@ -827,15 +827,15 @@ void tcp_release_cb(struct sock *sk)
  64. */
  65. sock_release_ownership(sk);
  66. - if (flags & (1UL << TCP_WRITE_TIMER_DEFERRED)) {
  67. + if (flags & TCPF_WRITE_TIMER_DEFERRED) {
  68. tcp_write_timer_handler(sk);
  69. __sock_put(sk);
  70. }
  71. - if (flags & (1UL << TCP_DELACK_TIMER_DEFERRED)) {
  72. + if (flags & TCPF_DELACK_TIMER_DEFERRED) {
  73. tcp_delack_timer_handler(sk);
  74. __sock_put(sk);
  75. }
  76. - if (flags & (1UL << TCP_MTU_REDUCED_DEFERRED)) {
  77. + if (flags & TCPF_MTU_REDUCED_DEFERRED) {
  78. inet_csk(sk)->icsk_af_ops->mtu_reduced(sk);
  79. __sock_put(sk);
  80. }