Skip to contentSkip to conversation

mpls: Reduce skb re-allocations due to skb_cow()

PATCH Applied Christoph Paasch 3 participants 5 messages Aug 15, 2024 – Aug 19, 2024

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

PATCH 1/1 mpls: Reduce skb re-allocations due to skb_cow()

mpls_xmit() needs to prepend the MPLS-labels to the packet. That implies one needs to make sure there is enough space for it in the headers.

Calling skb_cow() implies however that one wants to change even the playload part of the packet (which is not true for MPLS). Thus, call skb_cow_head() instead, which is what other tunnelling protocols do.

Running a server with this comm it entirely removed the calls to pskb_expand_head() from the callstack in mpls_xmit() thus having significant CPU-reduction, especially at peak times.

---
 net/mpls/mpls_iptunnel.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/mpls/mpls_iptunnel.c +1 -1
index 4385fd3b13be..6e73da94af7f 100644
@@ -106,7 +106,7 @@ static int mpls_xmit(struct sk_buff *skb)
 		hh_len = 0;
 
 	/* Ensure there is enough space for the headers in the skb */
-	if (skb_cow(skb, hh_len + new_header_size))
+	if (skb_cow_head(skb, hh_len + new_header_size))
 		goto drop;
 
 	skb_set_inner_protocol(skb, skb->protocol);
Signature · 1 line
2.39.5 (Apple Git-154)
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Christoph Paasch

mpls_xmit() needs to prepend the MPLS-labels to the packet. That implies one needs to make sure there is enough space for it in the headers.

Calling skb_cow() implies however that one wants to change even the playload part of the packet (which is not true for MPLS). Thus, call skb_cow_head() instead, which is what other tunnelling protocols do.

Running a server with this comm it entirely removed the calls to pskb_expand_head() from the callstack in mpls_xmit() thus having significant CPU-reduction, especially at peak times.

Hi Christoph and Craig,

Including some performance data here would be nice.

Quoted 3 lines

And one minor nit, which I do not think warrants a repost:
netnext -> net-next.

In any case, this looks good to me.

#2 lore raw

Hello!

Quoted 10 lines · Simon Horman
Quoted 7 lines · Christoph Paasch

mpls_xmit() needs to prepend the MPLS-labels to the packet. That implies one needs to make sure there is enough space for it in the headers.

Calling skb_cow() implies however that one wants to change even the playload part of the packet (which is not true for MPLS). Thus, call skb_cow_head() instead, which is what other tunnelling protocols do.

Quoted 7 lines
Quoted 3 lines

Running a server with this comm it entirely removed the calls to pskb_expand_head() from the callstack in mpls_xmit() thus having significant CPU-reduction, especially at peak times.

Hi Christoph and Craig,

Including some performance data here would be nice.

Getting exact production performance data is going to be a major challenge. Not a technical challenge, but rather logistically, ...

Quoted 7 lines
Quoted 3 lines

And one minor nit, which I do not think warrants a repost:
netnext -> net-next.

Ugh - I was wondering why did patchwork thought it was a fix… that explains it.

If a respin is needed, please let me know.

Quoted 3 lines

In any case, this looks good to me.

Thanks,
Christoph

reviewer
#3 lore raw
Quoted 16 lines · Christoph Paasch

Hello!

Quoted 14 lines · Simon Horman
Quoted 10 lines · Christoph Paasch

mpls_xmit() needs to prepend the MPLS-labels to the packet. That implies one needs to make sure there is enough space for it in the headers.

Calling skb_cow() implies however that one wants to change even the playload part of the packet (which is not true for MPLS). Thus, call skb_cow_head() instead, which is what other tunnelling protocols do.

Running a server with this comm it entirely removed the calls to pskb_expand_head() from the callstack in mpls_xmit() thus having significant CPU-reduction, especially at peak times.

Quoted 5 lines
Quoted 3 lines

Hi Christoph and Craig,

Including some performance data here would be nice.

Getting exact production performance data is going to be a major challenge. Not a technical challenge, but rather logistically, ...

Understood :)

#4 lore raw
In reply to Christoph Paasch
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, 15 Aug 2024 09:12:01 -0700 you wrote:

mpls_xmit() needs to prepend the MPLS-labels to the packet. That implies one needs to make sure there is enough space for it in the headers.

Calling skb_cow() implies however that one wants to change even the playload part of the packet (which is not true for MPLS). Thus, call skb_cow_head() instead, which is what other tunnelling protocols do.

[...]

Here is the summary with links:
- [netnext] mpls: Reduce skb re-allocations due to skb_cow()

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

You are awesome, thank you!

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