Skip to content

tcp/mptcp: Don't call tcp_update_recv_tstamps() if not needed.

Kuniyuki Iwashima netdev 2 versions – Applied

Status from this message: This series was applied to netdev/net-next.git (main)

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest2 patches 1 replyApplied 2/2
  2. v12 patches 3 repliesSuperseded

Changes in v2 from the cover letter

* Patch 1
* Mention software tstamp
* s/sk_want_rx_tstamps/tcp_want_rx_tstamp_cmsg/ and moved to include/net/tcp.h
* Use const in tcp_want_rx_tstamps()

Patches in v2 All 2 applied

#Subject and filesSizeRepliesApplied
1/2tcp: Don't call tcp_update_recv_tstamps() if not needed.include/net/tcp.h net/ipv4/tcp.c+17 -30 repliesApplied
2/2mptcp: Don't call tcp_update_recv_tstamps() if not needed.net/mptcp/protocol.c+2 -11 replyApplied

Reviews trailers per patch

1 of 2 patches has a Reviewed-by or Acked-by.

PatchMatthieu Baerts (NGI0)
1/2
2/2A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 net-next 0/2] tcp/mptcp: Don't call tcp_update_recv_tstamps() if not needed.

When RX HWtstamp is enabled on NIC, skb_hwtstamps(skb)->hwtstamp is set. It is also set when one socket enables software timestamp.

Then, recvmsg() always calls tcp_recv_timestamp() even when sockets do not need timestamp.

Since it is called after release_sock() and touches sk->sk_tsflags, which shares the same cacheline with sk->sk_forward_alloc, it stalls:

   0.31 │ 403:   test   %al,%al
   0.02 │      ↓ je     4a0
  12.40 │        test   $0x2,%bpl        ; if (cmsg_flags & TCP_CMSG_TS)
        │      ↓ je     48f
  11.59 │        mov    0x60(%r14),%r15  ; sock_flag(sk, SOCK_TSTAMP_NEW)
  12.25 │        mov    0x170(%r14),%ebx ; READ_ONCE(sk->sk_tsflags)
  20.70 │        mov    0xd0(%rsp),%rdi  ; if (tss->ts[0]) {
   0.39 │        test   %rdi,%rdi
        │      ↓ je     44c

Commit f0e70409b7eb ("net: avoid unconditionally touching sk_tsflags on RX") introduced SOCK_TIMESTAMPING_ANY to avoid the issue for UDP.

This series checks it to avoid touching sk->sk_tsflags unnecessarily.

With the change, tcp_rr -T 128 -F 10000 gains ~3% more throughput on AMD EPYC 7B12 Zen 2 Rome (2 sockets, 256 vCPUs).

Changes:
v2:
* Patch 1
* Mention software tstamp
* s/sk_want_rx_tstamps/tcp_want_rx_tstamp_cmsg/ and moved to include/net/tcp.h
* Use const in tcp_want_rx_tstamps()

v1: https://lore.kernel.org/netdev/[email protected]/

Kuniyuki Iwashima (2):
tcp: Don't call tcp_update_recv_tstamps() if not needed.
mptcp: Don't call tcp_update_recv_tstamps() if not needed.

 include/net/tcp.h    |  7 +++++++
 net/ipv4/tcp.c       | 13 ++++++++++---
 net/mptcp/protocol.c |  3 ++-
 3 files changed, 19 insertions(+), 4 deletions(-)
Signature · 1 line
2.56.0.455.g6c5a503b38-goog