Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

xfrm: reduce struct sec_path size

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: Florian Westphal <fw@strlen.de>
Reviewed-by: Steffen Klassert <steffen.klassert@secunet.com>
Link: https://patch.msgid.link/83846bd2e3fa08899bd0162e41bfadfec95e82ef.1770398071.git.pabeni@redhat.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Paolo Abeni and committed by
Jakub Kicinski
dc010e1b e72d4c53

+5 -5
+5 -5
include/net/xfrm.h
··· 1156 1156 #define CRYPTO_INVALID_PROTOCOL 128 1157 1157 1158 1158 /* Used to keep whole l2 header for transport mode GRO */ 1159 - __u32 orig_mac_len; 1159 + __u16 orig_mac_len; 1160 1160 1161 1161 __u8 proto; 1162 1162 __u8 inner_ipproto; 1163 1163 }; 1164 1164 1165 1165 struct sec_path { 1166 - int len; 1167 - int olen; 1168 - int verified_cnt; 1169 - 1170 1166 struct xfrm_state *xvec[XFRM_MAX_DEPTH]; 1171 1167 struct xfrm_offload ovec[XFRM_MAX_OFFLOAD_DEPTH]; 1168 + 1169 + u8 len; 1170 + u8 olen; 1171 + u8 verified_cnt; 1172 1172 }; 1173 1173 1174 1174 struct sec_path *secpath_set(struct sk_buff *skb);