[PATCH v3 net-next 0/9] tcp: avoid struct socket cache line miss in tcp_check_space()

Eric Dumazet posted 9 patches 2 weeks, 2 days ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/multipath-tcp/mptcp_net-next tags/patchew/20260929071743.23624-1-edumazet@kernel.org
.../networking/net_cachelines/tcp_sock.rst    |  1 +
drivers/block/drbd/drbd_worker.c              |  3 +-
drivers/nvme/host/tcp.c                       |  2 +-
drivers/nvme/target/tcp.c                     |  2 +-
fs/dlm/lowcomms.c                             | 10 ++--
include/linux/tcp.h                           |  3 ++
include/net/sock.h                            |  2 +
include/net/tcp.h                             | 30 +++++++++++-
net/ceph/messenger.c                          |  2 +-
net/core/sock.c                               | 46 ++++++++++++++++++-
net/core/stream.c                             |  6 +--
net/ipv4/tcp.c                                |  5 +-
net/ipv4/tcp_bpf.c                            |  2 +-
net/ipv4/tcp_input.c                          |  8 +++-
net/kcm/kcmsock.c                             |  4 +-
net/mptcp/protocol.c                          |  4 +-
net/mptcp/subflow.c                           |  5 ++
net/rds/tcp_send.c                            |  5 +-
net/smc/af_smc.c                              |  2 +-
net/smc/smc_tx.c                              |  6 +--
net/sunrpc/svcsock.c                          |  4 +-
net/sunrpc/xprtsock.c                         |  4 +-
net/tls/tls_sw.c                              |  2 +-
23 files changed, 121 insertions(+), 37 deletions(-)
[PATCH v3 net-next 0/9] tcp: avoid struct socket cache line miss in tcp_check_space()
Posted by Eric Dumazet 2 weeks, 2 days ago
tcp_check_space() is called on every incoming ACK and every transmitted
packet, and tests SOCK_NOSPACE in sk->sk_socket->flags.  Because struct
socket lives in its own cache line and the TCP fast paths do not touch
it for anything else, that test pulls in an extra cache line that is
cold when the working set of active sockets is large.

This series mirrors SOCK_NOSPACE into a new u8 field, tp->tcp_nospace,
placed right after tp->chrono_type in the tcp_sock_write_tx cache line
group (fitting in an existing 3-byte hole before chrono_start, so no
other field moves and sizeof(struct tcp_sock) is unchanged).  Both the
transmit and ACK fast paths already touch that cache line, making the
fast-path test in tcp_check_space() free of extra cache misses while
keeping __tcp_check_space() authoritative on SOCK_NOSPACE.

To maintain the invariant (SOCK_NOSPACE set => tp->tcp_nospace set) from
a single choke point:

 - Patch 1 fixes a long-standing bug in dlm where SOCKWQ_ASYNC_NOSPACE
   was tested and cleared on con->sock->flags instead of SOCK_NOSPACE.
 - Patch 2 introduces sk_set_nospace() and sk_clear_nospace() and
   converts the core networking setters and clearers.
 - Patches 3-8 convert the remaining in-kernel callers (sunrpc, rds,
   dlm, drbd, nvme-tcp, libceph) so that no open-coded set_bit() or
   clear_bit() of SOCK_NOSPACE remains in the tree.
 - Patch 9 adds tp->tcp_nospace, wires it into sk_set_nospace() and
   sk_clear_nospace(), and switches tcp_check_space() to test it.

v3:
 - Rebase and CC subsystem maintainers (Jakub)
 - Link to v2: https://lore.kernel.org/netdev/20260924134729.2047213-1-edumazet@google.com/

v2:
 - Order set_bit(SOCK_NOSPACE) before tp->tcp_nospace = 1 in
   sk_set_nospace() and tp->tcp_nospace = 0 before
   clear_bit(SOCK_NOSPACE) in sk_clear_nospace() so a concurrent
   lockless tcp_poll() cannot leave SOCK_NOSPACE set with
   tp->tcp_nospace cleared (Sashiko)
 - Move tp->tcp_nospace to the 3-byte hole after tp->chrono_type so no
   field in struct tcp_sock shifts after the AccECN bitfield additions
   (Sashiko)
 - Clarify comment and Patch 2 changelog wording (Sashiko)
 - Link to v1: https://lore.kernel.org/netdev/20260922122721.3568295-1-edumazet@google.com/

