Skip to contentSkip to conversation

tcp: gro: inline tcp_gro_pull_header()

PATCH Applied Eric Dumazet 3 participants 6 messages Nov 13, 2025 – Nov 15, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tcp: gro: inline tcp_gro_pull_header()

tcp_gro_pull_header() is used in GRO fast path, inline it.

---
 include/net/gro.h      | 27 +++++++++++++++++++++++++++
 include/net/tcp.h      |  1 -
 net/ipv4/tcp_offload.c | 27 ---------------------------
 3 files changed, 27 insertions(+), 28 deletions(-)
include/net/gro.h +27 -0
index e3affb2e2ca8b2c89a9ffd6f7fb1219a42200ac3..b65f631c521d7d9741ef86781add0038c9ce4055 100644
@@ -593,4 +593,31 @@ static inline void inet6_get_iif_sdif(const struct sk_buff *skb, int *iif, int *
 struct packet_offload *gro_find_receive_by_type(__be16 type);
 struct packet_offload *gro_find_complete_by_type(__be16 type);
 
+static inline struct tcphdr *tcp_gro_pull_header(struct sk_buff *skb)
+{
+	unsigned int thlen, hlen, off;
+	struct tcphdr *th;
+
+	off = skb_gro_offset(skb);
+	hlen = off + sizeof(*th);
+	th = skb_gro_header(skb, hlen, off);
+	if (unlikely(!th))
+		return NULL;
+
+	thlen = th->doff * 4;
+	if (unlikely(thlen < sizeof(*th)))
+		return NULL;
+
+	hlen = off + thlen;
+	if (!skb_gro_may_pull(skb, hlen)) {
+		th = skb_gro_header_slow(skb, hlen, off);
+		if (unlikely(!th))
+			return NULL;
+	}
+
+	skb_gro_pull(skb, thlen);
+
+	return th;
+}
+
 #endif /* _NET_GRO_H */
include/net/tcp.h +0 -1
index 4833ec7903eca45cd31bb4ab023a8d326ed8b436..0deb5e9dd9114641468f26696b086b8261a67f60 100644
@@ -2313,7 +2313,6 @@ void tcp_v4_destroy_sock(struct sock *sk);
 
 struct sk_buff *tcp_gso_segment(struct sk_buff *skb,
 				netdev_features_t features);
-struct tcphdr *tcp_gro_pull_header(struct sk_buff *skb);
 struct sk_buff *tcp_gro_lookup(struct list_head *head, struct tcphdr *th);
 struct sk_buff *tcp_gro_receive(struct list_head *head, struct sk_buff *skb,
 				struct tcphdr *th);
net/ipv4/tcp_offload.c +0 -27
index 2cb93da93abc2922fc347f4d62093741eb17c9d8..fdda18b1abda0f69226f6b59cec6d7d51b53555b 100644
@@ -282,33 +282,6 @@ struct sk_buff *tcp_gro_lookup(struct list_head *head, struct tcphdr *th)
 	return NULL;
 }
 
-struct tcphdr *tcp_gro_pull_header(struct sk_buff *skb)
-{
-	unsigned int thlen, hlen, off;
-	struct tcphdr *th;
-
-	off = skb_gro_offset(skb);
-	hlen = off + sizeof(*th);
-	th = skb_gro_header(skb, hlen, off);
-	if (unlikely(!th))
-		return NULL;
-
-	thlen = th->doff * 4;
-	if (thlen < sizeof(*th))
-		return NULL;
-
-	hlen = off + thlen;
-	if (!skb_gro_may_pull(skb, hlen)) {
-		th = skb_gro_header_slow(skb, hlen, off);
-		if (unlikely(!th))
-			return NULL;
-	}
-
-	skb_gro_pull(skb, thlen);
-
-	return th;
-}
-
 struct sk_buff *tcp_gro_receive(struct list_head *head, struct sk_buff *skb,
 				struct tcphdr *th)
 {
Signature · 1 line
2.51.2.1041.gc1ab5b90ca-goog
#2 lore raw
Quoted 7 lines · Alexander Lobakin

From: Eric Dumazet <[email protected]>
Date: Thu, 13 Nov 2025 14:03:57 +0000

Quoted 1 line

tcp_gro_pull_header() is used in GRO fast path, inline it.

Looks reasonable, but... any perf numbers? bloat-o-meter stats?

This is used two times, one from IPv4, one from IPv6.

FDO usually embeds this function in the two callers, this patch reduces the gap between FDO and non FDO kernels.
Non FDO builds get a ~0.5 % performance increase with this patch, for a cost of less than 192 bytes on x86_64.

It might sound small, but adding all these changes together is not small.

#3 lore raw

From: Eric Dumazet <[email protected]>
Date: Fri, 14 Nov 2025 08:09:31 -0800

Quoted 8 lines
Quoted 6 lines · Alexander Lobakin

From: Eric Dumazet <[email protected]>
Date: Thu, 13 Nov 2025 14:03:57 +0000

Quoted 1 line

tcp_gro_pull_header() is used in GRO fast path, inline it.

Quoted 8 lines
Quoted 1 line

Looks reasonable, but... any perf numbers? bloat-o-meter stats?

This is used two times, one from IPv4, one from IPv6.

FDO usually embeds this function in the two callers, this patch reduces the gap between FDO and non FDO kernels.
Non FDO builds get a ~0.5 % performance increase with this patch, for a cost of less than 192 bytes on x86_64.

I asked for these as you usually provide detailed stats with perf top output etc, but not this time.

(although you always require to provide perf stats when someone else
sends an optimization patch)

Quoted 2 lines

It might sound small, but adding all these changes together is not small.

A couple weeks ago you wrote that 1% of perf improvement is "a noise".

I'm not against this patch (if you add everything from the above to the commit message + maybe your usual detailed stats).
+0.5% for 192 bytes sounds good to me (I don't call it "a noise").

But from my PoV this just feels like "my 0.5% is bigger than your 1%" and "you have to show me the numbers, and I don't".

The rules are the same for everyone.

Thanks,
Olek

#4 lore raw
Quoted 16 lines · Alexander Lobakin

From: Eric Dumazet <[email protected]>
Date: Fri, 14 Nov 2025 08:09:31 -0800

Quoted 12 lines
Quoted 7 lines · Alexander Lobakin

From: Eric Dumazet <[email protected]>
Date: Thu, 13 Nov 2025 14:03:57 +0000

Quoted 1 line

tcp_gro_pull_header() is used in GRO fast path, inline it.

Looks reasonable, but... any perf numbers? bloat-o-meter stats?

This is used two times, one from IPv4, one from IPv6.

Quoted 7 lines
Quoted 4 lines

FDO usually embeds this function in the two callers, this patch reduces the gap between FDO and non FDO kernels.
Non FDO builds get a ~0.5 % performance increase with this patch, for a cost of less than 192 bytes on x86_64.

I asked for these as you usually provide detailed stats with perf top output etc, but not this time.

Because I am currently chasing many small optimizations, and they hit various subsystems.

Quoted 9 lines

(although you always require to provide perf stats when someone else
sends an optimization patch)

Quoted 2 lines

It might sound small, but adding all these changes together is not small.

A couple weeks ago you wrote that 1% of perf improvement is "a noise".

Quoted 8 lines

I'm not against this patch (if you add everything from the above to the commit message + maybe your usual detailed stats).
+0.5% for 192 bytes sounds good to me (I don't call it "a noise").

But from my PoV this just feels like "my 0.5% is bigger than your 1%" and "you have to show me the numbers, and I don't".

The rules are the same for everyone.

Sure, thank you so much !

#5 lore raw
In reply to Eric Dumazet
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 8 lines · On Thu, 13 Nov 2025 14:03:57 +0000 you wrote:

tcp_gro_pull_header() is used in GRO fast path, inline it.

---
 include/net/gro.h      | 27 +++++++++++++++++++++++++++
 include/net/tcp.h      |  1 -
 net/ipv4/tcp_offload.c | 27 ---------------------------
 3 files changed, 27 insertions(+), 28 deletions(-)

Here is the summary with links:
- [net-next] tcp: gro: inline tcp_gro_pull_header()

    https://git.kernel.org/netdev/net-next/c/6d650ae9282b

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html