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.

ipv6: optimize fl6_update_dst()

fl6_update_dst() is called for every TCP (and others) transmit,
and is a nop for common cases.

Split it in two parts :

1) fl6_update_dst() inline helper, small and fast.

2) __fl6_update_dst() for the exception, out of line.

Small size increase to get better TX performance.

$ scripts/bloat-o-meter -t vmlinux.old vmlinux.new
add/remove: 2/2 grow/shrink: 8/0 up/down: 296/-125 (171)
Function old new delta
__fl6_update_dst - 104 +104
rawv6_sendmsg 2244 2284 +40
udpv6_sendmsg 3013 3043 +30
tcp_v6_connect 1514 1534 +20
cookie_v6_check 1501 1519 +18
ip6_datagram_dst_update 673 690 +17
inet6_sk_rebuild_header 499 516 +17
inet6_csk_route_socket 507 524 +17
inet6_csk_route_req 343 360 +17
__pfx___fl6_update_dst - 16 +16
__pfx_fl6_update_dst 16 - -16
fl6_update_dst 109 - -109
Total: Before=22570304, After=22570475, chg +0.00%

Signed-off-by: Eric Dumazet <edumazet@google.com>
Link: https://patch.msgid.link/20260128185548.3738781-1-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Eric Dumazet and committed by
Jakub Kicinski
b1cd687e 70e9a576

+20 -10
+13 -3
include/net/ipv6.h
··· 1174 1174 1175 1175 int ipv6_find_tlv(const struct sk_buff *skb, int offset, int type); 1176 1176 1177 - struct in6_addr *fl6_update_dst(struct flowi6 *fl6, 1178 - const struct ipv6_txoptions *opt, 1179 - struct in6_addr *orig); 1177 + struct in6_addr *__fl6_update_dst(struct flowi6 *fl6, 1178 + const struct ipv6_txoptions *opt, 1179 + struct in6_addr *orig); 1180 + 1181 + static inline struct in6_addr * 1182 + fl6_update_dst(struct flowi6 *fl6, const struct ipv6_txoptions *opt, 1183 + struct in6_addr *orig) 1184 + { 1185 + if (likely(!opt)) 1186 + return NULL; 1187 + 1188 + return __fl6_update_dst(fl6, opt, orig); 1189 + } 1180 1190 1181 1191 /* 1182 1192 * socket options (ipv6_sockglue.c)
+7 -7
net/ipv6/exthdrs.c
··· 1336 1336 EXPORT_SYMBOL_GPL(__ipv6_fixup_options); 1337 1337 1338 1338 /** 1339 - * fl6_update_dst - update flowi destination address with info given 1339 + * __fl6_update_dst - update flowi destination address with info given 1340 1340 * by srcrt option, if any. 1341 1341 * 1342 1342 * @fl6: flowi6 for which daddr is to be updated 1343 1343 * @opt: struct ipv6_txoptions in which to look for srcrt opt 1344 1344 * @orig: copy of original daddr address if modified 1345 1345 * 1346 - * Returns NULL if no txoptions or no srcrt, otherwise returns orig 1346 + * Return: NULL if no srcrt or invalid srcrt type, otherwise returns orig 1347 1347 * and initial value of fl6->daddr set in orig 1348 1348 */ 1349 - struct in6_addr *fl6_update_dst(struct flowi6 *fl6, 1350 - const struct ipv6_txoptions *opt, 1351 - struct in6_addr *orig) 1349 + struct in6_addr *__fl6_update_dst(struct flowi6 *fl6, 1350 + const struct ipv6_txoptions *opt, 1351 + struct in6_addr *orig) 1352 1352 { 1353 - if (!opt || !opt->srcrt) 1353 + if (!opt->srcrt) 1354 1354 return NULL; 1355 1355 1356 1356 *orig = fl6->daddr; ··· 1374 1374 1375 1375 return orig; 1376 1376 } 1377 - EXPORT_SYMBOL_GPL(fl6_update_dst); 1377 + EXPORT_SYMBOL_GPL(__fl6_update_dst);