[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250206193521.2285488-2-willemdebruijn.kernel@gmail.com>
Date: Thu, 6 Feb 2025 14:34:48 -0500
From: Willem de Bruijn <willemdebruijn.kernel@...il.com>
To: netdev@...r.kernel.org
Cc: davem@...emloft.net,
kuba@...nel.org,
edumazet@...gle.com,
pabeni@...hat.com,
Willem de Bruijn <willemb@...gle.com>
Subject: [PATCH net-next 1/7] tcp: only initialize sockcm tsflags field
From: Willem de Bruijn <willemb@...gle.com>
TCP only reads the tsflags field. Don't bother initializing others.
Signed-off-by: Willem de Bruijn <willemb@...gle.com>
---
Another option is to entirely avoid sockcm_cookie in the tcp hot path.
Limit its use to the sock_cmsg_send branch:
@@ -1123,13 +1123,17 @@ int tcp_sendmsg_locked(struct sock *sk, struct
msghdr *msg, size_t size)
/* 'common' sending to sendq */
}
- sockcm_init(&sockc, sk);
+ tsflags = READ_ONCE(sk->sk_tsflags);
if (msg->msg_controllen) {
+ struct sockcm_cookie sockc = { .tsflags = tsflags };
+
err = sock_cmsg_send(sk, msg, &sockc);
if (unlikely(err)) {
err = -EINVAL;
goto out_err;
}
+
+ tsflags = sockc.tsflags;
This involves a bit more rework, to have sock_tx_timestamp take a u32
tsflags directly.
---
net/ipv4/tcp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 0d704bda6c41..1f94b4e6c7ec 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -1123,7 +1123,7 @@ int tcp_sendmsg_locked(struct sock *sk, struct msghdr *msg, size_t size)
/* 'common' sending to sendq */
}
- sockcm_init(&sockc, sk);
+ sockc = (struct sockcm_cookie) { .tsflags = READ_ONCE(sk->sk_tsflags)};
if (msg->msg_controllen) {
err = sock_cmsg_send(sk, msg, &sockc);
if (unlikely(err)) {
--
2.48.1.502.g6dc24dfdaf-goog
Powered by blists - more mailing lists