Eric Dumazet (9):
  dlm: fix send buffer backpressure handling
  net: add sk_set_nospace() and sk_clear_nospace()
  sunrpc: use sk_set_nospace() and sk_clear_nospace()
  rds: use sk_set_nospace()
  dlm: use sk_set_nospace() and sk_clear_nospace()
  drbd: use sk_set_nospace()
  nvme-tcp: use sk_clear_nospace()
  libceph: use sk_clear_nospace()
  tcp: add tp->tcp_nospace

 .../networking/net_cachelines/tcp_sock.rst    |  1 +
 drivers/block/drbd/drbd_worker.c              |  3 +-
 drivers/nvme/host/tcp.c                       |  2 +-
 drivers/nvme/target/tcp.c                     |  2 +-
 fs/dlm/lowcomms.c                             | 10 ++--
 include/linux/tcp.h                           |  3 ++
 include/net/sock.h                            |  2 +
 include/net/tcp.h                             | 30 +++++++++++-
 net/ceph/messenger.c                          |  2 +-
 net/core/sock.c                               | 46 ++++++++++++++++++-
 net/core/stream.c                             |  6 +--
 net/ipv4/tcp.c                                |  5 +-
 net/ipv4/tcp_bpf.c                            |  2 +-
 net/ipv4/tcp_input.c                          |  8 +++-
 net/kcm/kcmsock.c                             |  4 +-
 net/mptcp/protocol.c                          |  4 +-
 net/mptcp/subflow.c                           |  5 ++
 net/rds/tcp_send.c                            |  5 +-
 net/smc/af_smc.c                              |  2 +-
 net/smc/smc_tx.c                              |  6 +--
 net/sunrpc/svcsock.c                          |  4 +-
 net/sunrpc/xprtsock.c                         |  4 +-
 net/tls/tls_sw.c                              |  2 +-
 23 files changed, 121 insertions(+), 37 deletions(-)

-- 
2.56.0.rc1.315.gc6ed9934b7-goog
Re: [PATCH v3 net-next 0/9] tcp: avoid struct socket cache line miss in tcp_check_space()
Posted by netdev-bot+sinfo@kernel.org 2 weeks, 2 days ago
Hi!

This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:

 - Whether the issue was actually triggered, or is only theoretical
   (e.g. found by code inspection). If it was triggered please include
   the symptoms, like the stack trace or error messages.

Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account. If the series needs another revision for
other reasons, please include the information in the commit messages
then.

The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.
Re: [PATCH v3 net-next 0/9] tcp: avoid struct socket cache line miss in tcp_check_space()
Posted by Eric Dumazet 2 weeks, 2 days ago
On Tue, Sep 29, 2026 at 9:24 AM <netdev-bot+sinfo@kernel.org> wrote:
>
> Hi!
>
> This is an automated message. This series looks like a fix, but its
> commit messages seem to be missing some information:
>
>  - Whether the issue was actually triggered, or is only theoretical
>    (e.g. found by code inspection). If it was triggered please include
>    the symptoms, like the stack trace or error messages.
>

Patch 1/9 fixes a bug found by code inspection.

Other patches are not bug fixes.

> Please do not repost the series just to address the above. Instead,
> reply to this email with the missing information, so that reviewers
> can take it into account. If the series needs another revision for
> other reasons, please include the information in the commit messages
> then.
>
> The evaluation is done by an LLM so it may be wrong, if you think
> that is the case please reply and explain.
Re: [PATCH v3 net-next 0/9] tcp: avoid struct socket cache line miss in tcp_check_space()
Posted by patchwork-bot+netdevbpf@kernel.org 1 week, 2 days ago
Hello:

This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Tue, 29 Sep 2026 07:17:34 +0000 you wrote:
> tcp_check_space() is called on every incoming ACK and every transmitted
> packet, and tests SOCK_NOSPACE in sk->sk_socket->flags.  Because struct
> socket lives in its own cache line and the TCP fast paths do not touch
> it for anything else, that test pulls in an extra cache line that is
> cold when the working set of active sockets is large.
> 
> This series mirrors SOCK_NOSPACE into a new u8 field, tp->tcp_nospace,
> placed right after tp->chrono_type in the tcp_sock_write_tx cache line
> group (fitting in an existing 3-byte hole before chrono_start, so no
> other field moves and sizeof(struct tcp_sock) is unchanged).  Both the
> transmit and ACK fast paths already touch that cache line, making the
> fast-path test in tcp_check_space() free of extra cache misses while
> keeping __tcp_check_space() authoritative on SOCK_NOSPACE.
> 
> [...]

Here is the summary with links:
  - [v3,net-next,1/9] dlm: fix send buffer backpressure handling
    https://git.kernel.org/netdev/net-next/c/e234d7625598
  - [v3,net-next,2/9] net: add sk_set_nospace() and sk_clear_nospace()
    https://git.kernel.org/netdev/net-next/c/6ba48a271bdb
  - [v3,net-next,3/9] sunrpc: use sk_set_nospace() and sk_clear_nospace()
    https://git.kernel.org/netdev/net-next/c/28613c4d4757
  - [v3,net-next,4/9] rds: use sk_set_nospace()
    https://git.kernel.org/netdev/net-next/c/b747807ccaf9
  - [v3,net-next,5/9] dlm: use sk_set_nospace() and sk_clear_nospace()
    https://git.kernel.org/netdev/net-next/c/0e0be63cb35d
  - [v3,net-next,6/9] drbd: use sk_set_nospace()
    https://git.kernel.org/netdev/net-next/c/24280d1d2832
  - [v3,net-next,7/9] nvme-tcp: use sk_clear_nospace()
    https://git.kernel.org/netdev/net-next/c/f80fa2ddfe95
  - [v3,net-next,8/9] libceph: use sk_clear_nospace()
    https://git.kernel.org/netdev/net-next/c/5181ac617537
  - [v3,net-next,9/9] tcp: add tp->tcp_nospace
    https://git.kernel.org/netdev/net-next/c/4eee6d58ad14

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html