024-4-tcp-tsq-avoid-one-atomic-in-tcp_wfree.patch 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. From a9b204d1564702b704ad6fe74f10a102c7b87ba3 Mon Sep 17 00:00:00 2001
  2. From: Eric Dumazet <[email protected]>
  3. Date: Sat, 3 Dec 2016 11:14:53 -0800
  4. Subject: [PATCH 04/10] tcp: tsq: avoid one atomic in tcp_wfree()
  5. Under high load, tcp_wfree() has an atomic operation trying
  6. to schedule a tasklet over and over.
  7. We can schedule it only if our per cpu list was empty.
  8. Signed-off-by: Eric Dumazet <[email protected]>
  9. Signed-off-by: David S. Miller <[email protected]>
  10. ---
  11. net/ipv4/tcp_output.c | 5 ++++-
  12. 1 file changed, 4 insertions(+), 1 deletion(-)
  13. --- a/net/ipv4/tcp_output.c
  14. +++ b/net/ipv4/tcp_output.c
  15. @@ -885,6 +885,7 @@ void tcp_wfree(struct sk_buff *skb)
  16. for (oval = READ_ONCE(tp->tsq_flags);; oval = nval) {
  17. struct tsq_tasklet *tsq;
  18. + bool empty;
  19. if (!(oval & TSQF_THROTTLED) || (oval & TSQF_QUEUED))
  20. goto out;
  21. @@ -897,8 +898,10 @@ void tcp_wfree(struct sk_buff *skb)
  22. /* queue this socket to tasklet queue */
  23. local_irq_save(flags);
  24. tsq = this_cpu_ptr(&tsq_tasklet);
  25. + empty = list_empty(&tsq->head);
  26. list_add(&tp->tsq_node, &tsq->head);
  27. - tasklet_schedule(&tsq->tasklet);
  28. + if (empty)
  29. + tasklet_schedule(&tsq->tasklet);
  30. local_irq_restore(flags);
  31. return;
  32. }