]> git.baikalelectronics.ru Git - kernel.git/commit
skbuff: micro-optimize {,__}skb_header_pointer()
authorAlexander Lobakin <alobakin@pm.me>
Sun, 14 Mar 2021 11:11:50 +0000 (11:11 +0000)
committerDavid S. Miller <davem@davemloft.net>
Sun, 14 Mar 2021 21:48:02 +0000 (14:48 -0700)
commit640896c90086b5186057f2331ce6b5d49a23f6cf
treec6bf285f9bd54f1a0b57d604226f34895f4034f2
parent1fbe9148272eecc5d7acd2bf0e3134b0d963a6a6
skbuff: micro-optimize {,__}skb_header_pointer()

{,__}skb_header_pointer() helpers exist mainly for preventing
accesses-beyond-end of the linear data.
In the vast majorify of cases, they bail out on the first condition.
All code going after is mostly a fallback.
Mark the most common branch as 'likely' one to move it in-line.
Also, skb_copy_bits() can return negative values only when the input
arguments are invalid, e.g. offset is greater than skb->len. It can
be safely marked as 'unlikely' branch, assuming that hotpath code
provides sane input to not fail here.

These two bump the throughput with a single Flow Dissector pass on
every packet (e.g. with RPS or driver that uses eth_get_headlen())
on 20 Mbps per flow/core.

Signed-off-by: Alexander Lobakin <alobakin@pm.me>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/skbuff.h