* [PATCH net-next] xfrm: reduce struct sec_path size
@ 2026-02-06 17:14 Paolo Abeni
2026-02-07 10:39 ` Florian Westphal
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Paolo Abeni @ 2026-02-06 17:14 UTC (permalink / raw)
To: netdev
Cc: Steffen Klassert, Herbert Xu, David S. Miller, Eric Dumazet,
Jakub Kicinski, Simon Horman, Florian Westphal
The mentioned struct has an hole and uses unnecessary wide type to
store MAC length and indexes of very small arrays.
It's also embedded into the skb_extensions, and the latter, due
to recent CAN changes, may exceeds the 192 bytes mark (3 cachelines
on x86_64 arch) on some reasonable configurations.
Reordering and the sec_path fields, shrinking xfrm_offload.orig_mac_len
to 16 bits and xfrm_offload.{len,olen,verified_cnt} to u8, we can save
16 bytes and keep skb_extensions size under control.
Before:
struct sec_path {
int len;
int olen;
int verified_cnt;
/* XXX 4 bytes hole, try to pack */$
struct xfrm_state * xvec[6];
struct xfrm_offload ovec[1];
/* size: 88, cachelines: 2, members: 5 */
/* sum members: 84, holes: 1, sum holes: 4 */
/* last cacheline: 24 bytes */
};
After:
struct sec_path {
struct xfrm_state * xvec[6];
struct xfrm_offload ovec[1];
/* typedef u8 -> __u8 */ unsigned char len;
/* typedef u8 -> __u8 */ unsigned char olen;
/* typedef u8 -> __u8 */ unsigned char verified_cnt;
/* size: 72, cachelines: 2, members: 5 */
/* padding: 1 */
/* last cacheline: 8 bytes */
};
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
---
RFC -> v1:
- shrink lens fields - thanks Florian
- RFC: https://lore.kernel.org/netdev/a2552992ca2fa29754340eaa05b1a185fca7a381.1770309837.git.pabeni@redhat.com/
---
include/net/xfrm.h | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/include/net/xfrm.h b/include/net/xfrm.h
index 0a14daaa5dd4..10d3edde6b2f 100644
--- a/include/net/xfrm.h
+++ b/include/net/xfrm.h
@@ -1156,19 +1156,19 @@ struct xfrm_offload {
#define CRYPTO_INVALID_PROTOCOL 128
/* Used to keep whole l2 header for transport mode GRO */
- __u32 orig_mac_len;
+ __u16 orig_mac_len;
__u8 proto;
__u8 inner_ipproto;
};
struct sec_path {
- int len;
- int olen;
- int verified_cnt;
-
struct xfrm_state *xvec[XFRM_MAX_DEPTH];
struct xfrm_offload ovec[XFRM_MAX_OFFLOAD_DEPTH];
+
+ u8 len;
+ u8 olen;
+ u8 verified_cnt;
};
struct sec_path *secpath_set(struct sk_buff *skb);
--
2.52.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] xfrm: reduce struct sec_path size
2026-02-06 17:14 [PATCH net-next] xfrm: reduce struct sec_path size Paolo Abeni
@ 2026-02-07 10:39 ` Florian Westphal
2026-02-09 5:55 ` Steffen Klassert
2026-02-11 5:00 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Florian Westphal @ 2026-02-07 10:39 UTC (permalink / raw)
To: Paolo Abeni
Cc: netdev, Steffen Klassert, Herbert Xu, David S. Miller,
Eric Dumazet, Jakub Kicinski, Simon Horman
Paolo Abeni <pabeni@redhat.com> wrote:
> The mentioned struct has an hole and uses unnecessary wide type to
> store MAC length and indexes of very small arrays.
>
> It's also embedded into the skb_extensions, and the latter, due
> to recent CAN changes, may exceeds the 192 bytes mark (3 cachelines
> on x86_64 arch) on some reasonable configurations.
>
> Reordering and the sec_path fields, shrinking xfrm_offload.orig_mac_len
> to 16 bits and xfrm_offload.{len,olen,verified_cnt} to u8, we can save
> 16 bytes and keep skb_extensions size under control.
Reviewed-by: Florian Westphal <fw@strlen.de>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] xfrm: reduce struct sec_path size
2026-02-06 17:14 [PATCH net-next] xfrm: reduce struct sec_path size Paolo Abeni
2026-02-07 10:39 ` Florian Westphal
@ 2026-02-09 5:55 ` Steffen Klassert
2026-02-11 5:00 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Steffen Klassert @ 2026-02-09 5:55 UTC (permalink / raw)
To: Paolo Abeni
Cc: netdev, Herbert Xu, David S. Miller, Eric Dumazet, Jakub Kicinski,
Simon Horman, Florian Westphal
On Fri, Feb 06, 2026 at 06:14:36PM +0100, Paolo Abeni wrote:
> The mentioned struct has an hole and uses unnecessary wide type to
> store MAC length and indexes of very small arrays.
>
> It's also embedded into the skb_extensions, and the latter, due
> to recent CAN changes, may exceeds the 192 bytes mark (3 cachelines
> on x86_64 arch) on some reasonable configurations.
>
> Reordering and the sec_path fields, shrinking xfrm_offload.orig_mac_len
> to 16 bits and xfrm_offload.{len,olen,verified_cnt} to u8, we can save
> 16 bytes and keep skb_extensions size under control.
>
> Before:
>
> struct sec_path {
> int len;
> int olen;
> int verified_cnt;
>
> /* XXX 4 bytes hole, try to pack */$
> struct xfrm_state * xvec[6];
> struct xfrm_offload ovec[1];
>
> /* size: 88, cachelines: 2, members: 5 */
> /* sum members: 84, holes: 1, sum holes: 4 */
> /* last cacheline: 24 bytes */
> };
>
> After:
>
> struct sec_path {
> struct xfrm_state * xvec[6];
> struct xfrm_offload ovec[1];
> /* typedef u8 -> __u8 */ unsigned char len;
> /* typedef u8 -> __u8 */ unsigned char olen;
> /* typedef u8 -> __u8 */ unsigned char verified_cnt;
>
> /* size: 72, cachelines: 2, members: 5 */
> /* padding: 1 */
> /* last cacheline: 8 bytes */
> };
>
> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Reviewed-by: Steffen Klassert <steffen.klassert@secunet.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] xfrm: reduce struct sec_path size
2026-02-06 17:14 [PATCH net-next] xfrm: reduce struct sec_path size Paolo Abeni
2026-02-07 10:39 ` Florian Westphal
2026-02-09 5:55 ` Steffen Klassert
@ 2026-02-11 5:00 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-02-11 5:00 UTC (permalink / raw)
To: Paolo Abeni
Cc: netdev, steffen.klassert, herbert, davem, edumazet, kuba, horms,
fw
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Fri, 6 Feb 2026 18:14:36 +0100 you wrote:
> The mentioned struct has an hole and uses unnecessary wide type to
> store MAC length and indexes of very small arrays.
>
> It's also embedded into the skb_extensions, and the latter, due
> to recent CAN changes, may exceeds the 192 bytes mark (3 cachelines
> on x86_64 arch) on some reasonable configurations.
>
> [...]
Here is the summary with links:
- [net-next] xfrm: reduce struct sec_path size
https://git.kernel.org/netdev/net-next/c/dc010e1b4bb6
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-02-11 5:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-06 17:14 [PATCH net-next] xfrm: reduce struct sec_path size Paolo Abeni
2026-02-07 10:39 ` Florian Westphal
2026-02-09 5:55 ` Steffen Klassert
2026-02-11 5:00 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox